diff options
author | Russ Cox <rsc@golang.org> | 2024-05-08 20:41:38 -0400 |
---|---|---|
committer | Gopher Robot <gobot@golang.org> | 2024-05-15 13:52:10 +0000 |
commit | 6ccd8e4cf69efbc8983a9873a41158f554ea5363 (patch) | |
tree | c27a6b85448a30ceba52cf471f1dedf31efd0188 /src/cmd/go/alldocs.go | |
parent | 0222a028f19d9f497cf407bcf07f3ec56a032bdb (diff) | |
download | go-6ccd8e4cf69efbc8983a9873a41158f554ea5363.tar.gz go-6ccd8e4cf69efbc8983a9873a41158f554ea5363.zip |
cmd/go: add support for godebug lines in go.mod and go.work
The fact that the go line sets both the language version and the
GODEBUG compatibility version can be a problem, especially since
the go line is also required to be ≥ the go lines of any required
dependency modules.
This change adds a new 'godebug' line to go.mod and go.work
to allow setting the GODEBUG values for the entire module.
It also adds a new meta-value default=go1.21 that means
take the defaults from Go 1.21 no matter what the go line says.
These were discussed in proposal #65573.
Fixes #65573.
Change-Id: I91746322a10178370ed1015ce5278372a024c824
Reviewed-on: https://go-review.googlesource.com/c/go/+/584476
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Diffstat (limited to 'src/cmd/go/alldocs.go')
-rw-r--r-- | src/cmd/go/alldocs.go | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/cmd/go/alldocs.go b/src/cmd/go/alldocs.go index 7800c72af3..ad34b8dfcc 100644 --- a/src/cmd/go/alldocs.go +++ b/src/cmd/go/alldocs.go @@ -1201,6 +1201,12 @@ // // The -module flag changes the module's path (the go.mod file's module line). // +// The -godebug=key=value flag adds a godebug key=value line, +// replacing any existing godebug lines with the given key. +// +// The -dropgodebug=key flag drops any existing godebug lines +// with the given key. +// // The -require=path@version and -droprequire=path flags // add and drop a requirement on the given module path and version. // Note that -require overrides any existing requirements on path. @@ -1209,6 +1215,14 @@ // which make other go.mod adjustments as needed to satisfy // constraints imposed by other modules. // +// The -go=version flag sets the expected Go language version. +// This flag is mainly for tools that understand Go version dependencies. +// Users should prefer 'go get go@version'. +// +// The -toolchain=version flag sets the Go toolchain to use. +// This flag is mainly for tools that understand Go version dependencies. +// Users should prefer 'go get toolchain@version'. +// // The -exclude=path@version and -dropexclude=path@version flags // add and drop an exclusion for the given module path and version. // Note that -exclude=path@version is a no-op if that exclusion already exists. @@ -1230,13 +1244,9 @@ // like "v1.2.3" or a closed interval like "[v1.1.0,v1.1.9]". Note that // -retract=version is a no-op if that retraction already exists. // -// The -require, -droprequire, -exclude, -dropexclude, -replace, -// -dropreplace, -retract, and -dropretract editing flags may be repeated, -// and the changes are applied in the order given. -// -// The -go=version flag sets the expected Go language version. -// -// The -toolchain=name flag sets the Go toolchain to use. +// The -godebug, -dropgodebug, -require, -droprequire, -exclude, -dropexclude, +// -replace, -dropreplace, -retract, and -dropretract editing flags may be +// repeated, and the changes are applied in the order given. // // The -print flag prints the final go.mod in its text format instead of // writing it back to go.mod. @@ -1253,6 +1263,7 @@ // Module ModPath // Go string // Toolchain string +// Godebug []Godebug // Require []Require // Exclude []Module // Replace []Replace @@ -1264,9 +1275,14 @@ // Deprecated string // } // +// type Godebug struct { +// Key string +// Value string +// } +// // type Require struct { -// Path string -// Version string +// Path string +// Version string // Indirect bool // } // @@ -1530,6 +1546,12 @@ // rewrite the go.mod file. The only time this flag is needed is if no other // flags are specified, as in 'go work edit -fmt'. // +// The -godebug=key=value flag adds a godebug key=value line, +// replacing any existing godebug lines with the given key. +// +// The -dropgodebug=key flag drops any existing godebug lines +// with the given key. +// // The -use=path and -dropuse=path flags // add and drop a use directive from the go.work file's set of module directories. // @@ -1561,10 +1583,16 @@ // type GoWork struct { // Go string // Toolchain string +// Godebug []Godebug // Use []Use // Replace []Replace // } // +// type Godebug struct { +// Key string +// Value string +// } +// // type Use struct { // DiskPath string // ModulePath string |