<p>Hello, we’re a tiny team (less than 5 years of programming) trying to create a new experimental project in golang. We came from Node and Python background. </p>
<p>Please give us some advice of dos and don’ts and the things we should be preparing ahead.</p>
<p>Thank you. </p>
<hr/>**评论:**<br/><br/>razor_XI: <pre><p>I started a new project in GO at work less than a year ago. Here are a few pointers : </p>
<ol>
<li><p>Don't jump into web frameworks, I did this mistake and I regret it big time. Try to implement your own framework which meets your project needs.</p></li>
<li><p>GO is not a magical tool which give you faster application compared to Python and Node. Don't buy into the hype, build something , test it and see the result for yourself.</p></li>
<li><p>Since you are coming from a dynamic language background, static typing might be a pain. Remember pain is temporary. I was working in a NodeJS API project where the previous developer had used "userid" and "user_id", while giving out a json response. (The mobile devs hated this practice). You can avoid these problems, when you create a struct model. </p></li>
<li><p>Finally, Don't give up. GO is an excellent language. Go and make something useful.</p></li>
</ol></pre>InevitableAlarm: <pre><p>GO® is not an Acronym™.</p></pre>SeerUD: <pre><blockquote>
<p><del>GO</del> Go is not a magical tool which give you faster application compared to Python and Node. Don't buy into the hype, build something , test it and see the result for yourself.</p>
</blockquote>
<p>This is true, but you can also assume for many cases that Go <em>should be</em> faster than both Node and Python. Not always though. Also, Go doesn't protect you from being a bad developer. If you write something that will end up being slow, it'll be slow. Go does provide you with some excellent tools to help both avoid and detect these kinds of things though.</p></pre>jamra06: <pre><p>Static typing is not just for speed. It’s also for correctness and error handling. </p>
<p>I don’t worry about speed that much. I worry about clarity. Most of my time is spend maintaining things and the database is my web bottleneck, not the web framework. </p></pre>SeerUD: <pre><p>Yep, absolutely. You can definitely do some crazy things in the name of speed in Go. I've been working on a parser library (for something that I'm not yet ready to release) that will be used as part of an HTTP request, so I've been trying to ensure that's as fast as possible. It does make for some harder to understand code, but in that case it's worth it in my opinion.</p>
<p>Funnily enough it's something that already exists in JS, and the implementation of the lexer is twice as fast as the JS one for most input. I'm sure the JS implementation could also be made faster though.</p>
<p>In many cases, especially in most applications it's not worth this. In my case, better performance than the existing implementations is one of the main goals. Like you've said, IO is usually a much bigger bottleneck.</p></pre>xzenuu: <pre><p>Thank you so much.</p></pre>lost_izalith_is_best: <pre><blockquote>
<p>static typing might be a pain.</p>
</blockquote>
<p>Yup, PHP & JS dev for 9 years and when I switched full-time to Go it was definitely a learning experience. However, when I switch back to JS for front-end stuff or maintain my PHP applications, the fact that I can go <code>10.54 . 11 . "fred"</code> in PHP or <code>5 + 5.0 - "3"</code> in JS (and get... <em>7</em>) and NOT get an error message does not strike me as a good thing.</p></pre>chneau: <pre><p>I remember the difficulties I got, here are my tips.</p>
<ul>
<li><p>Use Visual Studio Code, add the Go extension, it will ask you to install some go commands, do it, that's it, you are ready to Go. (having the good tools is a good start, side note: it looks like GoLand is a very good IDE "too")</p></li>
<li><p>Understand how and why Go put your projects under ~/go/src (= how to not go to war against the env var GOPATH)</p></li>
<li><p>Understand how you should package your code. ( <a href="https://www.youtube.com/watch?v=MzTcsI6tn-0" rel="nofollow">this video I just saw moment ago</a> and <a href="https://github.com/golang-standards/project-layout" rel="nofollow">this template that I try to follow</a> )</p></li>
</ul>
<p>And enjoy this marvellous language :) that ships with test package, command line flags, documentation generation, and so much more ...</p></pre>SeerUD: <pre><p>If you put another newline under your first sentence then the bullet points will be formatted correctly.</p></pre>chneau: <pre><p>Aye ! Edited, Thank you very much :)</p></pre>SoWiT: <pre><p>I've tried using VS Code with Go but it worked so slow I couldn't bear it. Each code change took 5s for intellisense to catch up. GoLand is amazing tho.</p></pre>xzenuu: <pre><p>Thank you so much. </p></pre>mincor: <pre><p>+1 to getting a good IDE. There are many IDE that support go now, but only few do so while making it feel native. Visual Studio Code is one of them, GoLand is probably good too, last time I used it, it felt a bit cluncky around the edges, but that was a while ago, and since then it probably is much better. </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传