I have installed the Go extension for VS Code, but unable to make it work.
"dlv debug" works alright from the terminal.
dlv debug src/github.com/user/hello
The launch.json
:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}",
"env": {},
"args": []
}
]
}
Do you know how to set it up?
For using Delve debugger in Visual Studio Code with Golang, do the following steps:
GOROOT
andGOPATH
$GOPATH/bin
to your OSPATH
environment variable.GO15VENDOREXPERIMENT = 1
go get github.com/derekparker/delve/cmd/dlv
and make suredlv
binary generated in your$GOPATH/bin
ext install Go
, and press enter.Rich Go language support for Visual Studio Code
Enable
and restart Visual Studio CodeVisual Studio Code
Open Folder Ctrl+Shift+E , e.g.:$GOPATH\src\hello\
hello.go
from that folder (or make new file Ctrl+N and save it on this folder):i := 101
press F9 to set or toggle beakpoint.Go
.My
launch.json
untouched:Result:
FTA (in case it is hard to find), if when using
delve
and you getcannot find package
error even though yourGOPATH
is set correctly, check out this bug of vscode-go, it is affecting both MAC OS and Linux, as of October, 2017.The solution is posted there as well:
Content launch.json for gdb and delve
}