]> Cypherpunks.ru repositories - gostls13.git/commit
cmd/go: add $GOFLAGS environment variable
authorRuss Cox <rsc@golang.org>
Sun, 29 Jul 2018 05:10:02 +0000 (01:10 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 1 Aug 2018 00:35:21 +0000 (00:35 +0000)
commitc1a4fc3b36ccfe0022392224c2630f7971c156fe
tree12f32ebe5c1816053bd59726ff851e9733cd69bc
parent53859e575ba0f0b84914e7dc5c2a09b6b0c5d96f
cmd/go: add $GOFLAGS environment variable

People sometimes want to turn on a particular go command flag by default.
In Go 1.11 we have at least two different cases where users may need this.

1. Linking can be noticeably slower on underpowered systems
due to DWARF, and users may want to set -ldflags=-w by default.

2. For modules, some users or CI systems will want vendoring always,
so they want -getmode=vendor (soon to be -mod=vendor) by default.

This CL generalizes the problem to “set default flags for the go command.”

$GOFLAGS can be a space-separated list of flag settings, but each
space-separated entry in the list must be a standalone flag.
That is, you must do 'GOFLAGS=-ldflags=-w' not 'GOFLAGS=-ldflags -w'.
The latter would mean to pass -w to go commands that understand it
(if any do; if not, it's an error to mention it).

For #26074.
For #26318.
Fixes #26585.

Change-Id: I428f79c1fbfb9e41e54d199c68746405aed2319c
Reviewed-on: https://go-review.googlesource.com/126656
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
15 files changed:
src/cmd/go/alldocs.go
src/cmd/go/internal/base/goflags.go [new file with mode: 0644]
src/cmd/go/internal/cmdflag/flag.go
src/cmd/go/internal/envcmd/env.go
src/cmd/go/internal/help/helpdoc.go
src/cmd/go/internal/test/testflag.go
src/cmd/go/internal/vet/vetflag.go
src/cmd/go/main.go
src/cmd/go/testdata/script/goflags.txt [new file with mode: 0644]
src/make.bash
src/make.bat
src/make.rc
src/run.bash
src/run.bat
src/run.rc