functional lib for Go

xuanbao · · 1018 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Anyone recommend something like underscore or lodash for Go?</p> <hr/>**评论:**<br/><br/>garfj: <pre><p>Take a look at <a href="https://github.com/go-goast/goast">goast</a> in conjunction with the <a href="https://github.com/go-goast/iter">iter</a> package. </p></pre>davecheney: <pre><p><a href="http://tobyhede.github.io/underscore.go/">underscore.go</a></p></pre>tarrsalah: <pre><p>A quote from <a href="https://github.com/robpike/filter">https://github.com/robpike/filter</a> Rob Pike</p> <blockquote> <p>Having written it a couple of years ago, I haven&#39;t had occasion to use it once. Instead, I just use &#34;for&#34; loops.</p> <p>You shouldn&#39;t use it either.</p> </blockquote></pre>YEPHENAS: <pre><p>Don&#39;t do that. It&#39;s not idiomatic.</p></pre>SingularityNow: <pre><p>What exactly isn&#39;t idiomatic? Having a collection of common slice operations? </p></pre>icholy: <pre><p>When that involves unsafe code that relies on reflection ... yes.</p></pre>SingularityNow: <pre><p>Who was talking about unsafe or code or reflection?</p></pre>icholy: <pre><p>True, i was referring to implementations like underscore.go </p></pre>SingularityNow: <pre><p>Right, I figured. No worries.</p> <p>Given the recent push of <code>go generate</code> I&#39;m just starting to think code generation idea&#39;s should gain some traction. Seems like there&#39;s probably a way to do all that and keep type safety and skip reflection altogether.</p> <ul> <li><a href="http://clipperhouse.github.io/gen/" rel="nofollow">http://clipperhouse.github.io/gen/</a></li> <li><a href="https://github.com/go-goast/goast" rel="nofollow">https://github.com/go-goast/goast</a></li> <li><a href="https://github.com/droundy/gotgo" rel="nofollow">https://github.com/droundy/gotgo</a></li> </ul></pre>klaaax: <pre><p>I&#39;d argue it doesn&#39;t matter if it compiles and runs.</p> <p>I&#39;ve seen a lot of so called &#34;non idiomatic Go&#34; inside the go core library itself, to dodge Go language limitations,interface{} everywhere , heavy reflection,... if the Go team itself does it then it&#39;s idiomatic.</p></pre>xsolarwindx: <pre><p>There&#39;s a difference between idiomatic and reflection. This library is not idiomatic. There&#39;s a clearly defined idiomatic way to do what this library is doing, and that&#39;s by using loops. </p></pre>klaaax: <pre><p>I don&#39;t see what the problem is, somewhere in the code a for loop is used to iterate over an array. Are you saying it isn&#39;t idiomatic to wrap for loops into functions in go in order to write clean code without unnecessary noise?</p></pre>YEPHENAS: <pre><blockquote> <p>isn&#39;t idiomatic to wrap for loops into functions in go in order to write clean code without unnecessary noise?</p> </blockquote> <p>It&#39;s definitely not idiomatic Go to perform micro-DRY on control structures.</p></pre>SingularityNow: <pre><p>The &#39;zip&#39; pattern is a control structure now? </p></pre>ijustwantaredditacct: <pre><p><a href="http://golang.org/pkg/container/ring/#Ring.Do" rel="nofollow">abstracting</a> <a href="http://golang.org/src/go/ast/walk.go?s=6267:6309#L374" rel="nofollow">traversal</a> is totally non idiomatic.</p></pre>

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

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