<p>I'm coming from NodeJS web development using the Express framework. I want to try Go to learn more in depth about building things from scratch instead of npm installing everything. So using Go I've built a <a href="https://github.com/xDinomode/Go-Webapp-Example" rel="nofollow">static site generator</a> thing because I'm really into Jekyll atm. The other day I attempted to add websockets to it first using Go's net/websocket package which worked but didn't broadcast the messages to all clients. Then I tried gorilla/websocket but couldn't find easy to follow tutorials.</p>
<p>I simply want to broadcast a message to all users connected via web sockets. Is no one using Go for web development?</p>
<hr/>**评论:**<br/><br/>letsencrypt: <pre><blockquote>
<p>[...] but couldn't find easy to follow tutorials.</p>
</blockquote>
<p>That's the problem, you are probably trying to implement something that you barely understand. Here is the <a href="https://godoc.org/golang.org/x/net/websocket" rel="nofollow">official documentation</a> for the <em>"websocket"</em> package and there are <a href="https://github.com/golang-samples/websocket" rel="nofollow">enough examples</a> to get started with it. I doubt you will find a step-by-step tutorial explaining what every keyword does in the code, just read the documentation because that is what it is for.</p>
<p><strong>EDIT:</strong> I believe people coming from a JavaScript background, and specially from the Node.JS community tend to get things for granted, just install this bunch of random packages in my project and make some function calls and I'm done, right? I would expect people to learn the basics of every concept they want to implement in their projects before they start doing something with it, this is not like learning how to drive where you don't need to know how an engine works. In this specific case not knowing what is a web socket and/or not having an understanding of how it works will surely affect the final product.</p></pre>qxclpxzk: <pre><p><a href="https://gary.burd.info/go-websocket-chat/" rel="nofollow">Here's an example of a gorilla/websocket chat application.</a></p></pre>weberc2: <pre><blockquote>
<p>Why are there hardly any tutorials on web development for Go?</p>
</blockquote>
<p>My speculative answer to this question is that newcomers to the Node community are largely front end developers who've not done much backend stuff at all whereas newcomers to Go have prior backend experience, so tutorials are not as necessary.</p>
<p>I've also heard people from Python and other dynamic languages complain about Go's poor documentation. As a Python developer by day, I have a much tougher time locating documentation for Python than for Go, and I suspect it's because 1) all Go documentation is at Godoc.org in a consistent, readable format and 2) because Go is statically typed, there is less reason to rely on complex examples--simple examples plus the typed function signatures are usually enough to intuit how the pieces fit together. If you rely on complex examples and tutorials, you might find Go's documentation culture lacking, but this has not been my problem.</p>
<p>If you have specific questions, please ask them here. Most folks are happy to be helpful; a few of us can be a bit condescending, but don't let them stop you from learning. :)</p></pre>interactiv_: <pre><blockquote>
<p>My speculative answer to this question is that newcomers to the Node community are largely front end developers who've not done much backend stuff at all whereas newcomers to Go have prior backend experience, so tutorials are not as necessary.</p>
</blockquote>
<p>No the truth is that the Go community is smaller than Nodejs. You'd have the same problem with Rust or D. Furthermore people in Go community often conflate API doc and Documentation. In NodeJs world it is mandatory to write a documentation for a package or people won't use it. In Go community people don't bother writing documentation and rely on godoc.org to document their lib, which is often not a proper way to document a library for a third party. So smaller community and less interest in writing proper documentation.</p></pre>shovelpost: <pre><p><code>web_sockets != web_development</code></p></pre>DarkRye: <pre><p>The official <a href="https://golang.org/doc/articles/wiki/" rel="nofollow">backend example</a> is actually quite a good tutorial. It assumes knowledge of HTTP protocol, which you shall know by the time you doing backend.</p>
<p>I went through it when I wanted to know how HTML shall be done with Go.</p></pre>caseynashvegas: <pre><p>I agree we could benefit from more examples in documentation, but at least we don't suffer from the opposite problem, which is to show tons of shallow examples but no thorough documentation on what methods, parameters, overloads and data structures are available in a package. I used to think the .Net platform got this right, but with the newer stuff it seems harder and harder to find anything but shallow examples. </p></pre>Martinjn: <pre><p>Maybe it has to do with the fact that using Go in your company might be a competitive advantage over your competitors.</p>
<p>So why teach to your competitors?</p></pre>DarkRye: <pre><p>There is certainly a competitive advantage to GO.</p></pre>interactiv_: <pre><p>Right, why release Go as an open source project ? /s Google might loose its competitive advantage /s</p>
<p>You don't understand anything about Open source do you ? </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传