From: Russ Cox Date: Mon, 21 Nov 2022 21:50:41 +0000 (-0500) Subject: doc: document more cgo, go command changes X-Git-Tag: go1.20rc1~121 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=d58f2e741c742aafe5d3247bd184e182da71408d;p=gostls13.git doc: document more cgo, go command changes Also document new cgo changes and reorder go command section to put most important notes first. Change-Id: I45b0c785bd8bc82c3b174800fc995312ea057f14 Reviewed-on: https://go-review.googlesource.com/c/go/+/452557 Reviewed-by: Bryan Mills Run-TryBot: Russ Cox TryBot-Result: Gopher Robot Auto-Submit: Russ Cox --- diff --git a/doc/go1.20.html b/doc/go1.20.html index ebefbe6e06..aaa811e595 100644 --- a/doc/go1.20.html +++ b/doc/go1.20.html @@ -51,45 +51,41 @@ Do not send CLs removing the interior tags from such phrases.

Go command

-

- TODO: https://go.dev/cl/421440: cmd/go: add go generate -skip flag -

- -

- TODO: https://go.dev/issue/45454: provide build tags for architecture environment variables +

+ The directory $GOROOT/pkg no longer stores + pre-compiled package archives for the standard library: + go install no longer writes them, + the go build no longer checks for them, + and the Go distribution no longer ships them. + Instead, packages in the standard library are built as needed + and cached in the build cache, just like packages outside GOROOT. + This change reduces the size of the Go distribution and also + avoids C toolchain skew for packages that use cgo.

- TODO: CL 448357: cmd/go: print test2json start events -

- -

- The Go distribution no longer ships with pre-compiled .a - files for most of the packages in GOROOT, now only including - .a files for the five packages in GOROOT that use cgo. - Instead, those packages will be built as needed and cached in the build - cache, as is already done for non-main packages outside - GOROOT. Further, go install will - also not install .a files for GOROOT packages - except for those that use cgo. These changes are intended to - reduce the size of the Go distribution, in some cases by up to two-thirds. + The implementation of go test -json + has been improved to make it more robust. + Programs that run go test -json + do not need any updates. + Programs that invoke go tool test2json + directly should now run the test binary with -v=json + (for example, go test -v=json + or ./pkg.test -test.v=json) + instead of plain -v.

-

- When the main module is located within GOPATH/src, - go install no longer installs libraries for - non-main packages to GOPATH/pkg, - and go list no longer reports a Target - field for such packages. (In module mode, compiled packages are stored in the - build cache - only, but a bug had caused - the GOPATH install targets to unexpectedly remain in effect.) +

+ A related change to go test -json + is the addition of an event with Action set to start + at the beginning of each test program's execution. + When running multiple tests using the go command, + these start events are guaranteed to be emitted in the same order as + the packages named on the command line.

-

- The -i flag is no longer accepted by - go build and go test. - The flag has been deprecated since Go 1.16. +

+ TODO: https://go.dev/issue/45454: provide build tags for architecture environment variables

@@ -99,12 +95,35 @@ Do not send CLs removing the interior tags from such phrases. execute commands in multiple different modules.

+

+ The go build and go test + commands no longer accept the -i flag, + which has been deprecated since Go 1.16. +

+ +

+ The go generate command now accepts + -skip <pattern> to skip //go:generate directives + matching <pattern>. +

+

The go test command now accepts - -skip <pattern> to skip tests or subtests + -skip <pattern> to skip tests, subtests, or examples matching <pattern>.

+

+ When the main module is located within GOPATH/src, + go install no longer installs libraries for + non-main packages to GOPATH/pkg, + and go list no longer reports a Target + field for such packages. (In module mode, compiled packages are stored in the + build cache + only, but a bug had caused + the GOPATH install targets to unexpectedly remain in effect.) +

+

go version

@@ -114,6 +133,47 @@ Do not send CLs removing the interior tags from such phrases. and Linux binaries without execute permission.

+

Cgo

+ +

+ The go command now disables cgo by default + on systems without a C toolchain. + More specifically, when the CGO_ENABLED environment variable is unset, + the CC environment variable is unset, + and the default C compiler (typically clang or gcc) + is not found in the path, + CGO_ENABLED defaults to 0. + As always, you can override the default by setting CGO_ENABLED explicitly. +

+ +

+ The most important effect of the default change is that when Go is installed + on a system without a C compiler, it will now use pure Go builds for packages + in the standard library that use cgo, instead of using pre-distributed package archives + (which have been removed, as noted above) + or attempting to use cgo and failing. + This makes Go work better in some minimal container environments + as well as on macOS, where pre-distributed package archives have + not been used for cgo-based packages since Go 1.16. +

+ +

+ The packages in the standard library that use cgo are net, + os/user, and + plugin. + On macOS, the net and os/user packages have been rewritten not to use cgo: + the same code is now used for cgo and non-cgo builds as well as cross-compiled builds. + On Windows, the net and os/user packages have never used cgo. + On other systems, builds with cgo disabled will use a pure Go version of these packages. +

+ +

+ On macOS, the race detector has been rewritten not to use cgo: + race-detector-enabled programs can be built and run without Xcode. + On Linux and other Unix systems, and on Windows, a host C toolchain + is required to use the race detector. +

+

Cover

@@ -630,7 +690,7 @@ proxyHandler := &httputil.ReverseProxy{

- HTTP/2 stream errors returned by net/http functions may be converted + HTTP/2 stream errors returned by net/http functions may be converted to a "golang.org/x/net/http2".StreamError using errors.As.