1.碰见如下报错,调试器没有打印变量信息
Delve is too old for Go version 1.21.2 (maximum supported version 1.19)
2. 解决办法
升级delve
delve是go语言的debug工具。
go install github.com/go-delve/delve/cmd/dlv@latest
报错 Get
“https://proxy.golang.org/github.com/go-delve/delve/cmd/dlv/@v/list”:
dial tcp 142.251.42.241:443: connectex: A connection attempt failed
because the connected party did not properly respond after a period of
time, …说明proxy.golang.org网址被防火墙屏蔽了(ping
proxy.golang.org会显示超时),可以将该网址替换成goproxy.cn,即执行如下命令:go env –w GOPROXY=goproxy.cn
然后再次执行上述”go install …”命令,
步骤完成之后,在GOPATH\bin目录下会有一个dlv.exe,在goland>help>Edit Custom
Properties中增加一行(换成这个新的dlv.exe):dlv.path=你的gopath路径\dlv.exe(新的dlv.exe路径)
如: dlv.path=C:/Users/liuxiaoxiang/go/bin/dlv.exe
记住粘贴 Windows 路径 后斜杠替换成 “/”
重启goland编辑器