I created an API wrapper library. How can I DRY some of the logic?

xuanbao · · 504 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p><a href="https://github.com/gmccue/go-ilab-childlabor">https://github.com/gmccue/go-ilab-childlabor</a></p> <p>I&#39;m still learning how to properly use interfaces in Golang, and how to deal with JSON data. How can I improve this code? I felt like I was doing a lot of copy/pasting while developing this.</p> <hr/>**评论:**<br/><br/>touristtam: <pre><p>I would be interested as well to see the code refactored. And a write up on the changes. :)</p></pre>marshauf: <pre><p>At a quick glance it seems overengineered. Just a function for each endpoint with the key as an argument and result, error as return values would be enough.</p></pre>gmccue: <pre><p>Yeah, you&#39;re right about the over-engineering. Since this was partly a learning exercise I took that route on purpose. But simplifying would improve readability.</p></pre>TheMerovius: <pre><p><a href="https://godoc.org/github.com/gmccue/go-ilab-childlabor" rel="nofollow">You really should export your type at least</a></p></pre>gmccue: <pre><p>Yep, this is true. Thanks for the tip :)</p></pre>

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

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