]> Cypherpunks repositories - gostls13.git/commit
cmd/go: only add a 'go' directive to the main module when the go.mod file will be...
authorBryan C. Mills <bcmills@google.com>
Mon, 15 Mar 2021 16:40:34 +0000 (12:40 -0400)
committerBryan C. Mills <bcmills@google.com>
Wed, 17 Mar 2021 21:24:05 +0000 (21:24 +0000)
commit7e00049b5545cac8705d6df1e337c5ddc70e65e4
treef0ae39ba49ac7c649d14412d1949dd9fdf516de8
parent4313c2886160613ca62742d0f46665cf8954213c
cmd/go: only add a 'go' directive to the main module when the go.mod file will be written

Then, write the 'go.mod' file with that version before further
processing. That way, if the command errors out due to a change in
behavior, the reason for the change in behavior will be visible in the
file diffs.

If the 'go.mod' file cannot be written (due to -mod=readonly or
-mod=vendor), assume Go 1.11 instead of the current Go release.
(cmd/go has added 'go' directives automatically, including in 'go mod
init', since Go 1.12.)

For #44976

Change-Id: If9d4af557366f134f40ce4c5638688ba3bab8380
Reviewed-on: https://go-review.googlesource.com/c/go/+/302051
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
doc/go1.17.html
src/cmd/go/internal/modload/build.go
src/cmd/go/internal/modload/init.go
src/cmd/go/internal/modload/modfile.go
src/cmd/go/internal/work/gc.go
src/cmd/go/testdata/script/embed.txt
src/cmd/go/testdata/script/mod_go_version_missing.txt [new file with mode: 0644]
src/cmd/go/testdata/script/mod_outside.txt
src/cmd/go/testdata/script/mod_test.txt