apicompat icon indicating copy to clipboard operation
apicompat copied to clipboard

Handle GOPATH that are lists

Open ghost opened this issue 9 years ago • 4 comments

ghost avatar Oct 07 '16 01:10 ghost

161     if c.recurse {
162         // Technically this isn't correct, GOPATH could be a list
163         var (
164             dir    = filepath.Join(os.Getenv("GOPATH"), "src")
165             prefix = ""
166         )
167         if c.path == cwd {
168             // could c.path = getwd instead ?
169             if dir, err = os.Getwd(); err != nil {
170                 return nil, err
171             }
172             prefix = "." + string(os.PathSeparator)
173         }
174         paths = append(paths, c.getDirsRecursive(dir, rev, c.path, prefix)...)
175     }

bradleyfalzon avatar Oct 07 '16 02:10 bradleyfalzon

There's a func in the standard library to parse GOPATH variable (and any other env vars that are a list of paths joined by the OS-specific ListSeparator):

https://godoc.org/path/filepath#SplitList

dmitshur avatar Oct 07 '16 06:10 dmitshur

Thanks @shurcooL, I was aware, that comment was meant to result in an issue/TODO, but must have slipped by. I think I can just address it with another loop, but I can't recall why I didn't do that in the first place.

bradleyfalzon avatar Oct 07 '16 07:10 bradleyfalzon

TODO test various forms of GOPATH with list.

bradleyfalzon avatar Oct 07 '16 20:10 bradleyfalzon