launch.json
{ "name": "Attach", "type": "go", "request": "launch", "mode": "remote", "remotePath": "${workspaceRoot}", "port": 2345, "host": "127.0.0.1", "program": "${workspaceRoot}", "env": {}, "args": [], "showLog": true }
* 注意go build要带上这个标记 -gcflags='-N -l',目的是关闭Go内部作的一些优化,聚合变量和函数内联等优化。json
* 或者直接这样运行dlv --listen=:2345 --headless=true --api-version=2 exec ./demoapi