Go IDE使用

1 篇文章 0 订阅

Go IDE

在学习Go语言时,可以使用的IDE或编辑软件包括许多种。有兴趣的同学的可以浏览中文版翻译的<< The way to Go >>。作者试用了liteide、Intellij+Go插件、Eclipse+goclipse插件。安装过程十分简单,网上也有很多教程说了如何安装,这里不再赘述,只是介绍一下使用这些IDE遇到的问题。

哪种IDE使用方便

Go的源码文档(go/doc/debugging_with_gdb.html)里面明确指出,使用Delve进行debug要好于gdb。

Note that Delve is a better alternative to GDB when debugging Go programs built with the standard toolchain. It understands the Go runtime, data structures, and expressions better than GDB. Delve currently supports Linux, OSX, and Windows on amd64. For the most up-to-date list of supported platforms, please see the Delve documentation.

GDB does not understand Go programs well. The stack management, threading, and runtime contain aspects that differ enough from the execution model GDB expects that they can confuse the debugger and cause incorrect results even when the program is compiled with gccgo. As a consequence, although GDB can be useful in some situations (e.g., debugging Cgo code, or debugging the runtime itself), it is not a reliable debugger for Go programs, particularly heavily concurrent ones. Moreover, it is not a priority for the Go project to address these issues, which are difficult.

推荐liteide或intellij,安装方便,这两者都支持delve debug模式。liteide的界面比较挫,不过启动快,简单。intellij就不用说了,功能强大,但是启动、运行感觉慢。intellij安装完Go插件后,进行debug会出问题:

could not launch process: decoding dwarf section info at offset 0x0: too short

  • 解决方案1

作者是通过将liteide安装目录下的dlv.exe替换intellij自己的dlv.exe解决了这个问题。不清楚dlv.exe位置的同学可以使用intellij debug时,查看控制台输出,输出面板的最上面是执行的指令,就可以找到dlv.exe的位置。

D:\go1.11.9.windows-amd64\go\bin\go.exe build -o C:\xxx\Temp\___go_build_main_go.exe -gcflags "all=-N -l" . #gosetup "D:\JetBrains\IntelliJ IDEA 2017.3.3\bin\runnerw.exe" C:\xx\.IntelliJIdea2017.3\config\plugins\intellij-go\lib\dlv\windows\dlv.exe --listen=localhost:52151 --headless=true --api-version=2 --backend=default exec C:\xx\Temp\___go_build_main_go.exe -- #gosetup

  • 解决方案2

idea.properties中添加dlv位置配置:

 dlv.path=D:\\\\liteide\\bin\\dlv.exe

为什么不推荐eclipse

goclipse插件目前只支持gdb。目前有人open了一个关于支持delve的issue,未来goclipse可能可以支持delve。作者的体验是不推荐goclipse,因为可以直接运行成功,但是使用gdb进行debug时报错:生成的可执行文件不是正确文件格式。可能是因为go编译工具与目前goclipse版本提供的gdb不一致,需要另外下载gdb。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值