aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/work/build.go
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2019-10-02 10:51:09 -0400
committerBryan C. Mills <bcmills@google.com>2019-10-04 15:47:46 +0000
commit6145a80608087b309251b4edf1a612739331bdee (patch)
tree21844265641515c86014f632674f797868e587d3 /src/cmd/go/internal/work/build.go
parentc1e46af62f2893a6beb2341ef71ffe8d3787975b (diff)
downloadgo-6145a80608087b309251b4edf1a612739331bdee.tar.gz
go-6145a80608087b309251b4edf1a612739331bdee.zip
cmd/go: remove the -mod flag from 'go get'
'GOFLAGS=-mod=vendor' currently causes 'go get' to always fail unless the '-mod' flag is explicitly overwritten. Moreover, as of CL 198319 we plan to set -mod=vendor by default if a vendor directory is present, so all users with vendor directories will be affected — not just those who set 'GOFLAGS' explicitly. Similarly, an explicit '-mod=readonly' argument to 'go get' is currently ignored as a special case, but the fact that it is ignored (rather than rejected) can be very surprising. Rather than adding more special cases, we should remove the '-mod' flag from 'go get' entirely. Fixes #30345 Fixes #32502 Updates #33848 Change-Id: Iecd3233ca3ef580ca3a66bd5e6ee8d86d4cbd8a7 Reviewed-on: https://go-review.googlesource.com/c/go/+/198438 Run-TryBot: Bryan C. Mills <bcmills@google.com> 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.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/cmd/go/internal/work/build.go b/src/cmd/go/internal/work/build.go
index 9d6fa0c25b..1fc47a36c7 100644
--- a/src/cmd/go/internal/work/build.go
+++ b/src/cmd/go/internal/work/build.go
@@ -167,8 +167,8 @@ func init() {
CmdInstall.Flag.BoolVar(&cfg.BuildI, "i", false, "")
- AddBuildFlags(CmdBuild)
- AddBuildFlags(CmdInstall)
+ AddBuildFlags(CmdBuild, DefaultBuildFlags)
+ AddBuildFlags(CmdInstall, DefaultBuildFlags)
}
// Note that flags consulted by other parts of the code
@@ -216,9 +216,16 @@ func init() {
}
}
+type BuildFlagMask int
+
+const (
+ DefaultBuildFlags BuildFlagMask = 0
+ OmitModFlag BuildFlagMask = 1 << iota
+)
+
// addBuildFlags adds the flags common to the build, clean, get,
// install, list, run, and test commands.
-func AddBuildFlags(cmd *base.Command) {
+func AddBuildFlags(cmd *base.Command, mask BuildFlagMask) {
cmd.Flag.BoolVar(&cfg.BuildA, "a", false, "")
cmd.Flag.BoolVar(&cfg.BuildN, "n", false, "")
cmd.Flag.IntVar(&cfg.BuildP, "p", cfg.BuildP, "")
@@ -230,7 +237,9 @@ func AddBuildFlags(cmd *base.Command) {
cmd.Flag.StringVar(&cfg.BuildBuildmode, "buildmode", "default", "")
cmd.Flag.Var(&load.BuildGcflags, "gcflags", "")
cmd.Flag.Var(&load.BuildGccgoflags, "gccgoflags", "")
- cmd.Flag.StringVar(&cfg.BuildMod, "mod", "", "")
+ if mask&OmitModFlag == 0 {
+ cmd.Flag.StringVar(&cfg.BuildMod, "mod", "", "")
+ }
cmd.Flag.StringVar(&cfg.BuildContext.InstallSuffix, "installsuffix", "", "")
cmd.Flag.Var(&load.BuildLdflags, "ldflags", "")
cmd.Flag.BoolVar(&cfg.BuildLinkshared, "linkshared", false, "")