import (
"errors"
"fmt"
- "log"
"os"
"path/filepath"
"runtime"
return false
}
return !fi.IsDir()
- // TODO(adg): check object version is consistent
}
var (
func init() {
root := runtime.GOROOT()
t, err := newTree(root)
- if err != nil {
- log.Printf("invalid GOROOT %q: %v", root, err)
- } else {
+ if err == nil {
t.Goroot = true
Path = []*Tree{t}
}
-Loop:
for _, p := range filepath.SplitList(os.Getenv("GOPATH")) {
if p == "" {
continue
}
t, err := newTree(p)
if err != nil {
- 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())