GetStream / vg

Virtualgo: Easy and powerful workspace based development for go
MIT License
1.32k stars 45 forks source link

Breaks when initial GOPATH is empty #35

Closed matthijskooijman closed 6 years ago

matthijskooijman commented 6 years ago

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?

JelteF commented 6 years ago

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

matthijskooijman commented 6 years ago

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?