From 26c32de7c9a6bb54d0144d1cc2f00cc334778cac Mon Sep 17 00:00:00 2001 From: "Bryan C. Mills" Date: Fri, 12 Mar 2021 11:26:51 -0500 Subject: [PATCH] cmd/go/internal/modcmd: in 'go mod tidy', suspend go.mod writes until tidy For #36460 Change-Id: Ia8633f37aec8c7ed532bf7278867251e5e2a4285 Reviewed-on: https://go-review.googlesource.com/c/go/+/301370 Trust: Bryan C. Mills Run-TryBot: Bryan C. Mills TryBot-Result: Go Bot Reviewed-by: Michael Matloob Reviewed-by: Jay Conrod --- src/cmd/go/internal/modcmd/tidy.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/cmd/go/internal/modcmd/tidy.go b/src/cmd/go/internal/modcmd/tidy.go index 34ff86ff185..33ecd80bcb5 100644 --- a/src/cmd/go/internal/modcmd/tidy.go +++ b/src/cmd/go/internal/modcmd/tidy.go @@ -60,6 +60,7 @@ func runTidy(ctx context.Context, cmd *base.Command, args []string) { // request that their test dependencies be included. modload.ForceUseModules = true modload.RootMode = modload.NeedRoot + modload.DisallowWriteGoMod() // Suppress writing until we've tidied the file. modload.LoadPackages(ctx, modload.PackageOpts{ Tags: imports.AnyTags(), @@ -72,5 +73,7 @@ func runTidy(ctx context.Context, cmd *base.Command, args []string) { modload.TidyBuildList() modload.TrimGoSum() + + modload.AllowWriteGoMod() modload.WriteGoMod() }