Best resource to learn Go?

polaris · · 610 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hello all. I was wondering what an experienced Go programmer would recommend to a novice that&#39;s looking into learning the language. I came across several websites, but I want input as to what you guys would think is best.</p> <hr/>**评论:**<br/><br/>MarkPitman: <pre><p>I really liked <a href="https://gobyexample.com/">https://gobyexample.com/</a> when I was first learning go.</p></pre>AlBusters: <pre><p>Sorry for not replying earlier. I spent 4 hours looking through these last night and it was amazing. Thank you!</p></pre>schoenobates: <pre><p>+1 - This in combination with the official docs is ace.</p></pre>tuxlinski: <pre><p>Start with <a href="http://www.golang-book.com">Golang Book</a> and after <a href="https://golang.org/doc/effective_go.html">Effective Go</a></p></pre>AlBusters: <pre><p>I&#39;ll check it out once I make it out of gobyexample.</p></pre>nathj07: <pre><p>Work through the go tour <a href="https://tour.golang.org/welcome/1and">https://tour.golang.org/welcome/1and</a> read the language as well as the spec. Reading the standard library is super useful alongside the docs.</p></pre>AlBusters: <pre><p>Had not found this one before. Thanks!</p></pre>andygrunwald: <pre><p>I blogged about how i learned go: <a href="http://andygrunwald.com/blog/2015/06/20/resources-to-learn-golang/">http://andygrunwald.com/blog/2015/06/20/resources-to-learn-golang/</a> Maybe helpful</p></pre>AlBusters: <pre><p>Will definitely check it out!</p></pre>yocoda: <pre><p>I <a href="https://vimeo.com/53221560">like this golang talk</a> by <a href="/u/enneff">/u/enneff</a> that walks you through building a chat program. The chat program goes from a command line interface, to using websockets, to having AI that simulates users. The talk shows the power of golang&#39;s type system.</p></pre>jbuberel: <pre><p>See also: </p> <p><a href="https://github.com/golang/go/wiki#learning-more-about-go" rel="nofollow">https://github.com/golang/go/wiki#learning-more-about-go</a></p></pre>AlBusters: <pre><p>Resources upon resources! Thank you!</p></pre>Sk1LLb0X: <pre><p>if you&#39;re lazy and already know how to program <a href="http://learnxinyminutes.com/docs/go/" rel="nofollow">http://learnxinyminutes.com/docs/go/</a></p></pre>AlBusters: <pre><p>I had seen that site, actually. I need to check it out further.</p></pre>qxclpxzk: <pre><p>If you are interested in web development, write a website or app with minimal third-party module usage. I mainly use Gorilla&#39;s mux and websocket modules in addition to github.com/lib/pq for my postgreSQL driver. Start with serving just a string, then a static page, and then start adding routes and experimenting with controller functions. I recommend <a href="http://astaxie.gitbooks.io/build-web-application-with-golang/content/en/index.html" rel="nofollow">this book on building web services.</a></p> <p>You&#39;ll want to use html/template if you want to serve web pages. An example of a static template composed of other templates would be:</p> <pre><code>{{define &#34;index-loggedout&#34;}} &lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; {{template &#34;header&#34;}} &lt;/head&gt; &lt;body&gt; {{template &#34;nav-loggedout&#34;}} {{template &#34;news&#34;}} &lt;/body&gt; &lt;/html&gt; {{end}} </code></pre> <p>Making your own user authentication module is a good next step. It will get you comfortable with the different http methods (ie: GET, POST) and database interaction.</p> <p>A minimal <em>user.go</em> I developed has the following functions: </p> <ul> <li>hashPassword(password) hashedPassword string</li> <li>addUser(name, password, email) success bool</li> <li>userExists(user) exists bool</li> <li>newSession(user) authKey string</li> <li>sessionIsValid(authKey) valid bool</li> <li>deleteSession(authKey) err error</li> <li>getNameByKey(authKey) userName string</li> </ul> <p>powering the following endpoints: </p> <ul> <li>/ (GET) -&gt; logged out page || logged in page</li> <li>/login (POST) -&gt; error string || set auth cookie</li> <li>/register (POST) -&gt; error string || set auth cookie</li> <li>/logout (GET) -&gt; delete auth key from session table</li> </ul> <p>Where jQuery handles ajax form posting, displaying error messages (eg: incorrect login, user already exists, password too short, ...), and refreshing the page upon authentication.</p> <p>A real web service will need additional functions like account recovery, email verification, and editing account info, but these are the essentials. Once you have your user authentication infrastructure set up, you are ready to build out your application.</p> <p>PS: Make sure you adhere to security standards when handling user info. Most importantly: you may only transmit passwords or auth keys over SSL (https), and you may only store securely hashed passwords generated by libraries like pbkdf2. You can set up an http -&gt; https redirection server with 3 lines of code right before you start your secure server.</p> <pre><code>go http.ListenAndServe(&#34;:8080&#34;, func (w http.ResponseWriter, r *http.request) { http.Redirect(w, r, &#34;https://your-website.com&#34;, http.StatusMovedPermanently) }) </code></pre></pre>tuxlinski: <pre><p>Very nice! Just to complete, a few days ago I wrote a simply crud using MySQL driver to teach in an easier way. <a href="https://github.com/gustavokuklinski/go-mysql-crud/" rel="nofollow">Github - Go MySQL Crud</a></p></pre>tv64738: <pre><p><a href="http://golang.org/doc/" rel="nofollow">http://golang.org/doc/</a> walks you through quite a lot, just keep reading in order and write little programs as you go along.</p></pre>: <pre><p>[deleted]</p></pre>QThellimist: <pre><p>may not be true for mobile users</p></pre>shmup: <pre><p>True, but it&#39;s still worth letting OP know about the sidebar resources. </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

610 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传