使用golang调试器的visual studio代码与gopath路径代码不匹配?
我使用visual studio代码IDE MAC OS 构建golang环境,然后安装必要的工具:
go get -v -u github.com/peterh/liner github.com/derekparker/delve/cmd/dlv
go get -u -v github.com/nsf/gocode
go get -u -v github.com/rogpeppe/godef
go get -u -v github.com/golang/lint/golint
go get -u -v github.com/lukehoban/go-find-references
go get -u -v github.com/lukehoban/go-outline
go get -u -v sourcegraph.com/sqs/goreturns
go get -u -v golang.org/x/tools/cmd/gorename
go get -u -v github.com/tpng/gopkgs
go get -u -v github.com/newhook/go-symbols
我曾经设置了我的去路/Users/friends/gopath
,不久我改变了我的gopath /Users/friends/Document/share/gopath
。我改变了gopath 〜/ .bash_profile , visual studio代码设置关于
go.gopath": "/Users/friends/Documents/VirtualMachine/share/gopath
当我调试我的代码时,它提示无法找到 /Users/friends/gopath/src/...../apiSGetChainsIds.go
中的文件,实际上该文件存在于/Users/friends/Documents/VirtualMachine/share/gopath/src/..../apiSGetChainsIds.go
中。很显然,调试器找到以前的gopath
,这是golang工具的错误吗?或者我错了什么?
我的用户设置
{
"files.autoSave": "afterDelay",
//"go.buildOnSave": "package",
//"go.lintOnSave": "package",
//"go.vetOnSave": "package",
"go.buildFlags": [],
"go.lintFlags": [],
"go.vetFlags": [],
"go.useCodeSnippetsOnFunctionSuggest": false,
"go.formatOnSave": false,
"go.formatTool": "goreturns",
"editor.fontSize": 14,
"go.goroot": "/usr/local/Cellar/go/1.8.3/libexec",
"go.gopath": "/Users/friends/Documents/VirtualMachine/share/gopath"
}
答案 0 :(得分:1)
我今天也遇到了问题,这就是必要的:
让你自己钻研(https://github.com/derekparker/delve)
要么a)如果您想构建并安装它,请将repo克隆到
〜/去/ SRC / github.com / derekparker /掏空
然后运行:
go install github.com/derekparker/delve/cmd/dlv
由于最新的macOS安全更新,您还需要对其进行代码签名:
codesign -s dlv-cert $(which dlv)
或b)尝试酿造
"配置":[ { " name":" Launch Package", "输入":" go", "请求":"启动", "模式":"调试", " program":" $ {workspaceRoot} / myAppPackagePath /", " cwd":" $ {workspaceRoot}", " args":[" option1"," option2"," ..."], " showLog":是的 } ]