gorebuild icon indicating copy to clipboard operation
gorebuild copied to clipboard

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

Open dmitshur opened this issue 9 years ago • 0 comments

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.

dmitshur avatar Jun 13 '16 06:06 dmitshur