GetStream / vg

Virtualgo: Easy and powerful workspace based development for go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breaks when initial GOPATH is empty

matthijskooijman opened this issue · comments

When I activate a workspace using vg while my GOPATH is empty, the new GOPATH ends in a colon, followed by the original empty GOPATH, which confuses go:

matthijs@grubby:/$ cd /path/to/bar/
Activating bar
Uninstalling "github.com/foo/bar" from workspace
  Unmounting bindfs mount at "/home/matthijs/.virtualgo/bar/src/github.com/foo/bar"
  Removing sources at "/home/matthijs/.virtualgo/bar/src/github.com/foo/bar"
  Removing "github.com/foo/bar" from locally installed packages
Installing local sources at "." in workspace as "github.com/foo/bar" using bindfs
(bar) matthijs@grubby:/path/to/bar$ echo $GOPATH
/home/matthijs/.virtualgo/bar:
(bar) matthijs@grubby:/path/to/bar$ go build
go: GOPATH entry is relative; must be absolute path: "".
For more details see: 'go help gopath'

I realize that using a fully-isolated workspace would work here, but would it perhaps make sense to just ignore the previous GOPATH if it is empty?

Nice find! I think it should actually use $HOME/go in that case. Since recent go versions use that as the default GOPATH when it's not set

Ah, good point. It feels a bit fragile to hardcode that in vg, though, but I don't suppose go can tell you the default path to use... Perhaps showing a message about this makes sense to make it explicit?