Skip to content
Jonas Chevalier edited this page Mar 20, 2022 · 13 revisions

Using the gb Build Tool

If you're using the gb build tool for Go projects, you may find this layout useful for helping many GOPATH-dependent ecosystem tools work seamlessly in your projects:

# Usage: layout golang
#
# Sets up environment for a Go project using the alternative gb build tool. Also
# works with the official dep package.In addition to project executables on
# PATH, this includes an exclusive, project- local GOPATH which enables many
# tools like gocode and oracle to "just work".
#
# http:https://getgb.io/
# https://golang.github.io/dep/
#

layout_golang() {
  export GOPATH="$PWD/vendor:$PWD"
  PATH_add "$PWD/vendor/bin"
  PATH_add bin
}

Add this to your ~/.config/direnv/direnvrc and then use layout golang in your project .envrcs. With this loaded, the support for many tools like gocode, oracle, godoc, etc. in editor plugins like vim-go and GoSublime will usually "just work". This layout may also be completely applicable if you are using the Go 1.5 "vendor experiment" with the official go tool on your project.

See this pull request for some background discussion.