Generate idiomatic go sql code with xo

polaris · · 382 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Hey, I&#39;ve recently found this library <a href="https://github.com/knq/xo">https://github.com/knq/xo</a> that generates idiomatic go code for sql dbs.</p> <p>From what I see, it generated exactly what&#39;s needed, no more, no less. I&#39;m wondering if anyone is actually using this in production or if I should go raw sql. That&#39;s a good option to get consistent db code with minimum effort though</p> <hr/>**评论:**<br/><br/>shovelpost: <pre><p>Looks like a great library. Makes me wonder how it compares to <a href="https://github.com/volatiletech/sqlboiler" rel="nofollow">sqlboiler</a>.</p></pre>natefinch: <pre><p>My problem with sqlboiler is twofold... one, I hate fluent APIs. Two, it doesn&#39;t give you any assurances that the code you&#39;re writing will actually work....</p> <pre><code>Where(&#34;age &gt; ?&#34;, 30) </code></pre> <p><sup>^</sup> This is terrible. What if you change the name of the age column? You won&#39;t know unless you have tests running against the database. And then you have to manually go find all the places you used the old name and change them to a new name. </p> <p>It&#39;s spewing magic strings all over your codebase. Just say no.</p></pre>shark1337: <pre><p>Wow. This one looks good too!</p></pre>iroflmaowtf: <pre><p>seeing postgres being the star, I must applaud the library</p></pre>natefinch: <pre><p>We&#39;re using it at Mattel with extremely customized templates. I really love code generation, so it works well for me.</p> <p>That being said, I&#39;m also working on my own replacement for it that does things a little differently.</p></pre>brilliantdick: <pre><p><a href="https://github.com/doug-martin/goqu" rel="nofollow">https://github.com/doug-martin/goqu</a> has served me well on multiple go projects when connecting to pg. </p></pre>

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

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