goland debug运行报错问题

报错信息

goland 运行 debug 报错如下

API server listening at: 127.0.0.1:58193
2023-11-22T11:08:07+08:00 error layer=debugger could not patch runtime.mallogc: no type entry found, use 'types' for a list of valid types
WARNING: undefined behavior - version of Delve is too old for Go version 1.21.4 (maximum supported version 1.18)
=== RUN   Test_intersection

Debugger finished with the exit code 0

报错原因

未找到对应 go 版本的 dlv.exe文件

解决方案

cd%GOPATH%/src 目录,执行
go install github.com/go-delve/delve/cmd/dlv

这时候你发现,在 %GOPATH%/bin目录下生产了一个dlv.exe程序
我的是在 D:\code\go\bin 目录下

打开 GolandHelp->Edit Customer Properties,若提示文件不存在,点击创建。然后在新加一行 dlv.path=D:/code/go/bin/dlv.exe 重启就可以了, 注意是 / 不是 \

参考文档

https://www.jianshu.com/p/8b16ba03c938

作者:海马  创建时间:2023-11-22 11:01
最后编辑:海马  更新时间:2024-05-10 15:32