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