Which tools are you using to debug your code?

blov · · 1015 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<hr/>**评论:**<br/><br/>scanlonman: <pre><p>log.Println</p></pre>HornedKavu: <pre><p><a href="https://github.com/davecgh/go-spew">https://github.com/davecgh/go-spew</a></p></pre>DualRearWheels: <pre><p>So I&#39;m not the only one.</p></pre>thepciet: <pre><p>Write tests to uncover what you can!</p></pre>Marvelt: <pre><ul> <li><a href="https://github.com/mailgun/godebug">godebug</a></li> <li><a href="https://github.com/derekparker/delve">Delve</a></li> <li><a href="https://golang.org/pkg/log/">Package log</a></li> </ul> <p>Each has it&#39;s own pros and cons.</p></pre>bmurphy1976: <pre><p>To be honest, it&#39;s always a pain to debug code in any language. Your best bet is to structure your software as much as possible into small independent pieces that can be tested (and unit-tested) quickly and easily. Inevitably you are going to have to test the integration of these components, and this is where having a solid logging strategy comes in handy.</p> <p>Debuggers are great in a pinch, however, if you find yourself regularly using a debugger then that is a clear sign your application is due for a serious refactoring.</p> <p>So, what do I use to debug my code? log.Println and solid unit tests, and only on rare and exceptional occasions do I fire up a debugger.</p></pre>ant-ham: <pre><p>I clearly agree with you. It&#39;s hard to debug when you have several different pieces of software not interacting locally</p></pre>dlsniper: <pre><p>fmt or log package. Or Delve (from IntelliJ IDEA) if the code is complex. There are still some issues with Delve but it&#39;s getting there. More support from the Go team for issues that slow/block development of Delve would be nice. </p></pre>inanotherworld: <pre><p>LiteIDE, it has breakpoints, step into, step over, step out, run to line etc etc. Works great.</p></pre>1Gijs: <pre><p>LiteIDE uses gdb which has issues with Go. In my experience gdb is only useful in simple cases where println works just fine as well. For more complex situations it fails.</p></pre>careuno: <pre><p>the best solution I&#39;ve seen is Delve with Visual Studio Code</p></pre>hmny: <pre><p>that was my first thought too but I couldn&#39;t set it up on my Windows</p></pre>dlsniper: <pre><p>Delve doesn&#39;t support Windows yet.</p></pre>mzi_: <pre><p>It sort of does. See issue <a href="https://github.com/derekparker/delve/pull/276" rel="nofollow">276</a>. You have to compile with a GCC toolchain for cgo to work on Windows.</p></pre>jussij: <pre><p>The Delve build page makes no reference to it supporting Windows:</p> <p><a href="https://github.com/derekparker/delve/wiki/Building" rel="nofollow">https://github.com/derekparker/delve/wiki/Building</a></p></pre>mzi_: <pre><p>Did you follow the link I posted? </p></pre>dlsniper: <pre><p>A word of caution. It&#39;s a work in progress PR which, by reading the comments in it, still has open issues and will have them after it&#39;s merged.</p></pre>mzi_: <pre><p>So does Delve for Linux and OSX. It seems like both the maintainer and the author are fine with a merge. It is not a shrink wrap product, so there will of course be rough edges. But more or less the same functionality as for the Linux implementation is available now for Windows. I don&#39;t see why this is voted down.</p></pre>1Gijs: <pre><p>I really like VS Code. Installed Delve as well but I am so used to printf that I did not yet try it.</p></pre>postman_: <pre><p><a href="https://golang.org/doc/gdb" rel="nofollow">Go developers said you don&#39;t need a debugger, please obey:</a></p> <blockquote> <p>Moreover, it is not a priority for the Go project to address these issues, which are difficult.</p> </blockquote></pre>nesigma: <pre><p><a href="https://www.youtube.com/watch?v=VoS7DsT1rdM&amp;feature=youtu.be&amp;t=46m11s">Rob Pike&#39;s answer to the question: &#34;Are there any plans for a debugger?&#34;</a></p> <blockquote> <p>There are plans for a debugger but they are very sketchy.</p> </blockquote></pre>

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

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