]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: address review comments
authorRuss Cox <rsc@golang.org>
Fri, 3 Feb 2017 18:29:06 +0000 (13:29 -0500)
committerRuss Cox <rsc@golang.org>
Fri, 3 Feb 2017 20:32:36 +0000 (20:32 +0000)
Address review comments from earlier CLs.
These are changes I was too scared to try to push
down into the original CLs (thanks, Git).

Change-Id: I0e428fad73d71bd2a7d08178cf2e856de3cef19f
Reviewed-on: https://go-review.googlesource.com/36257
Reviewed-by: David Crawshaw <crawshaw@golang.org>
20 files changed:
src/cmd/dist/deps.go
src/cmd/go/internal/base/base.go
src/cmd/go/internal/base/flag.go
src/cmd/go/internal/base/path.go
src/cmd/go/internal/cfg/cfg.go
src/cmd/go/internal/clean/clean.go
src/cmd/go/internal/doc/doc.go
src/cmd/go/internal/envcmd/env.go [moved from src/cmd/go/internal/env/env.go with 97% similarity]
src/cmd/go/internal/fix/fix.go
src/cmd/go/internal/fmtcmd/fmt.go [moved from src/cmd/go/internal/fmt/fmt.go with 93% similarity]
src/cmd/go/internal/generate/generate.go
src/cmd/go/internal/help/help.go
src/cmd/go/internal/list/list.go
src/cmd/go/internal/load/pkg.go
src/cmd/go/internal/run/run.go
src/cmd/go/internal/tool/tool.go
src/cmd/go/internal/version/version.go
src/cmd/go/internal/vet/vet.go
src/cmd/go/internal/work/build.go
src/cmd/go/main.go

