diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index a769f6c926..66c277bb01 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -38,6 +38,7 @@ Additional help topics: buildmode description of build modes filetype file types gopath GOPATH environment variable + environment environment variables importpath import path syntax packages description of package lists testflag description of testing flags @@ -974,6 +975,77 @@ in future releases. Once settled, they will be on by default. See https://golang.org/s/go15vendor for details. +Environment variables + +The go command, and the tools it invokes, examine a few different +environment variables. For many of these, you can see the default +value of on your system by running 'go env NAME', where NAME is the +name of the variable. + +General-purpose environment variables: + + GCCGO + The gccgo command to run for 'go build -compiler=gccgo'. + GOARCH + The architecture, or processor, for which to compile code. + Examples are amd64, 386, arm, ppc64. + GOBIN + The directory where 'go install' will install a command. + GOOS + The operating system for which to compile code. + Examples are linux, darwin, windows, netbsd. + GOPATH + See 'go help gopath'. + GORACE + Options for the race detector. + See https://golang.org/doc/articles/race_detector.html. + GOROOT + The root of the go tree. + +Environment variables for use with cgo: + + CC + The command to use to compile C code. + CGO_ENABLED + Whether the cgo command is supported. Either 0 or 1. + CGO_CFLAGS + Flags that cgo will pass to the compiler when compiling + C code. + CGO_CPPFLAGS + Flags that cgo will pass to the compiler when compiling + C or C++ code. + CGO_CXXFLAGS + Flags that cgo will pass to the compiler when compiling + C++ code. + CGO_LDFLAGS + Flags that cgo will pass to the compiler when linking. + CXX + The command to use to compile C++ code. + +Architecture-specific environment variables: + + GOARM + For GOARCH=arm, the ARM architecture for which to compile. + Valid values are 5, 6, 7. + GO386 + For GOARCH=386, the floating point instruction set. + Valid values are 387, sse2. + +Special-purpose environment variables: + + GOROOT_FINAL + The root of the installed Go tree, when it is + installed in a location other than where it is built. + File names in stack traces are rewritten from GOROOT to + GOROOT_FINAL. + GO15VENDOREXPERIMENT + Set to 1 to enable the Go 1.5 vendoring experiment. + GO_EXTLINK_ENABLED + Whether the linker should use external linking mode + when using -linkmode=auto with code that uses cgo. + Set to 0 to disable external linking mode, 1 to enable it. + + Import path syntax An import path (see 'go help packages') denotes a package diff --git a/src/cmd/go/help.go b/src/cmd/go/help.go index 2f463f7650..591c2f4a07 100644 --- a/src/cmd/go/help.go +++ b/src/cmd/go/help.go @@ -420,6 +420,81 @@ See https://golang.org/s/go15vendor for details. `, } +var helpEnvironment = &Command{ + UsageLine: "environment", + Short: "environment variables", + Long: ` + +The go command, and the tools it invokes, examine a few different +environment variables. For many of these, you can see the default +value of on your system by running 'go env NAME', where NAME is the +name of the variable. + +General-purpose environment variables: + + GCCGO + The gccgo command to run for 'go build -compiler=gccgo'. + GOARCH + The architecture, or processor, for which to compile code. + Examples are amd64, 386, arm, ppc64. + GOBIN + The directory where 'go install' will install a command. + GOOS + The operating system for which to compile code. + Examples are linux, darwin, windows, netbsd. + GOPATH + See 'go help gopath'. + GORACE + Options for the race detector. + See https://golang.org/doc/articles/race_detector.html. + GOROOT + The root of the go tree. + +Environment variables for use with cgo: + + CC + The command to use to compile C code. + CGO_ENABLED + Whether the cgo command is supported. Either 0 or 1. + CGO_CFLAGS + Flags that cgo will pass to the compiler when compiling + C code. + CGO_CPPFLAGS + Flags that cgo will pass to the compiler when compiling + C or C++ code. + CGO_CXXFLAGS + Flags that cgo will pass to the compiler when compiling + C++ code. + CGO_LDFLAGS + Flags that cgo will pass to the compiler when linking. + CXX + The command to use to compile C++ code. + +Architecture-specific environment variables: + + GOARM + For GOARCH=arm, the ARM architecture for which to compile. + Valid values are 5, 6, 7. + GO386 + For GOARCH=386, the floating point instruction set. + Valid values are 387, sse2. + +Special-purpose environment variables: + + GOROOT_FINAL + The root of the installed Go tree, when it is + installed in a location other than where it is built. + File names in stack traces are rewritten from GOROOT to + GOROOT_FINAL. + GO15VENDOREXPERIMENT + Set to 1 to enable the Go 1.5 vendoring experiment. + GO_EXTLINK_ENABLED + Whether the linker should use external linking mode + when using -linkmode=auto with code that uses cgo. + Set to 0 to disable external linking mode, 1 to enable it. + `, +} + var helpFileType = &Command{ UsageLine: "filetype", Short: "file types", diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go index ae1f954b3e..e07651bb02 100644 --- a/src/cmd/go/main.go +++ b/src/cmd/go/main.go @@ -95,6 +95,7 @@ var commands = []*Command{ helpBuildmode, helpFileType, helpGopath, + helpEnvironment, helpImportPath, helpPackages, helpTestflag,