diff options
author | Russ Cox <rsc@golang.org> | 2019-04-22 23:55:27 -0400 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2019-04-24 14:25:09 +0000 |
commit | 74695644e0c38586a85b9b483830c546efbb6642 (patch) | |
tree | 1798977e86114cda7a1fb50cdf85885f9ad686ce /src/cmd/go/internal/work/build.go | |
parent | 8a20fde697c973962d978c1284fddf81a694141a (diff) | |
download | go-74695644e0c38586a85b9b483830c546efbb6642.tar.gz go-74695644e0c38586a85b9b483830c546efbb6642.zip |
cmd/go: add -trimpath build flag
"go build -trimpath" trims the recorded file paths in the
resulting packages and executables to avoid recording
the names of any local directories. Instead, the files appear
to be stored in directories named either "go/src/..." (for the
standard library) or named after the module or package
in which the files appear.
Fixes #16860.
Change-Id: I433afeeb1fdeea641286b21693fee5e0a66d607e
Reviewed-on: https://go-review.googlesource.com/c/go/+/173345
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Diffstat (limited to 'src/cmd/go/internal/work/build.go')
-rw-r--r-- | src/cmd/go/internal/work/build.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go index 15faf578f8..355c1477f5 100644 --- a/src/cmd/go/internal/work/build.go +++ b/src/cmd/go/internal/work/build.go @@ -108,6 +108,12 @@ and test commands: a space-separated list of build tags to consider satisfied during the build. For more information about build tags, see the description of build constraints in the documentation for the go/build package. + -trimpath + remove all file system paths from the resulting executable. + Instead of absolute file system paths, the recorded file names + will begin with either "go" (for the standard library), + or a module path@version (when using modules), + or a plain import path (when using GOPATH). -toolexec 'cmd args' a program to use to invoke toolchain programs like vet and asm. For example, instead of running asm, the go command will run @@ -229,6 +235,7 @@ func AddBuildFlags(cmd *base.Command) { cmd.Flag.BoolVar(&cfg.BuildMSan, "msan", false, "") cmd.Flag.Var((*base.StringsFlag)(&cfg.BuildContext.BuildTags), "tags", "") cmd.Flag.Var((*base.StringsFlag)(&cfg.BuildToolexec), "toolexec", "") + cmd.Flag.BoolVar(&cfg.BuildTrimpath, "trimpath", false, "") cmd.Flag.BoolVar(&cfg.BuildWork, "work", false, "") // Undocumented, unstable debugging flags. |