<p>I've been working on getting my feet wet with golang and have been positively impressed while doing a couple of implementations. I've just recently started to work on an IRC server implementation. I think I've come to a point, where the codebase is big enough, but yet still small enough, that someone can can quickly take a grasp at what it's doing and see where I'm headed with that code style and maybe direct me in a different direction if it's not working out.</p>
<p>Enough of the talk, here's the project:
<a href="https://github.com/tehcyx/girc" rel="nofollow">https://github.com/tehcyx/girc</a></p>
<p>Feel free to point out things you'd change and maybe help me out with things like these:</p>
<pre><code>call of append copies lock value: server.Room contains sync.Mutex
</code></pre>
<p>Thanks for your effort!</p>
<hr/>**评论:**<br/><br/>dgryski: <pre><p>For the vet issue, read <a href="https://medium.com/golangspec/detect-locks-passed-by-value-in-go-efb4ac9a3f2b" rel="nofollow">https://medium.com/golangspec/detect-locks-passed-by-value-in-go-efb4ac9a3f2b</a></p></pre>tehcyx: <pre><p>While it tells me, that it's best practice not to do this, it fails to point out a valuable solution for it.</p>
<p>I want copies of these structs, that contain the Mutex, but how would I go ahead and design it in a way, that I don't copy the Mutex? Do I just have global Mutex for this, since the <code>roomList</code> and <code>connectedClientList</code> are supposed to be global anyways?</p>
<p>And while the list itself shouldn't be modifiable, the <code>Room</code> should have a Mutex by itself, so that only one user at a given time can e.g. change the topic. The list of active users in a room doesn't change, while I loop through it, to notify everyone of someone's arrival or departure.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传