Visual Studio代码调试代码不使用Golang匹配Gopath



使用Golang调试器的Visual Studio代码不匹配Gopath Path代码?

我使用Visual Studio Code IDE构建UP Golang环境 Mac OS ,然后安装必要的工具:

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

我曾经设置过我的GO路径/Users/friends/gopath,不久之后,我更改了Gopath /Users/friends/Document/share/gopath。我更改了gopath 〜/.bash_profile Visual Studio Code设置 about

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,是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"
    }

我也遇到了今天运行的问题,这是必要的:

  1. 获得自我delve(https://github.com/derekparker/delve)

    a)如果您愿意构建并安装它,请克隆仓库

    〜/go/src/github.com/derekparker/delve

然后运行:

go install github.com/derekparker/delve/cmd/dlv

由于最新的MacOS安全更新,您还需要对其进行编码:

codesign -s dlv-cert $(which dlv)

或b)尝试酿造

  1. 在启动中添加启动配置。JSON,我的工作如下:

"配置":[ { "名称":"启动软件包", " type":" go", "请求":"启动", "模式":"调试", " program":" $ {workspaceroot}/myapppackagepath/", " cwd":" $ {workspaceroot}", " args":[" option1"," option2"," ..."],, " Showlog":true } ]

最新更新