index e4a025701bdf4d28857cfa275674ee50c8c6afdc..d929252bae8cd45cd99c09b8077e1dabca5382f1 100644 (file)
@@ -6,14 +6,14 @@ var builddeps = map[string][]string{
        "bufio":                             {"bytes", "errors", "internal/race", "io", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sync", "sync/atomic", "unicode", "unicode/utf8"},
        "bytes":                             {"errors", "internal/race", "io", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sync", "sync/atomic", "unicode", "unicode/utf8"},
        "cmd/go/internal/base":              {"bufio", "bytes", "cmd/go/internal/cfg", "cmd/go/internal/str", "context", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
-       "cmd/go/internal/bug":               {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/env", "cmd/go/internal/load", "cmd/go/internal/str", "cmd/go/internal/web", "cmd/go/internal/work", "compress/flate", "compress/zlib", "container/heap", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
-       "cmd/go/internal/buildid":           {"bufio", "bytes", "cmd/go/internal/cfg", "compress/flate", "compress/zlib", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
-       "cmd/go/internal/cfg":               {"bufio", "bytes", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
+       "cmd/go/internal/bug":               {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/envcmd", "cmd/go/internal/load", "cmd/go/internal/str", "cmd/go/internal/web", "cmd/go/internal/work", "compress/flate", "compress/zlib", "container/heap", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
+       "cmd/go/internal/buildid":           {"bufio", "bytes", "cmd/go/internal/cfg", "compress/flate", "compress/zlib", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
+       "cmd/go/internal/cfg":               {"bufio", "bytes", "errors", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
        "cmd/go/internal/clean":             {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/load", "cmd/go/internal/str", "cmd/go/internal/work", "compress/flate", "compress/zlib", "container/heap", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
        "cmd/go/internal/doc":               {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/cfg", "cmd/go/internal/str", "context", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
-       "cmd/go/internal/env":               {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/load", "cmd/go/internal/str", "cmd/go/internal/work", "compress/flate", "compress/zlib", "container/heap", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
+       "cmd/go/internal/envcmd":            {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/load", "cmd/go/internal/str", "cmd/go/internal/work", "compress/flate", "compress/zlib", "container/heap", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
        "cmd/go/internal/fix":               {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/load", "cmd/go/internal/str", "compress/flate", "compress/zlib", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
-       "cmd/go/internal/fmt":               {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/load", "cmd/go/internal/str", "compress/flate", "compress/zlib", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
+       "cmd/go/internal/fmtcmd":            {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/load", "cmd/go/internal/str", "compress/flate", "compress/zlib", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
        "cmd/go/internal/generate":          {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/load", "cmd/go/internal/str", "cmd/go/internal/work", "compress/flate", "compress/zlib", "container/heap", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding/binary", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
        "cmd/go/internal/get":               {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/load", "cmd/go/internal/str", "cmd/go/internal/web", "cmd/go/internal/work", "compress/flate", "compress/zlib", "container/heap", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding", "encoding/base64", "encoding/binary", "encoding/json", "encoding/xml", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "internal/race", "internal/singleflight", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
        "cmd/go/internal/help":              {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/cfg", "cmd/go/internal/str", "context", "encoding", "encoding/base64", "encoding/json", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "html", "html/template", "internal/race", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
@@ -87,5 +87,5 @@ var builddeps = map[string][]string{
        "unicode":                 {"runtime", "runtime/internal/atomic", "runtime/internal/sys"},
        "unicode/utf16":           {"runtime", "runtime/internal/atomic", "runtime/internal/sys"},
        "unicode/utf8":            {"runtime", "runtime/internal/atomic", "runtime/internal/sys"},
-       "cmd/go":                  {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/bug", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/clean", "cmd/go/internal/doc", "cmd/go/internal/env", "cmd/go/internal/fix", "cmd/go/internal/fmt", "cmd/go/internal/generate", "cmd/go/internal/get", "cmd/go/internal/help", "cmd/go/internal/list", "cmd/go/internal/load", "cmd/go/internal/run", "cmd/go/internal/str", "cmd/go/internal/test", "cmd/go/internal/tool", "cmd/go/internal/version", "cmd/go/internal/vet", "cmd/go/internal/web", "cmd/go/internal/work", "compress/flate", "compress/zlib", "container/heap", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding", "encoding/base64", "encoding/binary", "encoding/json", "encoding/xml", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "html", "html/template", "internal/race", "internal/singleflight", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
+       "cmd/go":                  {"bufio", "bytes", "cmd/go/internal/base", "cmd/go/internal/bug", "cmd/go/internal/buildid", "cmd/go/internal/cfg", "cmd/go/internal/clean", "cmd/go/internal/doc", "cmd/go/internal/envcmd", "cmd/go/internal/fix", "cmd/go/internal/fmtcmd", "cmd/go/internal/generate", "cmd/go/internal/get", "cmd/go/internal/help", "cmd/go/internal/list", "cmd/go/internal/load", "cmd/go/internal/run", "cmd/go/internal/str", "cmd/go/internal/test", "cmd/go/internal/tool", "cmd/go/internal/version", "cmd/go/internal/vet", "cmd/go/internal/web", "cmd/go/internal/work", "compress/flate", "compress/zlib", "container/heap", "context", "crypto", "crypto/sha1", "debug/dwarf", "debug/elf", "debug/macho", "encoding", "encoding/base64", "encoding/binary", "encoding/json", "encoding/xml", "errors", "flag", "fmt", "go/ast", "go/build", "go/doc", "go/parser", "go/scanner", "go/token", "hash", "hash/adler32", "html", "html/template", "internal/race", "internal/singleflight", "internal/syscall/windows", "internal/syscall/windows/registry", "internal/syscall/windows/sysdll", "io", "io/ioutil", "log", "math", "net/url", "os", "os/exec", "os/signal", "path", "path/filepath", "reflect", "regexp", "regexp/syntax", "runtime", "runtime/internal/atomic", "runtime/internal/sys", "sort", "strconv", "strings", "sync", "sync/atomic", "syscall", "text/template", "text/template/parse", "time", "unicode", "unicode/utf16", "unicode/utf8"},
 }
index 3d04880acdd06029889c08d9abe4b7ea0850c90f..aff33f70d8deb3394e708bf2c20e0edeb840087e 100644 (file)
@@ -8,8 +8,6 @@ package base
 
 import (
        "bytes"
-       "cmd/go/internal/cfg"
-       "cmd/go/internal/str"
        "errors"
        "flag"
        "fmt"
@@ -19,6 +17,9 @@ import (
        "os/exec"
        "strings"
        "sync"
+
+       "cmd/go/internal/cfg"
+       "cmd/go/internal/str"
 )
 
 // A Command is an implementation of a go command
index 84ea02ad2b913c41eb74faeabbdf1106e7b016e3..5e03e6405884d27eb5fce6b2623da9187b1760c6 100644 (file)
@@ -5,8 +5,10 @@
 package base
 
 import (
-       "cmd/go/internal/str"
        "flag"
+
+       "cmd/go/internal/cfg"
+       "cmd/go/internal/str"
 )
 
 // A StringsFlag is a command-line flag that interprets its argument
@@ -28,6 +30,6 @@ func (v *StringsFlag) String() string {
 
 // AddBuildFlagsNX adds the -n and -x build flags to the flag set.
 func AddBuildFlagsNX(flags *flag.FlagSet) {
-       flags.BoolVar(&BuildN, "n", false, "")
-       flags.BoolVar(&BuildX, "x", false, "")
+       flags.BoolVar(&cfg.BuildN, "n", false, "")
+       flags.BoolVar(&cfg.BuildX, "x", false, "")
 }
index f7e985aa5968ac2faa970356600fabf36c6fecf6..7a51181c9736e9cdf8549a7192f9bdcf67f419ce 100644 (file)
@@ -10,7 +10,15 @@ import (
        "strings"
 )
 
-var Cwd, _ = os.Getwd()
+func getwd() string {
+       wd, err := os.Getwd()
+       if err != nil {
+               Fatalf("cannot determine current directory: %v", err)
+       }
+       return wd
+}
+
+var Cwd = getwd()
 
 // ShortPath returns an absolute or relative name for path, whatever is shorter.
 func ShortPath(path string) string {
index 19d648b1938d5fd2d329d4224617dbba4cbcdb1e..48b9e81e2da132dc023cec2f174c44627ecbae03 100644 (file)
@@ -7,7 +7,6 @@
 package cfg
 
 import (
-       "flag"
        "go/build"
        "os"
        "path/filepath"
@@ -30,14 +29,18 @@ var (
        BuildRace              bool               // -race flag
        BuildToolexec          []string           // -toolexec flag
        BuildToolchainName     string
-       BuildToolchainCompiler string
-       BuildToolchainLinker   string
+       BuildToolchainCompiler func() string
+       BuildToolchainLinker   func() string
        BuildV                 bool // -v flag
        BuildWork              bool // -work flag
        BuildX                 bool // -x flag
-
 )
 
+func init() {
+       BuildToolchainCompiler = func() string { return "missing-compiler" }
+       BuildToolchainLinker = func() string { return "missing-linker" }
+}
+
 // The test coverage mode affects package loading. Sigh.
 var TestCoverMode string // -covermode flag
 
@@ -50,8 +53,10 @@ type EnvVar struct {
 // OrigEnv is the original environment of the program at startup.
 var OrigEnv []string
 
-// NewEnv is the new environment for running commands.
-var NewEnv []EnvVar
+// CmdEnv is the new environment for running go tool commands.
+// User binaries (during go test or go run) are run with OrigEnv,
+// not CmdEnv.
+var CmdEnv []EnvVar
 
 // Global build parameters (used during package load)
 var (
@@ -61,12 +66,6 @@ var (
        Gopath    []string
 )
 
-// AddBuildFlagsNX adds the -n and -x build flags to the flag set.
-func AddBuildFlagsNX(flags *flag.FlagSet) {
-       flags.BoolVar(&BuildN, "n", false, "")
-       flags.BoolVar(&BuildX, "x", false, "")
-}
-
 var (
        GOROOT    = filepath.Clean(runtime.GOROOT())
        GOBIN     = os.Getenv("GOBIN")
index df57deff1d5bb7b0ceb3e34cf4a40c07050d173c..454cac1f47b4c592f1049c4fb3f6414de4eed0fd 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package clean implements the ``go clean'' command.
 package clean
 
 import (
index 512f312fe74d64a1005d02c49396375929ecf7a3..66ff07615ee45854485e1e037b067f57804816a2 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package doc implements the ``go doc'' command.
 package doc
 
 import (
similarity index 97%
rename from src/cmd/go/internal/env/env.go
rename to src/cmd/go/internal/envcmd/env.go
index dad158e62cb941ebb300ed4d42411fe04123b526..c7d8c6cc1bedc4b3a1e6eab27520ea1e9f2e6471 100644 (file)
@@ -2,7 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package env
+// Package envcmd implements the ``go env'' command.
+package envcmd
 
 import (
        "fmt"
@@ -103,7 +104,7 @@ func ExtraEnvVars() []cfg.EnvVar {
 }
 
 func runEnv(cmd *base.Command, args []string) {
-       env := cfg.NewEnv
+       env := cfg.CmdEnv
        env = append(env, ExtraEnvVars()...)
        if len(args) > 0 {
                for _, name := range args {
index 0475dc379934bd549bca5df8f31d380bf1ccf53a..377cd037faf3c0e2a46aa8b3989fb953f893b4cb 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package fix implements the ``go fix'' command.
 package fix
 
 import (
similarity index 93%
rename from src/cmd/go/internal/fmt/fmt.go
rename to src/cmd/go/internal/fmtcmd/fmt.go
index 1124beeedb6575120cc77fb14d50c3c37ddbc2da..a4bf79e2657f89886ef7b2c240a45c1f3b0dc368 100644 (file)
@@ -2,7 +2,8 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-package fmt
+// Package fmtcmd implements the ``go fmt'' command.
+package fmtcmd
 
 import (
        "os"
@@ -15,7 +16,7 @@ import (
 )
 
 func init() {
-       cfg.AddBuildFlagsNX(&CmdFmt.Flag)
+       base.AddBuildFlagsNX(&CmdFmt.Flag)
 }
 
 var CmdFmt = &base.Command{
index 07f3d13938260611446948e0fc9801ea0cbc4a19..fb6d77709188ee22ce99bcdabc58869032634586 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package generate implements the ``go generate'' command.
 package generate
 
 import (
index 1558fa458796fe72c5fadae7b3e7d6fb592366f3..da52ac00fdfa64f7742619aca54308a6bc84933f 100644 (file)
@@ -2,17 +2,17 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// Package help implements "go help".
+// Package help implements the ``go help'' command.
 package help
 
 import (
        "bufio"
        "bytes"
        "fmt"
-       "html/template"
        "io"
        "os"
        "strings"
+       "text/template"
        "unicode"
        "unicode/utf8"
 
index 2f7ae6f72b889a7cb28886ca3293af5d3d192783..c63753813e6c3e0dde64eab09ed65ad153b42dff 100644 (file)
@@ -2,19 +2,21 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package list implements the ``go list'' command.
 package list
 
 import (
        "bufio"
-       "cmd/go/internal/base"
-       "cmd/go/internal/cfg"
-       "cmd/go/internal/load"
-       "cmd/go/internal/work"
        "encoding/json"
        "io"
        "os"
        "strings"
        "text/template"
+
+       "cmd/go/internal/base"
+       "cmd/go/internal/cfg"
+       "cmd/go/internal/load"
+       "cmd/go/internal/work"
 )
 
 var CmdList = &base.Command{
index 3b149946cb007ba8e609e7e6d95d6cceb55a8cee..11dd6815df667fde2273af2e87564db4fb56302f 100644 (file)
@@ -883,7 +883,7 @@ func (p *Package) load(stk *ImportStack, bp *build.Package, err error) *Package
                        p.Internal.Target = filepath.Join(cfg.GOROOTpkg, "tool", full)
                }
                if p.Internal.Target != "" && cfg.BuildContext.GOOS == "windows" {
-                       p.Internal.Target += ".Internal.Exe"
+                       p.Internal.Target += ".exe"
                }
        } else if p.Internal.Local {
                // Local import turned into absolute path.
@@ -1562,10 +1562,10 @@ func isStale(p *Package) (bool, string) {
        // Excluding $GOROOT used to also fix issue 4106, but that's now
        // taken care of above (at least when the installed Go is a released version).
        if p.Root != cfg.GOROOT {
-               if olderThan(cfg.BuildToolchainCompiler) {
+               if olderThan(cfg.BuildToolchainCompiler()) {
                        return true, "newer compiler"
                }
-               if p.Internal.Build.IsCommand() && olderThan(cfg.BuildToolchainLinker) {
+               if p.Internal.Build.IsCommand() && olderThan(cfg.BuildToolchainLinker()) {
                        return true, "newer linker"
                }
        }
index edd3ddd8432a9d7cefd52189c3209959c4bfe7bc..980e160fee8b7446e9fd1393e002b5991fbb2e80 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package run implements the ``go run'' command.
 package run
 
 import (
@@ -66,7 +67,7 @@ func runRun(cmd *base.Command, args []string) {
        }
        for _, file := range files {
                if strings.HasSuffix(file, "_test.go") {
-                       // goFilesPackage is going to assign this to TestGoFiles.
+                       // GoFilesPackage is going to assign this to TestGoFiles.
                        // Reject since it won't be part of the build.
                        base.Fatalf("go run: cannot run *_test.go files (%s)", file)
                }
index 1a3e0765212b2acb8e1b23332ca41204e5c35a6b..51675262e590bc2d5d25b42527b73f17216727e1 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package tool implements the ``go tool'' command.
 package tool
 
 import (
index 550f31a3438c975515e8649f00a49aa280be7fc4..c3f7d73ff1d95fd47a31d8b1cafc593a8b3f9eec 100644 (file)
@@ -2,12 +2,14 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package version implements the ``go version'' command.
 package version
 
 import (
-       "cmd/go/internal/base"
        "fmt"
        "runtime"
+
+       "cmd/go/internal/base"
 )
 
 var CmdVersion = &base.Command{
index fa60d998e138629593116a3472e481be9067f524..2bd4fafe95d702e55d6a53a4f8afc737eb5431cb 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// Package vet implements the ``go vet'' command.
 package vet
 
 import (
index 63731e1dfa6ee77deaa871ac0a5ab4dffeafed9e..06611885dac979614dcf4b23a1c0313231a90779 100644 (file)
@@ -180,8 +180,8 @@ func (c buildCompiler) Set(value string) error {
                return fmt.Errorf("unknown compiler %q", value)
        }
        cfg.BuildToolchainName = value
-       cfg.BuildToolchainCompiler = BuildToolchain.compiler()
-       cfg.BuildToolchainLinker = BuildToolchain.linker()
+       cfg.BuildToolchainCompiler = BuildToolchain.compiler
+       cfg.BuildToolchainLinker = BuildToolchain.linker
        cfg.BuildContext.Compiler = value
        return nil
 }
@@ -1317,9 +1317,11 @@ func (b *Builder) build(a *Action) (err error) {
                        sfiles = nil
                }
 
-               cgoExe := base.Tool("cgo")
+               var cgoExe string
                if a.cgo != nil && a.cgo.Target != "" {
                        cgoExe = a.cgo.Target
+               } else {
+                       cgoExe = base.Tool("cgo")
                }
                outGo, outObj, err := b.cgo(a, cgoExe, obj, pcCFLAGS, pcLDFLAGS, cgofiles, objdirCgofiles, gccfiles, cxxfiles, a.Package.MFiles, a.Package.FFiles)
                if err != nil {
index 1a9f36b0556132aa2a90a07e70c92d1d0fad6386..337e0236994b49738c09f238afaa503176f98d49 100644 (file)
@@ -20,9 +20,9 @@ import (
        "cmd/go/internal/cfg"
        "cmd/go/internal/clean"
        "cmd/go/internal/doc"
-       "cmd/go/internal/env"
+       "cmd/go/internal/envcmd"
        "cmd/go/internal/fix"
-       fmtcmd "cmd/go/internal/fmt"
+       "cmd/go/internal/fmtcmd"
        "cmd/go/internal/generate"
        "cmd/go/internal/get"
        "cmd/go/internal/help"
@@ -40,7 +40,7 @@ func init() {
                work.CmdBuild,
                clean.CmdClean,
                doc.CmdDoc,
-               env.CmdEnv,
+               envcmd.CmdEnv,
                bug.CmdBug,
                fix.CmdFix,
                fmtcmd.CmdFmt,
@@ -114,8 +114,8 @@ func main() {
        // but in practice there might be skew
        // This makes sure we all agree.
        cfg.OrigEnv = os.Environ()
-       cfg.NewEnv = env.MkEnv()
-       for _, env := range cfg.NewEnv {
+       cfg.CmdEnv = envcmd.MkEnv()
+       for _, env := range cfg.CmdEnv {
                if os.Getenv(env.Name) != env.Value {
                        os.Setenv(env.Name, env.Value)
                }