Workspace mode only allows -mod to be set to 'readonly'. When returning
the error for other values of -mod, specify the the value in the error
so it's easier to see what's going on when the go command is invoked
through another tool.
For #45713, #48186
Change-Id: I3ba206a71c7a20c18aeccfa48f3c9dc935a180a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/347593
Trust: Michael Matloob <matloob@golang.org>
Trust: Daniel Martà <mvdan@mvdan.cc>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Daniel Martà <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
func setDefaultBuildMod() {
if cfg.BuildModExplicit {
if inWorkspaceMode() && cfg.BuildMod != "readonly" {
- base.Fatalf("go: -mod may only be set to readonly when in workspace mode." +
- "\n\tRemove the -mod flag to use the default readonly value," +
- "\n\tor set -workfile=off to disable workspace mode.")
+ base.Fatalf("go: -mod may only be set to readonly when in workspace mode, but it is set to %q"+
+ "\n\tRemove the -mod flag to use the default readonly value,"+
+ "\n\tor set -workfile=off to disable workspace mode.", cfg.BuildMod)
}
// Don't override an explicit '-mod=' argument.
return