1
0
mirror of https://github.com/golang/go synced 2024-11-21 15:44:44 -07:00

go/build: handle and warn of duplicate GOPATH entries

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/5519050
This commit is contained in:
Andrew Gerrand 2012-01-09 14:24:05 +11:00
parent 7478bb981a
commit c7e91724c0

View File

@ -157,6 +157,7 @@ func init() {
Path = []*Tree{t}
}
Loop:
for _, p := range filepath.SplitList(os.Getenv("GOPATH")) {
if p == "" {
continue
@ -166,6 +167,21 @@ func init() {
log.Printf("invalid GOPATH %q: %v", p, err)
continue
}
// Check for dupes.
// TODO(alexbrainman): make this correct under windows (case insensitive).
for _, t2 := range Path {
if t2.Path != t.Path {
continue
}
if t2.Goroot {
log.Printf("GOPATH is the same as GOROOT: %q", t.Path)
} else {
log.Printf("duplicate GOPATH entry: %q", t.Path)
}
continue Loop
}
Path = append(Path, t)
gcImportArgs = append(gcImportArgs, "-I", t.PkgDir())
ldImportArgs = append(ldImportArgs, "-L", t.PkgDir())