From c7e91724c0e1f514982e90d7d08bb2c291a2bc43 Mon Sep 17 00:00:00 2001 From: Andrew Gerrand Date: Mon, 9 Jan 2012 14:24:05 +1100 Subject: [PATCH] go/build: handle and warn of duplicate GOPATH entries R=golang-dev, alex.brainman CC=golang-dev https://golang.org/cl/5519050 --- src/pkg/go/build/path.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/pkg/go/build/path.go b/src/pkg/go/build/path.go index 7a281800c2..bb9b8ca642 100644 --- a/src/pkg/go/build/path.go +++ b/src/pkg/go/build/path.go @@ -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()) -- 2.50.0