go debug vscode breakpoint debugging

Go directly to the solution:

  • One line command to install delve: go get -u github.com/go-delve/delve/cmd/dlv
    (delve is a debugging tool for go language)
  • Then configure as shown below:

insert image description here

My own launch.json (modify to your own path):

{
    
    
    "version": "0.2.0",
    "configurations": [
        {
    
    
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            //"port": 2345,
            //"host": "127.0.0.1",
            "program": "/home/daji/data/codes/go_programming/src/daji-HelloGo/test.go",
            "env": {
    
    
                "GOPATH":"/home/daji/data/codes/go_programming"
            },
            "args": [],
            "showLog": true
        }
    ]
}

Finally, click on the position shown in the figure below, and you can run it.

insert image description here

Guess you like

Origin blog.csdn.net/weixin_44757863/article/details/121194985