Debug Go program with derekparker/delve

Install the delve debugging tool

  1. byGo getDownload source
go get -u
  1. Install the dlv-cert certificate

inDerekparker/delve/scripts 下有 script, execute it to generate a certificate. A user password is required. It can be seen in the Keychain after it is generated.

  1. Update xcode command-line
xcode-select --install

However, the debug api of the upgraded CommandLineTools has changed, and currently it is not compatible with the current delve.

  1. Installation dlv

Solve the problem with command-line above. In the delve directory:Execute the following command in $GOPATH/src/ 中执行下面的命令:

git remote add aarzilli [email protected]:aarzilli/delve.gitgit pull aarzilli debugserverfixGO15VENDOREXPERIMENT=1 CERT=dlv-cert make install

ExecutedYou can see dlv in $GOPATH/bin.

Debugging with VSCode

Start by searching for the Go plugin in the vscode store.

Generate launch.json configuration

{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "mode": "debug", " remotePath": "", "port": 2345, "host": "", "program": "${fileDirname}", "env": { "GOPATH": "/Users/x/golang" // Modify GOPATH path}, "args": [], "showLog": true } ]}

After configuring the click button, you can run the debugging directly.

Debugging with Goland

Mainly need to replace the dlv in Goland and replace it withDlv in $GOPATH/bin.

Running the debug in Goland will report an error, mainly because of the dlv installation.

could not launch process: EOF