Skip to content

scele/go-dep-bazel-vscode-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Example setup for go + dep + bazel + vscode

This project shows how to use rules_go_dep to set up a development enviromnent.

Prerequisites

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.vsix

The 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).

MacOS

Clone this example project

go get -u github.com/scele/go-dep-bazel-vscode-example
cd $GOPATH/src/github.com/scele/go-dep-bazel-vscode-example

NOTE: The build does not require the source to be under $GOPATH, but dep ensure does.

Build and run with bazel

bazel build //...
bazel run //cmd/example

Use vscode to debug

code -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).

Update go dependencies

dep ensure
rm -rf ./vendor

The vendor directory should be manually deleted, since the dependencies will be pulled through bazel.

Update BUILD files

bazel run //:gazelle

About

Example setup for go + dep + bazel + vscode

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published