JetBrains GoLand 以debug运行Go程序时出现could not launch process: decoding dwarf section info at offset 0x0: too short报错之保姆级别解决方案
这是一篇写给刚开始学习Go语言而在搭建环境可能遇到问题的小萌新的文,大神请自行绕路哈(0-0)
有天,我把Go运用环境升到最新版1.16后,用以前一直在用的JetBrains GoLand 2017.3.3 x64版本运行了搭建的gin框架项目时,使用debug模式后,启动就出现了这样一条异常信息:could not launch process: decoding dwarf section info at offset 0x0: too short——
奇怪的是,run模式运行就正常,当时我第一感觉是,可能是debug插件有问题。
后来百度一番后,发现这确实是Go版本过新而JetBrains GoLand的debug插件版本过老的原因,原本想试试换新一版JetBrains GoLand,但想了一下,这一个小问题,是否可以更快捷地解决呢?若能快捷解决的话,也比再去找一款破解版的新款JetBrains GoLand安装方便。
网上很多方案,但也不知道哪种有用,在试错了多次后,发现其中一种是真的有用。
故而想把我的操作过程详细记录下来,希望可以帮助其他在使用JetBrains GoLand学习Go出现debug异常的小伙伴。
这一个debug错误,应属于Delve调试插件已经过老原因,无法适配新版的Go运用环境。
那么,Delve工具是什么呢?
开源软件库是这样介绍的:Delve 是一个 Go 语言的调试器,目标是给 Go 提供一个简单和特性齐全的调试工具,并且是容易调用和使用的。
简而言之,当JetBrains GoLand使用debug时,其实就是使用到了Delve的debug命令。
你可以在JetBrains GoLand使用dlv --help,就会出现其具备的命令功能,其中的debug命令就是我们要用到的——
既然如此,若是dlv(Delve 简写)版本过低的原因,那好办,不妨先升级一下div。
一、下载div新版本
执行go get -u github.com/derekparker/delve/cmd/dlv
这时候,可能会出现 RPC failed; curl 28 OpenSSL SSL_read: Connection was reset, errno 10054,这是远程从GitHub上拉去的dlv文件超过本地设置下载文件大小限制的原因,故而把本地git下载限制调大即可,例如:git config --global http.postBuffer 624288000。
再执行上面的go get -u github.com/derekparker/delve/cmd/dlv,就可以正常更新了,执行成功后,进入到你的GOPATH目录下,就可以看到多了一个bin目录,且目录底下有一个dlv.exe文件,即证明新版本Delve 下载完成。
至于GOPATH目录在哪里,其实在下载Go的运行环境时,它会自动在电脑系统环境变量里帮你设置,例如,我的是在——
二、替换JetBrains GoLand编译器的本地div工具路径
设置文件所在路径:Help->Edit Custom Properties
进入到Edit Custom Properties后,设置新div的配置如下:
dlv.path=C:/Users/Administrator/go/bin/dlv
其中,C:/Users/Administrator/go是你的系统环境变量里的%GOPATH%对应路径,我这里用到了绝对路径,不知道直接用dlv.path=%GOPATH%/bin/dlv可否也行,暂时没有进一步尝试,感兴趣的小伙伴可自行验证。
设置完的配置如下:
完成这一步后,需要重启一下JetBrains GoLand,选择路径File->Invalidate Caches /Restart
等待重启完成,就可以打一个断点,试一下debug是否可行了,经验证,已可以正常进行debug运行,接下来就可以愉快地啪~敲Go语言代码了。
- IDEA Denug Go 报 could not launch process: decoding dwarf section info at offset 0x0: too short
- could not attach to pid: decoding dwarf section info at offset 0x0: too short
- 真机上运行项目时,出现Could not launch "FeedMeWorms" failed to get the task for process 3118
- macOS 10.12.1 Idea调试Go程序遇到could not launch process: could not get thread count
- 在Eclipse中运行C++程序出现"Launch failed. Binary not foud"和"Program file not Specified"的问题
- Could not launch "xxx". process launch failed: timed out waiting for app to launch解决方案
- 如何解决 X-code5.0中的iOS7.0SDK运行程序时,出现的以下问题:“Could not find a storyboard named 'Main' in bundle NSBundle”
- 真机调试出现Could not launch "FeedMeWorms" failed to get the task for process 3118
- 解决Jetbrains的开发工具不能运行或调试(run/debug)go/golang程序[Intellj Idea,Webstorm,PyCharm,PhpStrom,Android Studio]
- 在Eclipse中运行C++程序出现"Launch failed. Binary not foud"和"Program file not Specified"的问题
- 导入其它android项目或自己建的android项目运行时出现 Could not found *.apk 终极解决方案
- Mac OS X运行程序出现bad interpreter: operation not permitted的解决方案
- 在真机运行程序的时候提示“Could not launch 'app name'”
- gogland出现could not launch process: exec: "lldb-server": executable file not found in $PATH错误
- 关于在IIS服务器上运行asp.net Web程序出现下面 “Could not load file or assembly。。。”问题的
- java程序运行时出现问题:Could not find the main class: test_jena. Program will exit.
- .py程序运行时,出现operands could not be broadcast together with shape (12,) (11,)错误
- Windows下利用cmd运行程序,出现“warning: no newline at end of file”解决方案
- Mac OS X运行程序出现bad interpreter: operation not permitted的解决方案
- Mac OS X运行程序出现bad interpreter: operation not permitted的解决方案