目录

go 开发工具 goland debug 报错解决 no debug info found

背景

golang在开发时,使用开发工具 goland 进行代码 debug ,点击Goland的Debug按钮准备断点调试,结果控制台直接弹出“no debug info found”的报错,原本红色的断点瞬间变成了灰色——这意味着调试器找不到对应的调试信息,根本没法断点。

具体报错信息如下:

Got a connection, launched process /Caches/JetBrains/GoLand2024.1/tmp/GoLand/___2core_server (pid = 40849).

Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.
Warning: no debug info found, some functionality will be missing such as stack traces and variable evaluation.

could not launch process: could not get the Go version for the moduledata extraction: no goversion found

查了官方文档又翻了Stack Overflow,折腾了快1小时才搞定。

后来发现,这个报错看似棘手,实则大多是编译配置、工具链关联或缓存问题导致的。记录分享下这次报错解决方法,希望能够帮助大家踩坑少走弯路…

原因

在解决问题前,得先明白调试信息的本质:Go程序编译时,会生成包含变量、函数、行号等信息的“调试符号表”,Goland的Debug工具就是通过读取这个表来定位断点、查看变量的。

报错“no debug info found”,本质就是编译后的可执行文件里没有调试符号表

解决方法

从网上找了下,和官方的 issues 中发现了问题的解决方法:

no debug info found, some functionality missing such as stack traces and variable evaluation. : GO-17137 (jetbrains.com)

https://github.com/golang/go/issues/61229

只需要配置一下环境配置即可

go env -w CGO_ENABLED='0'

亲测问题可以解决

不知道大家还有遇到在调试过程中还遇到过哪些棘手的问题呢?欢迎大家在评论区评论分享交流!!!

版权声明

未经授权,禁止转载本文章。
如需转载请保留原文链接并注明出处。即视为默认获得授权。
未保留原文链接未注明出处或删除链接将视为侵权,必追究法律责任!

本文原文链接: https://fiveyoboy.com/articles/go-idea-goland-debug-err/

备用原文链接: https://blog.fiveyoboy.com/articles/go-idea-goland-debug-err/