From 58c6afe075d74261dd67750e0aab5a1b8460839f Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Wed, 12 Sep 2018 13:58:18 -0400 Subject: [PATCH] doc/go1.11, cmd/go: elaborate on new GOFLAGS environment variable In Go 1.11, cmd/go gained support for the GOFLAGS environment variable. It was added and described in detail in CL 126656. Mention it in the Go 1.11 release notes, link to the cmd/go documentation, and add more details there. Fixes #27282. Change-Id: Ifc35bfe3e0886a145478d36dde8e80aedd8ec68e Reviewed-on: https://go-review.googlesource.com/135035 Reviewed-by: Bryan C. Mills Reviewed-by: Rob Pike --- doc/go1.11.html | 14 ++++++++++++++ src/cmd/go/alldocs.go | 6 ++++++ src/cmd/go/internal/help/helpdoc.go | 6 ++++++ 3 files changed, 26 insertions(+) diff --git a/doc/go1.11.html b/doc/go1.11.html index afe19397663af8..16b4c904cb332c 100644 --- a/doc/go1.11.html +++ b/doc/go1.11.html @@ -348,6 +348,20 @@

Cgo

details.

+

Go command

+ +

+ 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. +

+

Godoc

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