This project shows how to use rules_go_dep to set up a development enviromnent.
It is assumed that dep, bazel and vscode are already installed.
Currently the setup requires a custom build of the vscode-go extension, which can be installed with the following commands:
wget https://github.com/scele/vscode-go/releases/download/0.6.72-lpeltonen.2/Go-0.6.72-lpeltonen.2.vsix
code --install-extension ./Go-0.6.72-lpeltonen.2.vsix
rm ./Go-0.6.72-lpeltonen.2.vsixThe project setup points vscode-go to a fake GOPATH constructed into the bazel build area. To prevent vscode-go from installing its dependency tools there, you should set go.toolsGopath in your vscode user settings to point somewhere else (e.g. to your normal GOPATH).
- Install delve (you may need to apply this workaround if the installation fails)
go get -u github.com/scele/go-dep-bazel-vscode-example
cd $GOPATH/src/github.com/scele/go-dep-bazel-vscode-exampleNOTE: The build does not require the source to be under
$GOPATH, butdep ensuredoes.
bazel build //...
bazel run //cmd/examplecode -n .In vscode, open cmd/example/main.go, set a breakpoint, and hit F5 to start debugging.
Starting debugging will automatically invoke bazel build.
To build the app without launching debugger, you can hit Ctrl+Shift+B (⇧⌘B on macOS).
dep ensure
rm -rf ./vendorThe vendor directory should be manually deleted, since the dependencies will be pulled through bazel.
bazel run //:gazelle

