KyleBanks / goggles

🔭 Goggles is a cross-platform GUI for your $GOPATH!
Apache License 2.0
671 stars 18 forks source link

Add support for multiple $GOPATH:s #33

Closed mewmew closed 7 years ago

mewmew commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

mewmew commented 7 years ago

@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 commented 7 years ago

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

mewmew commented 7 years ago

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

mewmew commented 7 years ago

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

KyleBanks commented 7 years ago

Awesome!