前言
最近在学习golang, 在IDEA里配置了golang的开发环境,点运行没有问题,点debug,发现报错:
Version of Delve is too old for this version of Go (maximum supported version 1.13, suppress this error with --check-go-version=false)
记录下解决方案,给有需要的人。
解决
方案1
Delve版本太老,说明delve存在,但是版本和当前的golang版本不匹配,那就更新下delve:
$goget-ugithub.com/go-delve/delve/cmd/dlv
但本地实测之后,报如下错误:
(代理已经设置为阿里云的地址:GOPROXY=https://mirrors.aliyun.com/goproxy/,direct)
goget:upgradinggolang.org/x/sys@v0.0.0-20200930185726-fdedc70b468f:unrecognizedimportpath"golang.org/x/sys":httpsfetch:Get"https://golang.org/x/sys?go-get=1":dialtcp216.239.37.1:443:connectex:Aconnectionattemptfailedbecausetheconnectedpartydidnotproperlyrespondafteraperiodoftime,orestablishedconnectionfailedbecauseconnectedhosthasfailedtorespond.
先不去探究为什么会报上面的错误吧。其实,这个方案的本质就是升级一下delve版本,让其与golang版本(本地是1.15)相匹配不就得了。所以变通下,直接去github上下载一个吧。
方案2
找到delve的github仓库
把仓库克隆到本地:git clone https://github.com/go-delve/delve.git
进入到cmd/dlv目录,运行go build, 会生成一个dlv.exe文件
将dlv.exe放到$GOPATH中,比如这里是:D:/go/bin/dlv.exe
打开IDEA -> help -> Edit Custom Properties, 输入 dlv.path=D:/go/bin/dlv.exe
重启IDEA即可