Golang Design Patterns

xuanbao · · 986 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Any good writeups/code/presentations/etc. for software design patterns in Go? </p> <hr/>**评论:**<br/><br/>dericofilho: <pre><p><a href="https://groups.google.com/d/msg/golang-nuts/3fOIZ1VLn1o/GeE1z5qUA6YJ">https://groups.google.com/d/msg/golang-nuts/3fOIZ1VLn1o/GeE1z5qUA6YJ</a></p> <p>By Commander Pike, on Design Patterns book of GOF:</p> <blockquote> <p>As has been said, that book is about solving certain classic problems in Java, a language with a particular, restrictive programming model and type system. Go isn&#39;t much like Java.</p> <p>A concrete example: The Visitor Pattern.</p> <p>This is a clever, subtle pattern that uses subtype inheritance to implement a type switch.</p> <p>Go has type switches, and therefore no need for the Visitor Pattern. I leave the Singleton Pattern as an exercise.</p> <p>So you&#39;re right, it is educational to try to implement those problems in Go, but for the most part those <em>patterns</em> don&#39;t really apply. Java code doesn&#39;t work well in Go, nor Go in Java.</p> </blockquote> <p>-rob</p></pre>MoneyWorthington: <pre><p>The first place to check would be the <a href="https://blog.golang.org/index">official blog</a>. The topics there vary wildly, but a few of them are useful write-ups of things like <a href="https://blog.golang.org/context">context</a> and <a href="https://blog.golang.org/errors-are-values">error handling</a>.</p></pre>jgautheron: <pre><p>Take a look at this talk from the last GopherCon: <a href="https://www.youtube.com/watch?v=xyDkyFjzFVc">Tomas Senart - Embrace the Interface</a>.<br/> The speaker approaches a few patterns/principles, worth watching!</p></pre>varun06: <pre><p><a href="http://manuel.kiessling.net/2012/09/28/applying-the-clean-architecture-to-go-applications/">http://manuel.kiessling.net/2012/09/28/applying-the-clean-architecture-to-go-applications/</a></p> <p>Not sure if you are looking for something like this, but it is a good write up nonetheless. </p></pre>sindbis: <pre><p>Awesome resource! </p></pre>kortemy: <pre><p>Truth be told, implementing design patterns (and I am mostly talking about GOF design patterns) in Go like in any other OO language is redundant and unnecessary overhead.</p> <p>Given the nature of Go, as in not being fully object oriented, not supporting inheritance and being more functional than OO - there is no real need for design patterns. Simple function composition will solve you most of the problems design patterns try to fix.</p> <p>In Go world, people like to use word &#34;idiom&#34;, which is something between a &#34;pattern&#34; and a &#34;good practice&#34;.</p> <p>If you are looking for a solutions that mimics specific design pattern - ask away, and I&#39;m sure a lot of people will help you out. :)</p></pre>sindbis: <pre><p>Thanks! This is what I was looking for!</p></pre>klaaax: <pre><p>here , 5 seconds of search on google : </p> <p><a href="https://www.google.com/search?q=go+concurreny+pattern" rel="nofollow">https://www.google.com/search?q=go+concurreny+pattern</a></p></pre>paukul: <pre><p>Exactly. Why ask people in a forum, dedicated to the problem domain, about their opinion and advise when you can ask a search engine instead. Good job mate!</p></pre>

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

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