关于golang的debug

guozw · · 2874 次点击 · · 开始浏览    
这是一个创建于 的文章,其中的信息可能已经有所发展或是发生改变。

 Debuggers

Application programming needs good debugging support, and in this area still a lot of work needs to be done. A debugger (Oogle): support for gdb (at least version 7 is needed), the GNU debugger is being built in Go’s gc linker (6l, 8l) by the Go-team from Google (not for Windows and ARM-platforms) (see also http://blog.golang.org/2010/11/debugging)

Support for gdb version 7.1 is build in in LiteIDE and Goclipse.

If you don’t want to use a debugger, the following is useful in a simple debugging strategy:

1) use print-statements (with print / println and the fmt.Print functions) at well chosen places 2) in fmt.Printf functions use the following specifiers to obtain complete info about variables: %+v gives us a complete output of the instance with its fields %#v gives us a complete output of the instance with its fields and qualified type name %T gives us the complete type specification

The Way to Go

35

3) use a panic-statement (see § 13.2) to obtain a stack trace (a list of all the called functions up until that moment) 4) use the defer keyword in tracing code execution (see § 6.4). 



有疑问加站长微信联系(非本文作者)

本文来自:开源中国博客

感谢作者:guozw

查看原文:关于golang的debug

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

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