$ mkdir -p /xxx/dlv #在go任何包目录外,否则gomod模式会将dlv添加到相关工程依赖里
$ cd /xxx/dlv
$ go get -u github.com/go-delve/delve/cmd/dlv #设置好goproxy.io代理,一般能顺利执行;从网络安装更新指定的包;-v查看进度
go get 失败,则尝试分解动作
$ git clone https://github.com/go-delve/delve.git $GOPATH/src/github.com/go-delve/delve
$ cd $GOPATH/src/github.com/go-delve/delve
$ make install
{
"name": "Connect and launch",
"type": "go",
"debugAdapter": "dlv-dap", // the default
"request": "launch",
"port": 12345,
"host": "127.0.0.1", // can skip for localhost
"mode": "exec", #预编译好debug版然后执行为exec,debug为远程dlv现编debug然后执行
"program": "/absolute/path/to/remote/workspace/program/executable",
"substitutePath": [
{ "from": "${workspaceFolder}", "to": "/path/to/remote/workspace" }, //from 本地源文件目录; to 远程源文件目录
...
]
}
vs 设置断点进行调试
Continue / Pause F5
Step Over (aka next in Delve) F10
Step Into (aka step in Delve) F11
Step Out (aka stepout in Delve) Shift+F11 or ⇧F11
Restart (currently this is "Stop + Start") Ctrl+Shift+F5 or ⇧⌘F5
Stop (terminate the debugee. Available in Launch request) Shift+F5 or ⇧F5