apicompat
apicompat copied to clipboard
Handle GOPATH that are lists
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 }
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
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.
TODO test various forms of GOPATH with list.