<p>Is there a way to go fmt while generating code? I currently have a generator that creates some extra info for database schema abstraction, but it comes out not well formatted. Is there a way to call fmt on a string?</p>
<hr/>**评论:**<br/><br/>giovannibajo: <pre><p>Yes:
<a href="https://golang.org/pkg/go/format/#Source" rel="nofollow">https://golang.org/pkg/go/format/#Source</a></p></pre>drink_with_me_to_day: <pre><p>Thanks!</p></pre>Ploobers: <pre><p>If you want to see an example, <a href="https://github.com/goadesign/goa" rel="nofollow">https://github.com/goadesign/goa</a> is a generated framework that leverages gofmt via goimports.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传