如何为使用bazel构建的Go项目设置vscode?

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.