Skip to content

Commit ea537cc

Browse files
committed
cmd/go/internal/help: add documentation for language version downgrading
This change adds documentation for language version downgrading using build constraints. Fixes #68161 For #61894 Change-Id: I283a51afd7020c9fd1f5469a6a93fd814ba32f7e Reviewed-on: https://go-review.googlesource.com/c/go/+/595475 Reviewed-by: Robert Findley <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent b0927fd commit ea537cc

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/cmd/go/alldocs.go

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/cmd/go/internal/help/helpdoc.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,9 @@ line comment that begins
835835
836836
//go:build
837837
838+
Build constraints can also be used to downgrade the language version
839+
used to compile a file.
840+
838841
Constraints may appear in any kind of source file (not just Go), but
839842
they must appear near the top of the file, preceded
840843
only by blank lines and other comments. These rules mean that in Go
@@ -954,5 +957,9 @@ only when building the package for 32-bit x86.
954957
Go versions 1.16 and earlier used a different syntax for build constraints,
955958
with a "// +build" prefix. The gofmt command will add an equivalent //go:build
956959
constraint when encountering the older syntax.
960+
961+
In modules with a Go version of 1.21 or later, if a file's build constraint
962+
has a term for a Go major release, the language version used when compiling
963+
the file will be the minimum version implied by the build constraint.
957964
`,
958965
}

0 commit comments

Comments
 (0)