diff options
author | Ondřej Surý <ondrej@sury.org> | 2011-10-06 09:35:45 +0200 |
---|---|---|
committer | Ondřej Surý <ondrej@sury.org> | 2011-10-06 09:35:45 +0200 |
commit | 6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a (patch) | |
tree | fddeb87db026d64a1d8e597dd0c69d685f433597 /src/cmd/goinstall/main.go | |
parent | 04f99b387021a8ce32a8795360cba9beaf986a81 (diff) | |
download | golang-6c7ca6e4d4e26e4c8cbe0d183966011b3b088a0a.tar.gz |
Imported Upstream version 2011.09.21upstream-weekly/2011.09.21
Diffstat (limited to 'src/cmd/goinstall/main.go')
-rw-r--r-- | src/cmd/goinstall/main.go | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/cmd/goinstall/main.go b/src/cmd/goinstall/main.go index 23b26e383..478266357 100644 --- a/src/cmd/goinstall/main.go +++ b/src/cmd/goinstall/main.go @@ -13,7 +13,7 @@ import ( "go/token" "io/ioutil" "os" - "path/filepath" + "path/filepath" // use for file system paths "regexp" "runtime" "strings" @@ -190,7 +190,7 @@ func install(pkg, parent string) { }() // Don't allow trailing '/' - if _, f := filepath.Split(pkg); f == "" { + if strings.HasSuffix(pkg, "/") { errorf("%s should not have trailing '/'\n", pkg) return } @@ -225,16 +225,17 @@ func install(pkg, parent string) { terrorf(tree, "%s: %v\n", pkg, err) return } - dir := filepath.Join(tree.SrcDir(), pkg) + dir := filepath.Join(tree.SrcDir(), filepath.FromSlash(pkg)) // Install prerequisites. - dirInfo, err := build.ScanDir(dir, parent == "") + dirInfo, err := build.ScanDir(dir) if err != nil { terrorf(tree, "%s: %v\n", pkg, err) return } - if len(dirInfo.GoFiles)+len(dirInfo.CgoFiles) == 0 { - terrorf(tree, "%s: package has no files\n", pkg) + // We reserve package main to identify commands. + if parent != "" && dirInfo.Package == "main" { + terrorf(tree, "%s: found only package main in %s; cannot import", pkg, dir) return } for _, p := range dirInfo.Imports { |