From 65f0d24f73fa5386bf921393cbd26bb8f9cead03 Mon Sep 17 00:00:00 2001 From: Michael Matloob Date: Fri, 3 Sep 2021 18:11:00 -0400 Subject: [PATCH] cmd/go: print offending -mod value in workspace mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Trust: Daniel Martí Run-TryBot: Michael Matloob TryBot-Result: Go Bot Reviewed-by: Jay Conrod Reviewed-by: Daniel Martí Reviewed-by: Bryan C. Mills --- src/cmd/go/internal/modload/init.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go index a1016ec5a3..a855e6c851 100644 --- a/src/cmd/go/internal/modload/init.go +++ b/src/cmd/go/internal/modload/init.go @@ -976,9 +976,9 @@ func requirementsFromModFiles(ctx context.Context, modFiles []*modfile.File) *Re 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