Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for multiple $GOPATH:s #33

Closed
mewmew opened this issue Mar 24, 2017 · 7 comments
Closed

Add support for multiple $GOPATH:s #33

mewmew opened this issue Mar 24, 2017 · 7 comments

Comments

@mewmew
Copy link

mewmew commented Mar 24, 2017

I tried to use goggles today, and it does look great. However, upon doing so, it seems it encountered an error when trying to parse my $GOPATH, which is a list of GOPATH:s.

u@x220 ~> echo $GOPATH
/home/u/goget:/home/u/Desktop/go

When GOPATH is set to a list, goggles fails with the following error:

No packages found, does your $GOPATH look right?

Here are a couple of references that may be helpful for dealing with multiple $GOPATH:s.

https://golang.org/pkg/path/filepath/#SplitList
https://golang.org/pkg/go/build/#Context.SrcDirs

From mewkiz/pkg/goutil.SrcDir:

// SrcDir tries to locate dir in GOPATH/src/ or GOROOT/src/pkg/ and returns its
// full path. GOPATH may contain a list of paths.
func SrcDir(dir string) (absDir string, err error) {
	for _, srcDir := range build.Default.SrcDirs() {
		absDir = filepath.Join(srcDir, dir)
		finfo, err := os.Stat(absDir)
		if err == nil && finfo.IsDir() {
			return absDir, nil
		}
	}
	return "", errors.Errorf("unable to locate directory (%q) in GOPATH/src/ (%q) or GOROOT/src/pkg/ (%q)", dir, os.Getenv("GOPATH"), os.Getenv("GOROOT"))
}
@KyleBanks
Copy link
Owner

KyleBanks commented Mar 24, 2017

Ah yes, I totally forgot you could even have multiple GOPATHs without switching. This is definitely something Goggles should support.

PS thanks for the detailed issue, awesome!

@KyleBanks
Copy link
Owner

@mewmew thanks for raising this, it's resolved in v0.3.1

@mewmew
Copy link
Author

mewmew commented Mar 24, 2017

@KyleBanks Thanks for the very quick response time!

I tried it out, and it seems to be partially working. Now I can search my list of packages, but eventually, something seems to be searching in only one of the GOPATH:s and goggles exists with the following error:

u@x220 ~> goggles
2017/03/24 13:20:42 $GOPATH=[/home/u/goget /home/u/Desktop/go], srcdir=[/home/u/goget/src /home/u/Desktop/go/src]
2017/03/24 13:21:20 open /home/u/goget/src/github.com/decomp/decomp/cmd/ll2dot: no such file or directory

Note. github.com/decomp/decomp/cmd/ll2dot is indeed present in my GOPATH, however not in /home/u/goget, but rather in /home/u/Desktop/go.

@KyleBanks
Copy link
Owner

@mewmew sorry about that, realized I missed one thing on my TODO list right after posting. The last missing piece is in 1600139 and v0.3.2

@mewmew
Copy link
Author

mewmew commented Mar 24, 2017

I'll try to see if the issue is resolved in rev 1600139.

@mewmew
Copy link
Author

mewmew commented Mar 24, 2017

Now it's working! Thanks for the brilliant response time.

@KyleBanks
Copy link
Owner

Awesome!

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

No branches or pull requests

2 participants