Vscode commissioning of debug golang

Configuration startup items

  Open the Debug Panel: VSCode-> View -> Debugging

  Adding debug target: Click the Add Configuration

  Adding target debug configuration

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "remotePath": "",
            "port": 2345,
            "host": "127.0.0.1",
            "program": "${fileDirname}",
            "env": {
                "GOPATH":"D:/Develop/vscodegolang"
            },
            "args": [],
            "showLog": true
        }
    ]
}

    Where the "post", "host" is go plugin automatically generated, "env" to set environment variables, set the project directory contains the bin, src folder

Preparing to Debug plug-in

  Select to debug main.go, click F5 will report the error message: Failded to continue: "Can not find Delve debugger Install from https://github.com/derekparker/delve & ensure it is in your." GOPATH / bin "or "PATH"

  Use command to compile debugger: go get github.com/derekparker/delve/cmd/dlv will dlv debugger placed in the bin directory of GOPATH

Start Debugging

  Select to debug main.go, click F5 to start debugging

  Debugging keyboard shortcuts:

      F9 Toggle Breakpoint

      F10 Step over

      F11 Step in

      Shift+F11 Step out

  Note: Some members of the legal structure of the display directly, you can directly select the variable name, adding to monitor, or right-click on the "Debug: evaluation"

Multi-project commissioning

  May be added in multiple launch.json Debugging inlet, corresponding to the selected configuration debug panel is open by a different target debugging

May be added in multiple launch.json Debugging inlet, the configuration selected by the corresponding debug the debug panel is open for different targets 

{ 
    "Version": "0.2.0", 
    "Configurations": [ 
        { 
            "name": "Client", 
            "of the type": "Go", 
            "Request": "Launch", 
            "the MODE": "Debug", 
            "remotePath": "", 
            "Port": 2345, 
            "Host": "127.0.0.1", 
            "Program" : "fileDirname $ {}", 
            "the env": { 
                "GOPATH": "D: / Develop / vscodegolang" 
            },
            "args": [],
            "showLog": true
        },

        {
            "name": "server",
            "type": "go",
            "Request": "Launch", 
            "MODE": "Debug", 
            "the remotePath": "", 
            "Port": 2345, 
            "Host": "127.0.0.1", 
            "Program": "$ {workspaceRoot} / the src / Server ", 
            " the env ": { 
                " GOPATH ":" D: / Develop / vscodegolang " 
            }, 
            " args ": [], 
            " showlog ": to true 
        } 
    ] 
} 
" Program "in" $ {fileDirname} "is to the currently selected file as the starting point 

more is recommended to use "program" of "$ {workspaceRoot}", to the package name as a starting point the way to configure

  

Guess you like

Origin www.cnblogs.com/parallel-Y/p/11577430.html