Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

gorebuild will fail in environments where GOPATH includes 2 or more workspaces. #2

Open
dmitshur opened this issue Jun 13, 2016 · 0 comments

Comments

@dmitshur
Copy link

I don't see a mention in the README that gorebuild imposes any limitations on one's Go setup, but I see there's an issue that would prevent it from working when one has 2 or more workspaces.

The GOPATH environment variable is defined as:

The GOPATH environment variable lists places to look for Go code. On Unix, the value is a colon-separated string. On Windows, the value is a semicolon-separated string. On Plan 9, the value is a list.

So this line, for example, would fail to work as expected if one has 2 or more workspaces:

fi, err := ioutil.ReadDir(build.Default.GOPATH + "/bin")

Because the value of build.Default.GOPATH would be something like /path/to/workspace1:/path/to/workspace2.

The correct solution is to use filepath.SplitList to parse GOPATH environment variable and extract all workspaces that are included. Then, you'd want to process them in a way that works.

You can look at binstale for an example of how to work with multiple workspaces.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant