bradleyfalzon / apicompat

apicompat checks recent changes to a Go project for backwards incompatible changes
https://abicheck.bradleyf.id.au
MIT License
179 stars 5 forks source link

Handle GOPATH that are lists #29

Open ghost opened 7 years ago

bradleyfalzon commented 7 years ago
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     }
dmitshur commented 7 years ago

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

bradleyfalzon commented 7 years ago

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

TODO test various forms of GOPATH with list.