How can I setup vscode for Go project built with bazel?


I am trying to browse code for gVisor with VScode.

However, unlike other Go projects, gVisor is built with bazel, and the source code is not located under $GOROOT or $GOPATH. Maybe this prevents gVisor packages from being searched by VSCode go extension. Go-to-definition is not working in most cases, except for cases where the definition can be found under the same directory.

How can I setup VSCode with bazel Go projects? Especially gVisor. Thanks!


gVisor recently added a gopath BUILD rule that creates a canonical GOPATH tree from the source.

You may be able to use that the edit more effectively from VScode.

Answered By – prattmic

Answer Checked By – David Marino (GoLangFix Volunteer)

Leave a Reply

Your email address will not be published.