Currying Definition is Very Long

agolangf · · 332 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Is there a more concise/better way to accomplish shared functionality among multiple functions. I am doing some newbie learning, and this is the code I came up with but I can see this getting super long.</p> <p><a href="https://gist.github.com/jamesblack/b793dcf57e658d38284af0ba10219c9f" rel="nofollow">https://gist.github.com/jamesblack/b793dcf57e658d38284af0ba10219c9f</a></p> <p>I am coming from a javascript background, so thats probably influencing my solution.</p> <hr/>**评论:**<br/><br/>mostlywaiting: <pre><p>I would parse the template before starting the server, but your way allows hot swapping templates I guess.</p></pre>weberc2: <pre><p>I don&#39;t know why you were downvoted, this is absolutely correct (although this is not a particularly efficient way to get hot swapping, if that&#39;s what you&#39;re after).</p></pre>xiegeo: <pre><p>It looks fine as is, you need to add server logic that does different actions per page to show how you code is organized, but so far, unless you are looking to use it as a CMS, I don&#39;t see what is getting super long.</p></pre>weberc2: <pre><p>LGTM. As <a href="/u/mostlywaiting" rel="nofollow">/u/mostlywaiting</a> mentioned, it&#39;s probably a good idea to parse the template one time before starting the server rather than on each request. The currying bit looks good though. :+1</p></pre>egonelbre: <pre><p><a href="https://play.golang.org/p/WbCAY0gtix" rel="nofollow">https://play.golang.org/p/WbCAY0gtix</a></p></pre>shovelpost: <pre><p>Yes there is. Please read <a href="https://golang.org/doc/articles/wiki/" rel="nofollow">https://golang.org/doc/articles/wiki/</a>.</p></pre>allhatenocattle: <pre><p>If you want your response to be helpful, please point someone at a specific section that you think answers their question.</p></pre>shovelpost: <pre><p>Yeah it&#39;s a huge article after all...</p> <p>There you go: <a href="https://golang.org/doc/articles/wiki/#tmp_6" rel="nofollow">https://golang.org/doc/articles/wiki/#tmp_6</a></p></pre>

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

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