From 58c6afe075d74261dd67750e0aab5a1b8460839f Mon Sep 17 00:00:00 2001
From: Dmitri Shuralyov Cgo
details.
+ The environment variable GOFLAGS
may now be used
+ to set default flags for the go
command.
+ This is useful in certain situations.
+ Linking can be noticeably slower on underpowered systems due to DWARF,
+ and users may want to set -ldflags=-w
by default.
+ For modules, some users and CI systems will want vendoring always,
+ so they should set -mod=vendor
by default.
+ For more information, see the go
+ command documentation.
+
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 35cabcac14373d..969d51f5ab581e 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -1449,6 +1449,12 @@ // The directory where the go command will write // temporary source files, packages, and binaries. // +// Each entry in the GOFLAGS list must be a standalone flag. +// Because the entries are space-separated, flag values must +// not contain spaces. In some cases, you can provide multiple flag +// values instead: for example, to set '-ldflags=-s -w' +// you can use 'GOFLAGS=-ldflags=-s -ldflags=-w'. +// // Environment variables for use with cgo: // // CC diff --git a/src/cmd/go/internal/help/helpdoc.go b/src/cmd/go/internal/help/helpdoc.go index aff4ce12f6c9ae..e2c4e61615bcc7 100644 --- a/src/cmd/go/internal/help/helpdoc.go +++ b/src/cmd/go/internal/help/helpdoc.go @@ -507,6 +507,12 @@ General-purpose environment variables: The directory where the go command will write temporary source files, packages, and binaries. +Each entry in the GOFLAGS list must be a standalone flag. +Because the entries are space-separated, flag values must +not contain spaces. In some cases, you can provide multiple flag +values instead: for example, to set '-ldflags=-s -w' +you can use 'GOFLAGS=-ldflags=-s -ldflags=-w'. + Environment variables for use with cgo: CC