Compare commits

..

205 Commits

Author SHA1 Message Date
Gopher Robot
3901409b5d [release-branch.go1.24] go1.24.0
Change-Id: I98457f219e75fb99233804d15c8b9577ee3d4a24
Reviewed-on: https://go-review.googlesource.com/c/go/+/648555
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-02-11 09:55:39 -08:00
Cherry Mui
35c0ea22a9 [release-branch.go1.24] bytes: use "subslice" instead of "substring" in doc comments
The bytes package iterators return subslices, not substrings.

Updates #61901.

Change-Id: Ida91d3e33a0f178edfe9a267861adf4f13f9a965
Reviewed-on: https://go-review.googlesource.com/c/go/+/647875
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit ff27d270c9)
Reviewed-on: https://go-review.googlesource.com/c/go/+/648095
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
2025-02-10 11:50:28 -08:00
Michael Anthony Knyszek
6d399e9da6 [release-branch.go1.24] os: hide SetFinalizer from users of Root
Currently Root embeds a root and calls SetFinalizer on &r.root. This
sets the finalizer on the outer root, which is visible to users of
os.Root, and thus they can mutate the finalizer attached to it.

This change modifies Root to not embed its inner root, but rather to
refer to it by pointer. This allows us to set the finalizer on this
independent inner object, preventing users of os.Root from changing the
finalizer. This follows the same pattern as os.File's finalizer.

Fixes #71617.

Change-Id: Ibd199bab1b3c877d5e12ef380fd4647b4e10221f
Reviewed-on: https://go-review.googlesource.com/c/go/+/647876
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
(cherry picked from commit a704d39b29)
Reviewed-on: https://go-review.googlesource.com/c/go/+/648135
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-02-10 10:48:31 -08:00
thepudds
b7b4c60585 [release-branch.go1.24] weak: prevent unsafe conversions using weak pointers
Prevent conversions between Pointer types,
like we do for sync/atomic.Pointer.

Fixes #71583

Change-Id: I20e83106d8a27996f221e6cd9d52637b0442cea4
Reviewed-on: https://go-review.googlesource.com/c/go/+/647195
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
(cherry picked from commit 8163ea1458)
Reviewed-on: https://go-review.googlesource.com/c/go/+/647435
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
2025-02-06 13:53:01 -08:00
Gopher Robot
18068cb96a [release-branch.go1.24] go1.24rc3
Change-Id: Ib3e93a2ea07a0ef1ce0989143d03c765ede8cc99
Reviewed-on: https://go-review.googlesource.com/c/go/+/646936
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
Auto-Submit: Gopher Robot <gobot@golang.org>
2025-02-05 12:35:01 -08:00
Roland Shoemaker
c43ac38b3b [release-branch.go1.24] Revert "cmd/go/internal/work: allow @ character in some -Wl, linker flags on darwin"
This reverts commit e3cd55e9d2.

This change introduced a security issue as @ flags are first resolved as
files by the darwin linker, before their meaning as flags, allowing the
flag filtering logic to be entirely bypassed.

Thanks to Juho Forsén for reporting this issue.

Fixes #71476
Fixes CVE-2025-22867

Change-Id: I3a4b4a6fc534de105d930b8ed5b9900bc94b0c4e
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1900
Reviewed-by: Russ Cox <rsc@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit cc0d725a4168f234ef38859b2d951a50a8fd94b5)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1940
Reviewed-by: Neal Patel <nealpatel@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/646995
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Bypass: Cherry Mui <cherryyz@google.com>
2025-02-05 11:57:13 -08:00
Carlos Amedee
4241f582fc [release-branch.go1.24] all: merge master (37f27fb) into release-branch.go1.24
Conflicts:

- src/cmd/go/testdata/script/goauth_netrc.txt

Merge List:

+ 2025-01-31 37f27fbecd cmd/go: enable fips test and fix caching bug
+ 2025-01-31 77d20838e9 cmd: update golang.org/x/tools to CL 645697, and revendor
+ 2025-01-30 ce7ea0a6a5 cmd/go: refine GOAUTH user parsing to be more strict
+ 2025-01-29 e81f715515 lib/fips140: freeze v1.0.0 FIPS 140 module zip file
+ 2025-01-29 4f48ad5c6b cmd/link/internal/loader: fix linknames from FIPS 140 frozen tree
+ 2025-01-29 1f58ad5d6d Revert "os: employ sendfile(2) for file-to-file copying on Linux when needed"
+ 2025-01-28 90ec9996cb crypto/pbkdf2: add keyLength limit
+ 2025-01-28 62cd7cb6cd crypto/hkdf: check error in TestFIPSServiceIndicator
+ 2025-01-28 7764c502e2 crypto/internal/sysrand: skip TestNoGetrandom without cgo
+ 2025-01-28 50455385b0 internal/coverage: fix bug in text-format coverage output with multiple packages
+ 2025-01-28 28d389ef30 internal/godebug: check error from os.ReadFile in test
+ 2025-01-28 8071f2a169 runtime: mapiter linkname compatibility layer
+ 2025-01-28 78e6f2a1c8 runtime: rename mapiterinit and mapiternext
+ 2025-01-28 4ebd5bf855 internal/goexperiment: update location of baseline experiment in comment
+ 2025-01-27 f8937cb625 archive/zip, archive/tar: writer appends slash to directory names
+ 2025-01-27 11e08d9d96 strconv: adjust comment so that gofmt doesn't mung it
+ 2025-01-27 b9872221cd crypto/internal/fips140/rsa: avoid CAST unsetting the service indicator
+ 2025-01-27 3f791c8dfb crypto/internal/fips140/aes: set FIPS 140 service indicator for CTR and CBC
+ 2025-01-27 e0aeee82f3 crypto/ecdsa: avoid needless ScalarBaseMult in s390x
+ 2025-01-27 f70aa3824b cmd/go: do not call base.fatal for an unset HOME for GOAUTH=netrc
+ 2025-01-27 475e08349d Revert "runtime: Check LSE support on ARM64 at runtime init"
+ 2025-01-27 e2e700f8b1 crypto/internal/boring: keep ECDH public key alive during cgo calls
+ 2025-01-22 608acff847 go/types: avoid importer.Default
+ 2025-01-22 9d21ef3bd4 runtime: fix the equality check in AddCleanup
+ 2025-01-22 5a46b17b5f os: force a goroutine to be scheduled on WASM
+ 2025-01-22 6fc23a3cff crypto/internal/fips140/nistec: make p256NegCond constant time on ppc64le
+ 2025-01-22 70b603f4d2 go/importer: document limitations of this API
+ 2025-01-21 f6d17c5400 net/http: update bundled golang.org/x/net/http2 [generated]
+ 2025-01-21 3aa7c5ef01 testing: fix reference to B.N in docstring
+ 2025-01-20 3f4164f508 runtime: delete out of date comment
+ 2025-01-17 40b3c0e58a internal/coverage: refactor EmitTextual in preparation for bugfix
+ 2025-01-17 87023bb27f go/types, types2: ensure deterministic output when reporting an init cycle
+ 2025-01-17 80bf7d83ed go/types, types2: remove superfluous assertion (fix build)
+ 2025-01-16 1a93e4a2cf lib/time: update to 2025a/2025a
+ 2025-01-16 0b632d26b9 cmd/internal/obj/wasm, runtime: detect wasmexport call before runtime initialization
+ 2025-01-16 6a4effa08b crypto/x509: avoid panic when parsing partial PKCS#1 private keys
+ 2025-01-16 139d6eedae cmd/go: restore netrc preferences for GOAUTH and fix domain lookup
+ 2025-01-16 2b2314e9f6 crypto/x509: properly check for IPv6 hosts in URIs
+ 2025-01-16 6783377295 net/http: persist header stripping across repeated redirects
+ 2025-01-14 368a9ec998 encoding/json: cleanup tests
+ 2025-01-14 bd80d8956f cmd/go/internal/modfetch: do not trust server to send all tags in shallow fetch
+ 2025-01-14 4fa61d6f9c cmd/api: report error in test instead of crashing
+ 2025-01-14 c5e205e928 internal/runtime/maps: re-enable some tests
+ 2025-01-14 befc43655b testing/fstest: fix function name and comment
+ 2025-01-14 c83f2ca4b3 cmd/dist: ignore packages with no Go files in BenchmarkAll
+ 2025-01-13 6da16013ba cmd/go: check go version when parsing go.mod fails
+ 2025-01-13 de9fdc7b71 syscall/js: adjust comments to that gofmt does not change them
+ 2025-01-13 17ed215958 go/types, types2: don't panic when instantiating generic alias with wrong number of type arguments
+ 2025-01-13 c53307c3fd spec: fix grammar issue
+ 2025-01-13 47a56b2b6d encoding/json: add cases to TestUnmarshal for fatal syntactic errors
+ 2025-01-13 7bb192a1c5 encoding/json: always check resulting Go value for unmarshaling
+ 2025-01-12 44a6f817ea cmd/compile: fix write barrier coalescing
+ 2025-01-10 19e923182e crypto/internal/fips140test: add hmac DRBG ACVP tests
+ 2025-01-10 7255b94920 crypto/internal/fips140test: add ML-KEM ACVP tests
+ 2025-01-09 932ec2be8d crypto/rsa: fix GenerateKey flakes for toy-sized keys
+ 2025-01-09 d0c9142ce3 runtime/pprof: hide map runtime frames from heap profiles
+ 2025-01-09 c7c4420ae4 cmd/go: clarify GODEBUG in go help environment
+ 2025-01-09 c6ab13fc43 cmd/go/internal/mmap: reslice to file size on Windows
+ 2025-01-09 f5a89dff67 crypto: fix fips140=only detection of SHA-3
+ 2025-01-08 4225c6cb37 encoding/json: improve fidelity of TestUnmarshal for Numbers
+ 2025-01-08 c87a6f932e crypto/mlkem: merge mlkem768.go and mlkem1024.go to improve godoc
+ 2025-01-08 f57a3a7c04 crypto/mlkem: add example and improve docs
+ 2025-01-08 c9afcbade7 go/types, types2: require iterator yield to return bool (work-around)
+ 2025-01-08 54693a81fd crypto/md5,crypto/sha1: apply fips140=only to Write and Sum, not New
+ 2025-01-08 0cdf8c7a8c crypto/ecdsa: apply fips140=only to deterministic ECDSA hash
+ 2025-01-08 4640e92af7 crypto/rsa: apply fips140=only to opts.Hash in SignPSS

Change-Id: I443d8d9433e7f504905b60652d3fcd975e5f674b
2025-01-31 12:45:08 -05:00
Russ Cox
37f27fbecd cmd/go: enable fips test and fix caching bug
Enable the cmd/go fips test now that v1.0.0.zip has been checked in.
Will still need to enable the alias half when the alias is checked in.

Also fix a problem that was causing spurious failures, by fixing
repeated unpackings and also disabling modindex reads of the
virtual fips140 snapshot directories.

Fixes #71491.

Change-Id: I7fa21e9bde07ff4eb6c3483e99d49316ee0ea7f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/645835
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-31 08:50:43 -08:00
Rob Findley
77d20838e9 cmd: update golang.org/x/tools to CL 645697, and revendor
go get golang.org/x/tools@9874647 # CL 645697
go mod tidy
go mod vendor

Fixes #71485

Change-Id: I72d8f82abd0c6e05f2698d8a372bf9485002d1b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/645336
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Robert Findley <rfindley@google.com>
TryBot-Bypass: Robert Findley <rfindley@google.com>
2025-01-31 08:42:32 -08:00
Sam Thanawalla
ce7ea0a6a5 cmd/go: refine GOAUTH user parsing to be more strict
This CL enhances the parsing of GOAUTH user based authentication for
improved security.

Updates: #26232

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: Ica57952924020b7bd2670610af8de8ce52dbe92f
Reviewed-on: https://go-review.googlesource.com/c/go/+/644995
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-30 13:39:38 -08:00
Filippo Valsorda
e81f715515 lib/fips140: freeze v1.0.0 FIPS 140 module zip file
make v1.0.0.zip
    make v1.0.0.test
    make updatesum

Changed the v%.zip Makefile target to use the default of origin/master,
as per its comment and intention, instead of the local master.

Change-Id: I6a6a4656c097d11b8cdc96766394c984f9c47f82
Reviewed-on: https://go-review.googlesource.com/c/go/+/644645
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-29 07:10:35 -08:00
Filippo Valsorda
4f48ad5c6b cmd/link/internal/loader: fix linknames from FIPS 140 frozen tree
blockedLinknames was updated in CL 635676 after the lib/fips140 zip
mechanism was last tested. linknames from crypto/internal/fips140/v1.0.0
need to be allowed if they'd be allowed from crypto/internal/fips140.

Change-Id: I6a6a4656022118d4739ae14831f2ad721951c192
Reviewed-on: https://go-review.googlesource.com/c/go/+/645195
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-01-29 06:30:36 -08:00
Michael Pratt
1f58ad5d6d Revert "os: employ sendfile(2) for file-to-file copying on Linux when needed"
This reverts CL 603295.

Reason for revert: can cause child exit_group to hang.

This is not a clean revert. CL 603098 did a major refactoring of the
tests. That refactor is kept, just the sendfile-specific tests are
dropped from the linux tests.

Fixes #71375.

Change-Id: Ic4d6535759667c69a44bd9281bbb33d5b559f591
Reviewed-on: https://go-review.googlesource.com/c/go/+/644895
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Andy Pan <panjf2000@gmail.com>
2025-01-29 06:29:28 -08:00
Roland Shoemaker
90ec9996cb crypto/pbkdf2: add keyLength limit
As specified by RFC 8018. Also prevent unexpected overflows on 32 bit
systems.

Change-Id: I50c4a177b7d1ebb15f9b3b96e515d93f19d3f68e
Reviewed-on: https://go-review.googlesource.com/c/go/+/644122
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2025-01-28 18:20:16 -08:00
Ian Lance Taylor
62cd7cb6cd crypto/hkdf: check error in TestFIPSServiceIndicator
I don't know why this code calls panic(err) rather than
t.Fatal(err), but I didn't change it.

Change-Id: I9aa7503c604bd8d4f27cc295e2ec742446906df9
Reviewed-on: https://go-review.googlesource.com/c/go/+/643995
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2025-01-28 17:24:40 -08:00
Filippo Valsorda
7764c502e2 crypto/internal/sysrand: skip TestNoGetrandom without cgo
crypto/internal/sysrand/internal/seccomp needs cgo to disable getrandom.
Before this change, "CGO_ENABLED=0 go test crypto/internal/sysrand"
would fail on Linux.

Change-Id: I6a6a465685b480c846e5479da0659e90ab7f3a65
Reviewed-on: https://go-review.googlesource.com/c/go/+/642737
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-01-28 14:19:31 -08:00
Than McIntosh
50455385b0 internal/coverage: fix bug in text-format coverage output with multiple packages
In ProcessCoverTestDir pass the selected set of packages to
EmitTextual in addition to EmitPercent, so that when we have runs with
multiple packages selected but without -coverpkg, text format output
for package P was incorrectly including output for P's covered
dependencies. This is in effect an extension of the fix for issue
65570.

Includes a cmd/go script test to verify correct behavior; ideally it
would be nice to locate this test in .../internal/coverage somewhere
but at the moment script tests are only supported for
cmd/{go,compile,link}.

Updates #65570.
Fixes #70244.

Change-Id: Ia0bb10155353aa0f2ead46e81a2aaa71bde4ef82
Reviewed-on: https://go-review.googlesource.com/c/go/+/627316
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Than McIntosh <thanm@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-28 12:45:25 -08:00
Ian Lance Taylor
28d389ef30 internal/godebug: check error from os.ReadFile in test
Change-Id: I4770443c8eaa12add2e04cbf9d18ebfbbd851162
Reviewed-on: https://go-review.googlesource.com/c/go/+/643259
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-28 11:38:43 -08:00
Michael Pratt
8071f2a169 runtime: mapiter linkname compatibility layer
This CL reintroduces the various mapiter* linkname functions with a
compatibility layer that is careful to maintain compatibility with users
of the linkname.

The wrappers are straightforward. Callers of these APIs get an extra
layer of indirection, with their hiter containing a pointer to the real
maps.Iter. These users will take a minor performance hit from the extra
allocation, but this approach should have good long-term
maintainability.

Fixes #71408.

Change-Id: I6a6a636c7574bbd670ff5243dfeb63dfba6dc611
Reviewed-on: https://go-review.googlesource.com/c/go/+/643899
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-28 11:10:41 -08:00
Michael Pratt
78e6f2a1c8 runtime: rename mapiterinit and mapiternext
mapiterinit allows external linkname. These users must allocate their
own iter struct for initialization by mapiterinit. Since the type is
unexported, they also must define the struct themselves. As a result,
they of course define the struct matching the old hiter definition (in
map_noswiss.go).

The old definition is smaller on 32-bit platforms. On those platforms,
mapiternext will clobber memory outside of the caller's allocation.

On all platforms, the pointer layout between the old hiter and new
maps.Iter does not match. Thus the GC may miss pointers and free
reachable objects early, or it may see non-pointers that look like heap
pointers and throw due to invalid references to free objects.

To avoid these issues, we must keep mapiterinit and mapiternext with the
old hiter definition. The most straightforward way to do this is to use
mapiterinit and mapiternext as a compatibility layer between the old and
new iter types.

The first step to that is to move normal map use off of these functions,
which is what this CL does.

Introduce new mapIterStart and mapIterNext functions that replace the
former functions everywhere in the toolchain. These have the same
behavior as the old functions.

This CL temporarily makes the old functions throw to ensure we don't
have hidden dependencies on them. We cannot remove them entirely because
GOEXPERIMENT=noswissmap still uses the old names, and internal/goobj
requires all builtins to exist regardless of GOEXPERIMENT. The next CL
will introduce the compatibility layer.

I want to avoid using linkname between runtime and reflect, as that
would also allow external linknames. So mapIterStart and mapIterNext are
duplicated in reflect, which can be done trivially, as it imports
internal/runtime/maps.

For #71408.

Change-Id: I6a6a636c6d4bd1392618c67ca648d3f061afe669
Reviewed-on: https://go-review.googlesource.com/c/go/+/643898
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-01-28 10:54:43 -08:00
Ian Lance Taylor
4ebd5bf855 internal/goexperiment: update location of baseline experiment in comment
It moved in CL 310731.

Change-Id: I97340848b55e327d3b25949ec3850aec33448bbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/644955
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2025-01-28 10:44:40 -08:00
yincong
f8937cb625 archive/zip, archive/tar: writer appends slash to directory names
Fixes #71235

Change-Id: I62aebb9d421db0e4b57ad5cae25c70f47aa5f8f9
GitHub-Last-Rev: 6e0fba07dd
GitHub-Pull-Request: golang/go#71239
Reviewed-on: https://go-review.googlesource.com/c/go/+/642375
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2025-01-27 20:20:09 -08:00
Ian Lance Taylor
11e08d9d96 strconv: adjust comment so that gofmt doesn't mung it
Change-Id: I7fe5c6a0521d3c597eae0f3568942df1db9370b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/642497
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-27 13:16:45 -08:00
Filippo Valsorda
b9872221cd crypto/internal/fips140/rsa: avoid CAST unsetting the service indicator
Without fipsApproved set, when the CAST runs it sets the service
indicator to false for the whole span.

This is a very late Go 1.24 change, but it is necessary for the frozen
FIPS module, and doesn't impact anything else than the FIPS status
indicator value.

Change-Id: I6a6a46567818135158c3c252b5480431a190572b
Reviewed-on: https://go-review.googlesource.com/c/go/+/644636
Auto-Submit: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
2025-01-27 12:16:32 -08:00
Filippo Valsorda
3f791c8dfb crypto/internal/fips140/aes: set FIPS 140 service indicator for CTR and CBC
This is a very late Go 1.24 change, but it is necessary for the frozen
FIPS module, and doesn't impact anything else than the FIPS status
indicator value.

Change-Id: I6a6a4656f1ac94ac46d631c90a206ac8b6ddcf4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/644635
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-01-27 12:16:30 -08:00
Filippo Valsorda
e0aeee82f3 crypto/ecdsa: avoid needless ScalarBaseMult in s390x
We are running the (slow on s390x) ScalarBaseMult and then discarding
the point because we are reusing randomPoint.

Copied the function 1:1 removing the point computation.

Change-Id: I6a6a46561633ab3bbbaef804481f6c5da15fe2fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/644775
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-01-27 12:15:18 -08:00
Sam Thanawalla
f70aa3824b cmd/go: do not call base.fatal for an unset HOME for GOAUTH=netrc
This CL silences errors caused by GOAUTH=netrc and HOME being unset.
Instead, we log the error if the -x flag is set.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: Ibd323769f3562c169ebf559e060e9afbb63047bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/643917
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-27 10:46:57 -08:00
Cherry Mui
475e08349d Revert "runtime: Check LSE support on ARM64 at runtime init"
This reverts CL 610195.

Reason for revert: SIGILL on macOS. See issue #71411.

Updates #69124, #60905.
Fixes #71411.

Change-Id: Ie0624e516dfb32fb13563327bcd7f557e5cba940
Reviewed-on: https://go-review.googlesource.com/c/go/+/644695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
2025-01-27 09:58:29 -08:00
Roland Shoemaker
e2e700f8b1 crypto/internal/boring: keep ECDH public key alive during cgo calls
This prevents a possible use-after-free.

Change-Id: I02488206660d38cac5ebf2f11009907ae8f22157
Reviewed-on: https://go-review.googlesource.com/c/go/+/644119
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2025-01-27 09:30:26 -08:00
Alan Donovan
608acff847 go/types: avoid importer.Default
It uses a throwaway FileSet, so all position info is
wrong, and potentially misleading.

(Various other helpers in go/types testing also use a
throwaway FileSet, and should really accept it as a parameter.)

Fixes #71272

Change-Id: I9d899b987837b4041a299aad5ec266cb4f5d125c
Reviewed-on: https://go-review.googlesource.com/c/go/+/643777
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2025-01-22 10:13:04 -08:00
Carlos Amedee
9d21ef3bd4 runtime: fix the equality check in AddCleanup
This fixes the check that ensures that arg is not equal to ptr in
AddCleanup. This also changes any use of throw to panic in AddCleanup.

Fixes #71316

Change-Id: Ie5a3e0163b254dff44b7fefedf75207ba587b771
Reviewed-on: https://go-review.googlesource.com/c/go/+/643655
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-22 09:26:33 -08:00
Carlos Amedee
5a46b17b5f os: force a goroutine to be scheduled on WASM
The TestRootConcurrentClose test can fail when GOARCH=WASM because of
goroutine starvation. The spawned goroutine will sometimes run in a
loop and never have the main goroutine be scheduled. This causes the
test to fail due to a timeout. This change forces the goroutine to be
scheduled with each iteration of the loop when  GOARCH=WASM.

For #71134
Fixes #71117

Change-Id: I4fb68907c9ac3b33bd0572d5e5db2974a3379191
Reviewed-on: https://go-review.googlesource.com/c/go/+/640195
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Carlos Amedee <carlos@golang.org>
2025-01-22 09:23:24 -08:00
Roland Shoemaker
6fc23a3cff crypto/internal/fips140/nistec: make p256NegCond constant time on ppc64le
Remove the branching instruction from p256NegCond which made it variable
time. The technique used matches that used in p256MovCond.

Fixes #71383
Fixes CVE-2025-22866

Change-Id: Ibc2a46814d856cbbdaf6cc0c5a415ed5d42ca793
Reviewed-on: https://go-review.googlesource.com/c/go/+/643735
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-22 08:18:42 -08:00
Alan Donovan
70b603f4d2 go/importer: document limitations of this API
Arguably it should be deprecated, but that's a process.

Updates #71272

Change-Id: I69de1f9709c45dfea0fe67d96a7bd15d3df4e2f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/643795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2025-01-22 08:03:24 -08:00
Dmitri Shuralyov
f6d17c5400 net/http: update bundled golang.org/x/net/http2 [generated]
Pull in x/net CL 642606 and CL 643256 and regenerate h2_bundle.go:

	http2: disable extended CONNECT by default
	http2: encode :protocol pseudo-header before regular headers

For #36905.
Fixes #70728.
Fixes #71128.

[git-generate]
go install golang.org/x/build/cmd/updatestd@latest
go install golang.org/x/tools/cmd/bundle@latest
updatestd -goroot=$(pwd) -branch=internal-branch.go1.24-vendor

Change-Id: Id853cb96f8fc410956666f5c3ab4c5889c703503
Reviewed-on: https://go-review.googlesource.com/c/go/+/642398
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2025-01-21 13:03:18 -08:00
Kir Kolyshkin
3aa7c5ef01 testing: fix reference to B.N in docstring
Currently, a documentation reference to a struct member (such as [B.N])
does not result in it being rendered as a link, and thus the square
brackets remain in the rendered documentation which is mildly confusing.

The issue can be seen at
https://pkg.go.dev/testing@master#hdr-b_N_style_benchmarks

Remove the square brackets to fix.

Change-Id: Id374fd2085bd511018220c5d663650f89672302e
Reviewed-on: https://go-review.googlesource.com/c/go/+/643496
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2025-01-21 04:36:54 -08:00
Bill Morgan
3f4164f508 runtime: delete out of date comment
Fixes #71328

Change-Id: I5827255bf1f53b8fc4a84fa1accb4089f73d5e8a
GitHub-Last-Rev: 26f4eab182
GitHub-Pull-Request: golang/go#71337
Reviewed-on: https://go-review.googlesource.com/c/go/+/643456
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2025-01-20 09:25:11 -08:00
Than McIntosh
40b3c0e58a internal/coverage: refactor EmitTextual in preparation for bugfix
Refactor cformat.EmitTextual to accept a package filter (list of
packages to report). This is a no-op in terms of exposed coverage
functionality, but we will need this feature in a subsequent patch.

Updates #70244.

Change-Id: I1e6bcbfb5e68187d4d69d54b667e97bc1fdfa2d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/627315
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-17 08:40:47 -08:00
Wingrez
87023bb27f go/types, types2: ensure deterministic output when reporting an init cycle
Fixes #71254

Change-Id: Ie3bad281403c8ff6215e03d92760b9a378714cee
GitHub-Last-Rev: 9b804a7842421dca6a97c57ce18523b593b0817d
GitHub-Pull-Request: golang/go#71264
Reviewed-on: https://go-review.googlesource.com/c/go/+/642396
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-01-17 08:22:41 -08:00
Robert Griesemer
80bf7d83ed go/types, types2: remove superfluous assertion (fix build)
Remove an assertion that was overly restrictive and hard to get
correct under all circumstances (i.e., in the presence of incorrect)
code. This matches the code for *Named types in that specific switch.

Fixes #71284.

Change-Id: Ifccf8b73dc70cac9cb1c8b24946d16851d511454
Reviewed-on: https://go-review.googlesource.com/c/go/+/643255
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-17 06:41:53 -08:00
Tobias Klauser
1a93e4a2cf lib/time: update to 2025a/2025a
Commit generated by update.bash.

For #22487.

Change-Id: Ie5002725b9add75fd22b29ea3a7addbe0151b25c
Reviewed-on: https://go-review.googlesource.com/c/go/+/642020
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-16 13:23:33 -08:00
Cherry Mui
0b632d26b9 cmd/internal/obj/wasm, runtime: detect wasmexport call before runtime initialization
If a wasmexport function is called from the host before
initializing the Go Wasm module, currently it will likely fail
with a bounds error, because the uninitialized SP is 0, and any
SP decrement will make it out of bounds.

As at least some Wasm runtime doesn't call _initialize by default,
This error can be common. And the bounds error looks confusing to
the users. Therefore, we detect this case and emit a clearer error.

Fixes #71240.
Updates #65199.

Change-Id: I107095f08c76cdceb7781ab0304218eab7029ab6
Reviewed-on: https://go-review.googlesource.com/c/go/+/643115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-01-16 12:14:23 -08:00
Gopher Robot
8a4c24f9bb [release-branch.go1.24] go1.24rc2
Change-Id: I37362fe37c47078c17f3f6f610d8ca7664985bd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/643157
Auto-Submit: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-01-16 12:13:48 -08:00
Filippo Valsorda
3de5aca7d0 [release-branch.go1.24] crypto/x509: avoid panic when parsing partial PKCS#1 private keys
These keys are off-spec, but have historically been accepted by
ParsePKCS1PrivateKey.

Thanks to Philippe Antoine (Catena cyber) for reporting this issue.

Fixes #71216
Fixes CVE-2025-22865

Change-Id: I6a6a46564156fa32e29e8d6acbec3fbac47c7352
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1820
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
(cherry picked from commit 36c6c8b6957e155770461fd710aea9477ef3bc88)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1841
Reviewed-on: https://go-review.googlesource.com/c/go/+/643102
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-16 11:36:09 -08:00
Sam Thanawalla
8336dfde70 [release-branch.go1.24] cmd/go: restore netrc preferences for GOAUTH and fix domain lookup
Store netrc lines into the credential map backward so that earlier lines
take priority over later lines. This matches Go 1.23 netrc lookup which
stopped at the first match it found.
Additionally, this fixes a security issue related to domain parsing
which could have allowed servers to read credentials belonging to other
servers. The fix was to switch from using path.Dir(currentPrefix) to
strings.Cut(currentPrefix, "/")

Thanks to Juho Forsén of Mattermost for reporting this issue.

Fixes #71249
Fixes CVE-2024-45340

Change-Id: I175a00d6d7f4d31c9e4d79b7cf1c2a0ad35b2781
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1781
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 76833d221aa3ccc978b6f41bd24e26babf771375)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1840
Reviewed-on: https://go-review.googlesource.com/c/go/+/643101
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-01-16 11:36:07 -08:00
Damien Neil
6b60550504 [release-branch.go1.24] net/http: persist header stripping across repeated redirects
When an HTTP redirect changes the host of a request, we drop
sensitive headers such as Authorization from the redirected request.
Fix a bug where a chain of redirects could result in sensitive
headers being sent to the wrong host:

  1. request to a.tld with Authorization header
  2. a.tld redirects to b.tld
  3. request to b.tld with no Authorization header
  4. b.tld redirects to b.tld
  3. request to b.tld with Authorization header restored

Thanks to Kyle Seely for reporting this issue.

For #70530
Fixes #71212
Fixes CVE-2024-45336

Change-Id: Ia58a2e10d33d6b0cc7220935e771450e5c34de72
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1641
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
(cherry picked from commit 2889169b87a61f1218a02994feb80fd3d8bfa87c)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1766
Reviewed-on: https://go-review.googlesource.com/c/go/+/643100
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-01-16 11:36:03 -08:00
Roland Shoemaker
468fad45a2 [release-branch.go1.24] crypto/x509: properly check for IPv6 hosts in URIs
When checking URI constraints, use netip.ParseAddr, which understands
zones, unlike net.ParseIP which chokes on them. This prevents zone IDs
from mistakenly satisfying URI constraints.

Thanks to Juho Forsén of Mattermost for reporting this issue.

For #71156
Fixes #71209
Fixes CVE-2024-45341

Change-Id: Iecac2529f3605382d257996e0fb6d6983547e400
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1700
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
(cherry picked from commit 22ca55d396ba801e6ae9b2bd67a059fcb30562fd)
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1800
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/643099
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-01-16 11:08:59 -08:00
Filippo Valsorda
6a4effa08b crypto/x509: avoid panic when parsing partial PKCS#1 private keys
These keys are off-spec, but have historically been accepted by
ParsePKCS1PrivateKey.

Thanks to Philippe Antoine (Catena cyber) for reporting this issue.

Fixes #71216
Fixes CVE-2025-22865

Change-Id: I6a6a46564156fa32e29e8d6acbec3fbac47c7352
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1820
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/643098
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-01-16 11:01:33 -08:00
Sam Thanawalla
139d6eedae cmd/go: restore netrc preferences for GOAUTH and fix domain lookup
Store netrc lines into the credential map backward so that earlier lines
take priority over later lines. This matches Go 1.23 netrc lookup which
stopped at the first match it found.
Additionally, this fixes a security issue related to domain parsing
which could have allowed servers to read credentials belonging to other
servers. The fix was to switch from using path.Dir(currentPrefix) to
strings.Cut(currentPrefix, "/")

Thanks to Juho Forsén of Mattermost for reporting this issue.

Fixes #71249
Fixes CVE-2024-45340

Change-Id: I175a00d6d7f4d31c9e4d79b7cf1c2a0ad35b2781
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1781
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/643097
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-01-16 11:01:32 -08:00
Roland Shoemaker
2b2314e9f6 crypto/x509: properly check for IPv6 hosts in URIs
When checking URI constraints, use netip.ParseAddr, which understands
zones, unlike net.ParseIP which chokes on them. This prevents zone IDs
from mistakenly satisfying URI constraints.

Thanks to Juho Forsén of Mattermost for reporting this issue.

Fixes #71156
Fixes CVE-2024-45341

Change-Id: Iecac2529f3605382d257996e0fb6d6983547e400
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1700
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/643096
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-16 10:58:56 -08:00
Damien Neil
6783377295 net/http: persist header stripping across repeated redirects
When an HTTP redirect changes the host of a request, we drop
sensitive headers such as Authorization from the redirected request.
Fix a bug where a chain of redirects could result in sensitive
headers being sent to the wrong host:

  1. request to a.tld with Authorization header
  2. a.tld redirects to b.tld
  3. request to b.tld with no Authorization header
  4. b.tld redirects to b.tld
  3. request to b.tld with Authorization header restored

Thanks to Kyle Seely for reporting this issue.

For #70530
Fixes CVE-2024-45336

Change-Id: Ia58a2e10d33d6b0cc7220935e771450e5c34de72
Reviewed-on: https://go-internal-review.googlesource.com/c/go/+/1641
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Commit-Queue: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/643095
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2025-01-16 10:58:54 -08:00
Joe Tsai
368a9ec998 encoding/json: cleanup tests
Perform minor cleanups in tests to improve printout of diffs
and/or follow modern coding style.

This reduces the amount of diffs between v1 and the v2 prototype.

Change-Id: I019bb9642e2135f2fa3eac6abfa6df91c397aa82
Reviewed-on: https://go-review.googlesource.com/c/go/+/642257
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-14 14:54:07 -08:00
Russ Cox
bd80d8956f cmd/go/internal/modfetch: do not trust server to send all tags in shallow fetch
Newer git versions (at least git 2.47.1) do not send all the matching tags
for a shallow fetch of a specific hash anymore. The go command assumes
that git servers do this. Since that assumption is broken, use the local
copy of the remote refs list to augment the tags sent by the server.
This makes the cmd/go/internal/modfetch tests pass again with newer git.

Fixes #71261.

Change-Id: I9fd4f3fd7beeb68a522938599f8f3acd887d0b26
Reviewed-on: https://go-review.googlesource.com/c/go/+/642437
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2025-01-14 10:07:07 -08:00
Russ Cox
4fa61d6f9c cmd/api: report error in test instead of crashing
https://ci.chromium.org/ui/inv/build-8725798219051312433/test-results?sortby=&groupby=
shows a mysterious failure with this stack:

	=== RUN   BenchmarkAll
	BenchmarkAll
	panic: runtime error: invalid memory address or nil pointer dereference
	[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7c497f]

	goroutine 20 gp=0xc000004000 m=7 mp=0xc000182808 [running]:
	panic({0x81c5e0?, 0xabc6b0?})
		/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/panic.go:806 +0x168 fp=0xc00c7ffce0 sp=0xc00c7ffc30 pc=0x4ad4c8
	runtime.panicmem(...)
		/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/panic.go:262
	runtime.sigpanic()
		/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/signal_unix.go:925 +0x359 fp=0xc00c7ffd40 sp=0xc00c7ffce0 pc=0x4af6d9
	cmd/api.(*Walker).export(0xc000034100, 0x0)
		/home/swarming/.swarming/w/ir/x/w/goroot/src/cmd/api/main_test.go:193 +0x3f fp=0xc00c7ffe08 sp=0xc00c7ffd40 pc=0x7c497f
	cmd/api.BenchmarkAll(0xc000214288)
		/home/swarming/.swarming/w/ir/x/w/goroot/src/cmd/api/api_test.go:205 +0x207 fp=0xc00c7ffeb0 sp=0xc00c7ffe08 pc=0x7c1c07
	testing.(*B).runN(0xc000214288, 0x1)
		/home/swarming/.swarming/w/ir/x/w/goroot/src/testing/benchmark.go:202 +0x291 fp=0xc00c7fff78 sp=0xc00c7ffeb0 pc=0x57e611
	testing.(*B).run1.func1()
		/home/swarming/.swarming/w/ir/x/w/goroot/src/testing/benchmark.go:224 +0x7c fp=0xc00c7fffe0 sp=0xc00c7fff78 pc=0x57f11c
	runtime.goexit({})
		/home/swarming/.swarming/w/ir/x/w/goroot/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc00c7fffe8 sp=0xc00c7fffe0 pc=0x4b4a61
	created by testing.(*B).run1 in goroutine 1
		/home/swarming/.swarming/w/ir/x/w/goroot/src/testing/benchmark.go:217 +0x173

So import_ must have returned an error, making pkg nil. Show that error.
Also do the same at the other calls to import_.

Change-Id: Ie782571c4bda3334a86b303f61969cf1cc7d3c32
Reviewed-on: https://go-review.googlesource.com/c/go/+/642438
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2025-01-14 10:06:18 -08:00
Keith Randall
c5e205e928 internal/runtime/maps: re-enable some tests
Re-enable tests for stack-allocated maps and fast map accessors.
Those are implemented now.

Update #54766

Change-Id: I8c019702bd9fb077b2fe3f7c78e8e9e10d2263a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/642376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
2025-01-14 09:55:06 -08:00
cuishuang
befc43655b testing/fstest: fix function name and comment
Change-Id: I17bc68a2e3a96d0dc3d9ddcad40149df37fc4839
Reviewed-on: https://go-review.googlesource.com/c/go/+/642198
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-01-14 09:43:06 -08:00
Ian Lance Taylor
c83f2ca4b3 cmd/dist: ignore packages with no Go files in BenchmarkAll
This case recently started happening on the builders.
The synctest experiment was recently enabled for some targets (CL 642422).
This caused the list of standard packages to include testing/synctest.
However, BenchmarkAll tests for all configurations;
some did not include testing/synctest. That caused the test to crash.

Change-Id: Icade10af147c2e2bcbac25bf744919083db3e70f
Reviewed-on: https://go-review.googlesource.com/c/go/+/642397
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2025-01-14 07:27:27 -08:00
Sean Liao
6da16013ba cmd/go: check go version when parsing go.mod fails
Fixes #70979

Change-Id: I6597fe178eed34702eea6cba4eec5174c9203458
Reviewed-on: https://go-review.googlesource.com/c/go/+/639115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-01-13 11:19:14 -08:00
Ian Lance Taylor
de9fdc7b71 syscall/js: adjust comments to that gofmt does not change them
Change-Id: Ic410375987c0f376d0a975e5a6284de10f08b741
Reviewed-on: https://go-review.googlesource.com/c/go/+/642495
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-13 11:11:07 -08:00
Robert Griesemer
17ed215958 go/types, types2: don't panic when instantiating generic alias with wrong number of type arguments
The existing code assumed the type argument count check in
Checker.instance couldn't fail for generic alias types
(matching the code for generic signatures), but it actually
can.

Adjust the code accordingly and document that the result of
Checker.instance may be invalid.

Review all call sites of Checker.instance and make sure we
handle the failure case, or document the code accordingly
(in the case of generic signatures).

When reporting an type argument count error, use the alias
name rather than the alias string representation to match
the error we get for a non-alias type.

While at it, update the manual.go template for ease of use.

Fixes #71198.

Change-Id: I6d19ec6418440e9b49574a2d7dd9825e0af6c2fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/641857
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-01-13 10:30:43 -08:00
Oleksandr Redko
c53307c3fd spec: fix grammar issue
Change-Id: If4d3b3965762c8979d304a82493c9eb1068ee13c
Reviewed-on: https://go-review.googlesource.com/c/go/+/642037
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-01-13 08:27:58 -08:00
Joe Tsai
47a56b2b6d encoding/json: add cases to TestUnmarshal for fatal syntactic errors
The presence of a syntax error in the input immediately unmarshaling
before unmarshaling into the underlying value.
Otherwise, semantic errors are generally lazily reported and
allow unmarshaling to continue on.

Change-Id: Icf1cfc684e415312d9c8bf739c396ede15299d7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/642295
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-01-13 08:27:22 -08:00
Joe Tsai
7bb192a1c5 encoding/json: always check resulting Go value for unmarshaling
Even if an error occurs during unmarshal, check the resulting Go value.
The documented API specifies no guarantees on how much of a Go value
will be populated when an error occurs and the "json" package
is technically not bounded by the Go compatibility agreement
to ensure this behavior never changes.

However, there is still value in running checks for
what exactly what is partially mutated in the event of an error
even if this is not guaranteed behavior.

Change-Id: I6e923a31f77768a14c4adfb0d37dbeee5807a4a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/642275
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-13 08:27:19 -08:00
Keith Randall
44a6f817ea cmd/compile: fix write barrier coalescing
We can't coalesce a non-WB store with a subsequent Move, as the
result of the store might be the source of the move.

There's a simple codegen test. Not sure how we might do a real test,
as all the repro's I've come up with are very expensive and unreliable.

Fixes #71228

Change-Id: If18bf181a266b9b90964e2591cd2e61a7168371c
Reviewed-on: https://go-review.googlesource.com/c/go/+/642197
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2025-01-12 22:49:39 -08:00
Daniel McCarney
19e923182e crypto/internal/fips140test: add hmac DRBG ACVP tests
Adds ACVP test coverage for the hmacDRBG algorithm based on the NIST
spec:
  https://pages.nist.gov/ACVP/draft-vassilev-acvp-drbg.html#section-7.2

The HMAC DRBG algorithm in our fips module is a minimal implementation
tailored for use for generating ECDSA nonces and so lives in
crypto/internal/fips140/ecdsa.

In order to be testable by crypto/internal/fips140test this changeset
exports a ecdsa.TestingOnlyNewDrbg() constructor to support the ACVP use-case.
All FIPS-compatible SHA2 and SHA3 digests are tested.

The ACVP capability registration is customized to match the limited
capabilities of our ecdsa-focused impl. Most notably:

  * reseedImplemented is false - we expect this impl to be invoked
    only once or twice per instantiation and do not support explicit
    reseeding.
  * predResistanceEnabled is false - this requires reseeding.
  * Per mode:
    * derFuncEnabled is always false - this is only used by ctrDRBG.
    * additionalInputLen is 0 for all modes - this is only used with
      preResistanceEnabled.

The other capability values are chosen based on Table 4:
  https://pages.nist.gov/ACVP/draft-vassilev-acvp-drbg.html#section-7.4

Updates #69642

Change-Id: Ia58979d691f912e2ed739a05efb719f580fbbf89
Reviewed-on: https://go-review.googlesource.com/c/go/+/639775
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2025-01-10 14:12:31 -08:00
Daniel McCarney
7255b94920 crypto/internal/fips140test: add ML-KEM ACVP tests
Adds ACVP test coverage for ML-KEM based on the NIST spec:

  https://pages.nist.gov/ACVP/draft-celi-acvp-ml-kem.html

Notably we need to update the BoringSSL module version because the
acvptool was only recently updated to support testing ML-KEM.

A few non-test updates are also required for the
crypto/internal/fips140/mlkem package:

* For keyGen tests a new ExpandedBytes768() function is added that
  converts a DecapsualtionKey768 struct into the expanded NIST
  serialization. The existing Bytes() function returns the
  key's seed, while ACVP testing requires the more cumbersome format.
* For decap tests a new TestingOnlyNewDecapsulationKey768()
  constructor is added to produce a DecapsulationKey768 struct from the
  expanded FIPS 203 serialization provided by the ACVP test vector. The
  pre-existing NewDecapsulationKey768() function expects a seed as
  input.

The generate1024.go helper is updated to translate the above changes to
the generated mlkem1024.go implementation.

Both of these new functions are exclusively for ACVP usage and so not
present in the public mlkem API. End users should always prefer to work
with seeds.

Updates #69642

Change-Id: I79784f8a8db00a2ddefdcece4b8de50b033c8f69
Reviewed-on: https://go-review.googlesource.com/c/go/+/637439
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-10 04:37:57 -08:00
Filippo Valsorda
932ec2be8d crypto/rsa: fix GenerateKey flakes for toy-sized keys
Could have fixed this some other ways, including inside the FIPS 140-3
module, but this is small and self-contained, clearly not affecting
production non-toy key sizes. This late in the freeze, a surgical fix
felt best.

Fixes #71185

Change-Id: I6a6a465641357c9d6b076c8a520b221be4210ed5
Reviewed-on: https://go-review.googlesource.com/c/go/+/641755
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2025-01-09 15:08:34 -08:00
Michael Pratt
d0c9142ce3 runtime/pprof: hide map runtime frames from heap profiles
Heap profiles hide "runtime" frames like runtime.mapassign. This broke
in 1.24 because the map implementation moved to internal/runtime/maps,
and runtime/pprof only considered literal "runtime." when looking for
runtime frames.

It would be nice to use cmd/internal/objabi.PkgSpecial to find runtime
packages, but that is hidden away in cmd.

Fixes #71174.

Change-Id: I6a6a636cb42aa17539e47da16854bd3fd8cb1bfe
Reviewed-on: https://go-review.googlesource.com/c/go/+/641775
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2025-01-09 13:59:08 -08:00
Sean Liao
c7c4420ae4 cmd/go: clarify GODEBUG in go help environment
Fixes #37004
Fixes #50444

Change-Id: I7dd5a8c9bd0a2122ff38508cf509369d6d8ad599
Reviewed-on: https://go-review.googlesource.com/c/go/+/632177
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2025-01-09 12:24:58 -08:00
Michael Matloob
c6ab13fc43 cmd/go/internal/mmap: reslice to file size on Windows
The Mmap function returns a Data struct containing a slice with the
mapped contents of the file. Before this change, on Windows, the slice
contained the contents of all the pages of the mapping, including past
the end of the file. Re-slice the slice to the length of the file (if
if the slice is longer) so that the slice contains only the data in the
file.

For #71059

Change-Id: I389b752505b6fa1252b5c6d836a37bc7e662a45d
Reviewed-on: https://go-review.googlesource.com/c/go/+/640155
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-09 11:44:05 -08:00
Filippo Valsorda
f5a89dff67 crypto: fix fips140=only detection of SHA-3
Both fips140only and the service indicator checks in
crypto/internal/fips140/... expect to type assert to
crypto/internal/fips140/{sha256,sha512,sha3}.Digest.

However, crypto/sha3 returns a wrapper concrete type around sha3.Digest.

Add a new fips140hash.Unwrap function to turn the wrapper into the
underlying sha3.Digest, and use it consistently before calling into
fips140only or the FIPS 140-3 module.

In crypto/rsa, also made the fips140only checks apply consistently after
the Go+BoringCrypto shims, so we can instantiate the hash, and avoid
having to wrap the New function. Note that fips140=only is incompatible
with Go+BoringCrypto.

Fixes #70879

Change-Id: I6a6a4656ec55c3e13f6cbfadb9cf89c0f9183bdc
Reviewed-on: https://go-review.googlesource.com/c/go/+/640855
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-09 06:18:54 -08:00
Joe Tsai
4225c6cb37 encoding/json: improve fidelity of TestUnmarshal for Numbers
In particular, cover the behavior of unmarshaling a JSON string
into a Number type regardless of whether the `string` option
is specified or not.

Change-Id: Ibc55f16860442240bcfeea1fd51aaa76f7e50f67
Reviewed-on: https://go-review.googlesource.com/c/go/+/641416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-01-08 14:37:21 -08:00
Filippo Valsorda
c87a6f932e crypto/mlkem: merge mlkem768.go and mlkem1024.go to improve godoc
The constants appeared badly ordered and grouped in the godoc before

    const (
        CiphertextSize1024 = 1568
        EncapsulationKeySize1024 = 1568
    )
    const (
        SharedKeySize = 32
        SeedSize = 64
        CiphertextSize768 = 1088
        EncapsulationKeySize768 = 1184
    )

while now they are a single group with the good size first

    const (
        SharedKeySize = 32
        SeedSize = 64
        CiphertextSize768 = 1088
        EncapsulationKeySize768 = 1184
        CiphertextSize1024 = 1568
        EncapsulationKeySize1024 = 1568
    )

No code changes.

Change-Id: I6a6a4656961b1e8c8bca3992aafa33e0575af8a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/640997
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
2025-01-08 14:34:45 -08:00
Filippo Valsorda
f57a3a7c04 crypto/mlkem: add example and improve docs
Change-Id: I6a6a46565f9135d8f18bf219e5b76d5957df5ab0
Reviewed-on: https://go-review.googlesource.com/c/go/+/641295
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-01-08 14:30:30 -08:00
Robert Griesemer
c9afcbade7 go/types, types2: require iterator yield to return bool (work-around)
The original implementation of the type checkers accepted any boolean
result type for yield, but the compiler's front-end had a problem with
it (#71131).

As a temporary fix (for 1.24), adjust the type checkers to insist on the
spec's literal wording and avoid the compiler panic.

Fixes #71131.
For #71164.

Change-Id: Ie25f9a892e58b5e489d399b0bce2d0af55dc3c48
Reviewed-on: https://go-review.googlesource.com/c/go/+/640599
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-08 13:54:54 -08:00
Filippo Valsorda
54693a81fd crypto/md5,crypto/sha1: apply fips140=only to Write and Sum, not New
New is called to get a Hash which can then be rejected with an error
(instead of a panic) from fips140only.ApprovedHash.

Also, it's reasonable to call New().Size() and then not use the hash.

Change-Id: I6a6a4656c43528d169c4b28c8b6de48448236d4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/641317
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-08 11:44:28 -08:00
Filippo Valsorda
0cdf8c7a8c crypto/ecdsa: apply fips140=only to deterministic ECDSA hash
Change-Id: I6a6a46567b1eaaef080ac0994afa83db2624a75a
Reviewed-on: https://go-review.googlesource.com/c/go/+/641316
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-01-08 11:37:47 -08:00
Filippo Valsorda
4640e92af7 crypto/rsa: apply fips140=only to opts.Hash in SignPSS
Change-Id: I6a6a46569bd364b36f83b9aef640eca94e045173
Reviewed-on: https://go-review.googlesource.com/c/go/+/641315
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
2025-01-08 11:37:45 -08:00
Michael Pratt
e06b6fc58d [release-branch.go1.24] all: merge master (e966a27) into release-branch.go1.24
Merge List:

+ 2025-01-08 e966a2773c crypto/internal/fips140/drbg: avoid global lock on rand state

Change-Id: I1ca8f6bf2ba14ff3d5c4183a26cbd51ac20dad0a
2025-01-08 14:01:58 -05:00
Russ Cox
e966a2773c crypto/internal/fips140/drbg: avoid global lock on rand state
Having a global lock on the random state (used only in FIPS-140 mode)
introduces contention in concurrent programs. Use an approximately
per-P random state instead, using sync.Pool to manage per-P state.

This code is important to land for the Go 1.24 release because it is
part of the FIPS-140 module that will be validated and certified,
so it will live for a long time. We otherwise wouldn't be able to
correct this contention for at least a year, perhaps more.

At the same time, the code is only used in the FIPS-140 mode,
so there is no risk to normal programs.

Fixes #71155.

Change-Id: I6b779f15ddfdf232f608f5cda08f75906e58114f
Reviewed-on: https://go-review.googlesource.com/c/go/+/641097
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-08 10:28:31 -08:00
Michael Pratt
b3799ba634 [release-branch.go1.24] all: merge master (9a44df6) into release-branch.go1.24
Merge List:

+ 2025-01-08 9a44df6675 cmd/go/testdata/script: fix TestScript/env_gocacheprog on Windows
+ 2025-01-08 f025d19e7b runtime: hold traceAcquire across casgstatus in injectglist
+ 2025-01-08 1e9835f5b1 internal/sync: fix typo of panic message
+ 2025-01-07 39f2032c17 testing/synctest: add some examples
+ 2025-01-07 b50ccef67a cmd/go/internal/modindex: don't write index entry if file open
+ 2025-01-07 b2aa18b96c cmd/internal/hash: stop using md5, sha1
+ 2025-01-07 d93b549f05 cmd/go/internal/cache: handle cacheprog not responding to close
+ 2025-01-07 d62154db83 weak: don't panic when calling Value on a zero Pointer
+ 2025-01-07 9d0772b23e cmd/compile/internal/syntax: add test case for invalid label use
+ 2025-01-07 1d20bce981 go/types, types2: expand documentation for Info.Types map
+ 2025-01-07 a9bd6239a4 cmd/go/internal/env: add GOCACHEPROG to go env output
+ 2025-01-07 850b276a67 crypto/tls: send illegal_parameter on invalid ECHClientHello.type
+ 2025-01-06 27c5164374 crypto/internal/fips140: zeroise integrity test temporary values
+ 2025-01-06 d8ad4af78b cmd/internal/disasm: correct instruction length handling for riscv64
+ 2025-01-06 a76cc5a4ec crypto/rsa: use λ(N) instead of φ(N)
+ 2025-01-06 3f002abb60 internal/sync: add test from issue 70970
+ 2025-01-06 7a2e88e911 net/http: update NewRequestWithContext wrong link to NewRequest
+ 2025-01-06 c112c0af13 Revert "internal/sync: optimize CompareAndSwap and Swap"
+ 2025-01-03 705b5a569a crypto/ecdsa: drop SEC 1 reference from package doc
+ 2025-01-03 f966695cce context: use "canceled" in docs to refer to timed-out contexts
+ 2025-01-03 5da026354c cmd/go/internal/vcweb: close the .access file
+ 2025-01-03 31cabcf084 crypto/internal/fips140: mark OpenBSD unsupported
+ 2025-01-03 eb0c2b2f96 crypto/internal/fips140: add Supported
+ 2025-01-03 f0a9b6df45 internal/fuzz: remove the exp2 method
+ 2025-01-03 5d626c49ec spec: fix a dead link
+ 2025-01-03 81566aff3a internal/exportdata: add missing return
+ 2025-01-03 e7a8bd5d8b crypto/internal/fips140/check: remove Enabled
+ 2025-01-02 4b652e9f5f cmd/go: fix two typos in helpdoc.go
+ 2025-01-02 0afd7e85e5 cmd/go: document GOCACHEPROG in go help environment
+ 2025-01-02 3c8e5b13df cmd/go/internal/cacheprog: drop redundant Prog prefixes
+ 2025-01-02 20da34c6d2 cmd/go: move GOCACHEPROG protocol types to their own package
+ 2025-01-02 858a0e9dfd crypto/tls: properly return ECH retry configs
+ 2025-01-02 a63aee4955 cmd/go: improve GOCACHEPROG types documentation
+ 2025-01-02 847c357bbb cmd/go: remove references to gopath-get
+ 2025-01-01 d1d9312950 crypto/tls: fix Config.Time in tests using expired certificates
+ 2024-12-31 94f15810e6 cmd/go: document default GOARM value
+ 2024-12-30 856a7bc8e9 builtin: use list instead of indentation for comments in cap, len, and make
+ 2024-12-30 5efb4239c6 spec: document that string conversions don't guarantee result slice capacity
+ 2024-12-30 0d8aa8cce6 spec: describe representation of values
+ 2024-12-30 8857a5a33f crypto/tls: fix misspelling in comment
+ 2024-12-30 3c4102bfd4 encoding/binary: add documentation for endian methods
+ 2024-12-30 b702a26cf8 os: mention fsys modifications during CopyFS
+ 2024-12-30 15f232456a encoding/json: remove suggestion on Unmarshaler with JSON null
+ 2024-12-30 ba1deb1cee cmd/link: document that -s implies -w
+ 2024-12-30 fd5e0d26d9 go/doc: resolve imports before predeclared identifiers in examples
+ 2024-12-30 a785d11ac4 unique: fix typo
+ 2024-12-27 2b794ed86c encoding/json: expand and modernize TestInterfaceSet
+ 2024-12-27 e3cd55e9d2 cmd/go/internal/work: allow @ character in some -Wl, linker flags on darwin
+ 2024-12-27 39794819aa doc/initial: remove fixed-width spacing notice
+ 2024-12-27 7c03fe70b8 cmd/compile: improve compiler directive docs
+ 2024-12-27 d7c3e93c16 iter: improve documentation with iterator example
+ 2024-12-26 cce75da30b crypto/mlkem: swap order of return values of Encapsulate
+ 2024-12-23 772f024c61 weak: fix typo in warning about tiny allocator optimization
+ 2024-12-23 b9955f0ad9 cmd/link, runtime: apply a delta to RODATA->DATA relocations
+ 2024-12-23 eef35e3bd9 internal/goexperiment: run go generate for synctest
+ 2024-12-23 9f6c80a76a cmd/go/internal/work: allow single character values in -Wl, linker flags
+ 2024-12-22 05d8984781 net: document LookupTXT behavior with multiple strings per record
+ 2024-12-21 500675a7c8 cmd/compile: load map length with the right type
+ 2024-12-21 06b191e11f internal/syscall/unix: apply fstatat fix to linux/mips64le
+ 2024-12-21 110ab1aaf4 slices: document two oddities
+ 2024-12-19 669d87a935 runtime/pprof: continued attempt to deflake the VMInfo test.
+ 2024-12-19 45f49139f5 runtime: test trap panic parsing in TestTracebackSystem
+ 2024-12-19 e63eb98e98 net/http: fix nil panic in test
+ 2024-12-19 7b6c94dd03 cmd/go: drop fips140 build ID hacks
+ 2024-12-19 cb72406c36 cmd/go: fix two-step toolchain upgrade through go install, GOTOOLCHAIN
+ 2024-12-18 4f0561f9d3 cmd/dist: skip fips140test in exe mode on Android
+ 2024-12-18 87dbfb9fa7 weak: improve grammar in doc comments
+ 2024-12-18 f4e3ec3dbe crypto/ecdsa: fix condition for fips140=only check
+ 2024-12-18 6aa46eb750 crypto/tls: normalize spelling of "ClientHello" in comments
+ 2024-12-18 10ca5ba4ff crypto/pbkdf2: update RFC reference in package doc
+ 2024-12-18 8ff4cee564 cmd/go,crypto: reject using Go+BoringCrypto and fips140 together
+ 2024-12-18 971448ddf8 testing: support B.Context and F.Context
+ 2024-12-17 95b433eed4 debug/elf: adjust version API per issue discussion
+ 2024-12-17 b2c0168893 crypto/internal/fips140/aes/gcm: use aes.EncryptBlockInternal on ppc64x and s390x
+ 2024-12-17 b9e2ffdcd2 crypto/internal/fips140: add Name and Version
+ 2024-12-17 8790372a8d cmd, go: fix some typos
+ 2024-12-17 b057b8872d bytes, strings: add cross-references in docstrings
+ 2024-12-17 e977b83b32 cmd/go/internal/help: use secure link to swig.org
+ 2024-12-17 4ac8f552e9 syscall, internal/syscall/unix: fix fstatat on linux/mips64
+ 2024-12-17 236a0b4ffb spec: explain function invocation and passing of parameters more precisely
+ 2024-12-17 9f806bb76c go/build: streamline the crypto package graph in TestDependencies
+ 2024-12-17 0cd833d198 go/build: remove nonexistent package from TestDependencies
+ 2024-12-17 31e50af5f3 crypto/rsa: revert minimum GenerateKey size to 32 bits
+ 2024-12-17 b47ce8b0e9 crypto/cipher: block non-AES CTR and CBC in fips140=only mode
+ 2024-12-17 dd7a7ba38f crypto/internal/fips140/aes: mark AES-ECB as not approved
+ 2024-12-17 427a2401af cmd/go/testdata/script: update test_flags for new test output
+ 2024-12-17 75736cc169 fmt, strconv: document that exponent is always two digits
+ 2024-12-16 1218566fe5 cmd/link: update runtime dependency list
+ 2024-12-16 d92c34a387 cmd/go: don't create test actions for incomplete packages
+ 2024-12-16 3bd08b9792 runtime: usleep in TestWeakToStrongMarkTermination
+ 2024-12-15 18b5435fc8 testing: don't measure cleanup time after B.Loop
+ 2024-12-15 c1f2542c8b testing: improve B.Loop test
+ 2024-12-15 6bd56fcaeb testing: improve b.Loop example
+ 2024-12-15 090748d6c7 testing: improve B.Loop docs, use B.Loop in examples
+ 2024-12-13 e39e965e0e cmd/go: drop FailedBuild field if gotestjsonbuildtext=1
+ 2024-12-13 08770a5b94 cmd/link: make dwarf name slice index self-describing
+ 2024-12-13 c4f356dd86 crypto/ecdsa: fix s390x assembly with P-521
+ 2024-12-13 08725f9de2 crypto/internal/cryptotest: skip TestAllocations on s390x
+ 2024-12-13 1cbfe8c482 fmt: add more function and allocation tests
+ 2024-12-13 8391579ece runtime: migrate missing map linkname allowlists
+ 2024-12-12 80a2982a80 spec: align EBNF rules consistently (cosmetic change)
+ 2024-12-12 38e9a671d7 syscall: on freebsd-386 only update written for certain errors
+ 2024-12-12 6f7a4540b1 net: fix example function name for IP.To4
+ 2024-12-12 14e5093ee5 cmd/internal/obj: disallow linknamed access to builtin symbols
+ 2024-12-12 fb764cdad0 cmd/link: block new standard library linknames

Change-Id: Ie423f050db80034c3af6c12bd6007db273c5d281
2025-01-08 13:21:10 -05:00
Michael Matloob
9a44df6675 cmd/go/testdata/script: fix TestScript/env_gocacheprog on Windows
The backslashes on the windows paths will be escaped, so when checking
for them in the regular expression we'd have to have quadruple
backslashes '\\\\'. Since it's difficult to escape $GOCACHEPROG properly
for both json and regexp, just check for a string that ends in
cacheprog$GOEXE. We already check that the proper value is reported in
go env and go env -changed, and the json test case is mostly useful to
verify that GOCACHEPROG shows up in the json output.

For #71059

Change-Id: I52d49de61f2309a139f84c4d232b4cd94546ec8c
Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/641375
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-01-08 10:11:09 -08:00
Michael Anthony Knyszek
f025d19e7b runtime: hold traceAcquire across casgstatus in injectglist
Currently injectglist emits all the trace events before actually calling
casgstatus on each goroutine. This is a problem, since tracing can
observe an inconsistent state (gstatus does not match tracer's 'emitted
an event' state).

This change fixes the problem by having injectglist do what every other
scheduler function does, and that's wrap each call to casgstatus in
traceAcquire/traceRelease.

Fixes #70883.

Change-Id: I857e96cec01688013597e8efc0c4c3d0b72d3a70
Reviewed-on: https://go-review.googlesource.com/c/go/+/638558
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-08 09:25:53 -08:00
Koichi Shiraishi
1e9835f5b1 internal/sync: fix typo of panic message
Change-Id: I3e7a8498514da1d278acd566d526fdf6278f7d41
Reviewed-on: https://go-review.googlesource.com/c/go/+/638916
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2025-01-08 09:02:13 -08:00
Damien Neil
39f2032c17 testing/synctest: add some examples
For #67434

Change-Id: Iebcfc2559a62405fea7e3ceff8cf6c2f50b61def
Reviewed-on: https://go-review.googlesource.com/c/go/+/641176
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-01-07 20:05:28 -08:00
Michael Matloob
b50ccef67a cmd/go/internal/modindex: don't write index entry if file open
On Windows, we can't open a file that's already been opened. Before this
change, we'd try to write an index entry if mmapping the entry failed.
But that could happen either if the file doesn't exist or if there was a
problem mmapping an already opened file. Pass through information about
whether the file was actually opened so that we don't try to write to an
already opened file.

For #71059

Change-Id: I6adabe1093fed9ec37e7fafb13384c102786cbce
Reviewed-on: https://go-review.googlesource.com/c/go/+/640577
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-07 12:50:01 -08:00
Russ Cox
b2aa18b96c cmd/internal/hash: stop using md5, sha1
These break if the tools are run with GODEBUG=fips140=only,
which happens if someone sets that during 'go test' (and a test
binary must be built).

The easiest fix is to make the tools compatible with this GODEBUG
by just using sha256 as the underlying hash always. Just in case,
I made the wrappers select different sections of the hash, but
none of the call sites really care.

This CL is for the Go 1.24 release, but a follow-up during the Go 1.25
dev cycle could change all the usage sites to only use Sum32/New32.

For #70514
Fixes #70878

Change-Id: Id5fea779c83df51d1680dbe561e0949c56e8d1e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/641096
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2025-01-07 10:59:33 -08:00
Michael Matloob
d93b549f05 cmd/go/internal/cache: handle cacheprog not responding to close
Allow a gocacheprog to not respond to close. The intention of the code
is that after we send the close message we'd ignore errors reading from
the cacheprog's stdout. But before this change if a cacheprog
did not respond to close and we got an EOF reading from the cacheprog's
stdout we'd just ignore all pending requests. The send operation would
then block forever waiting for a response. With this change, we close
all response channels for pending responses if there's an error reading
from the cacheprog's stdout while we're closing. The receives from the
response channels would then proceed (but now have to handle a nil
value). Then the send operation would return and the (*ProgCache).Close
function can proceed.

Fixes #70848

Change-Id: I6631d317ba7aea3f25f714f31cd2aeef0f4d4e3e
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/640516
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-07 10:21:05 -08:00
Michael Anthony Knyszek
d62154db83 weak: don't panic when calling Value on a zero Pointer
Currently weak.Pointer.Value will panic if the weak.Pointer is
uninitialized (zero value) which goes against it's documentation. Fix
this and add a test. While we're here, also add a test to ensure
weak.Make[T](nil) is equivalent to the zero value of weak.Pointer[T].

Fixes #71153.

Change-Id: I4d9196026360bc42a5bfcb33ce449131ec251dba
Reviewed-on: https://go-review.googlesource.com/c/go/+/641095
Reviewed-by: David Finkel <david.finkel@gmail.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-01-07 10:08:42 -08:00
Robert Griesemer
9d0772b23e cmd/compile/internal/syntax: add test case for invalid label use
This case is not properly handled by the type checkers (see issue)
but the compiler uses the parser's label checking so it works as
expected.

For #70974.

Change-Id: I0849376bf7514a9a7730846649c3fe28c91f44ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/640895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2025-01-07 09:56:13 -08:00
Robert Griesemer
1d20bce981 go/types, types2: expand documentation for Info.Types map
Function types for function (and method) declarations do not
appear in Info.Types maps, only Info.Defs maps, because the
function type is implicit in the declaration and not a proper
(function) type expression. This is true even though the AST
represents these types via an (artificial) FuncType node.

Document this explicitly in the API.

No functional code changes.

Fixes #70908.

Change-Id: I2aa897daed04e7ad0fa8b625d9adc7b423c57387
Reviewed-on: https://go-review.googlesource.com/c/go/+/640776
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-07 09:56:11 -08:00
Michael Matloob
a9bd6239a4 cmd/go/internal/env: add GOCACHEPROG to go env output
For #71059

Change-Id: I4bbdd14d416dc2e6dae3549a84c16dbef9d4e645
Reviewed-on: https://go-review.googlesource.com/c/go/+/640755
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-07 07:48:33 -08:00
thekuwayama
850b276a67 crypto/tls: send illegal_parameter on invalid ECHClientHello.type
The spec indicates that if a client sends an invalid ECHClientHello.type
in ClientHelloOuter, the server will abort the handshake with a
decode_error alert.

Define errInvalidECHExt for invalid ECHClientHello.type. If parseECHExt
returns an errInvalidECHExt error, Conn now sends an illegal_parameter
alert.

Fixes #71061.

Change-Id: I240241fe8bbe3e77d6ad1af989794647bfa2ff87
GitHub-Last-Rev: 3d6c233ccd
GitHub-Pull-Request: golang/go#71062
Reviewed-on: https://go-review.googlesource.com/c/go/+/639235
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-01-07 06:36:26 -08:00
Filippo Valsorda
27c5164374 crypto/internal/fips140: zeroise integrity test temporary values
There is no point to zeroise anything here because there are no secrets,
but there is a strict FIPS 140-3 test requirement for it.

> TE05.08.02 (Levels 1, 2, 3, and 4): verify that any temporary values
> generated during the integrity test are zeroised upon completion of
> the integrity test

Change-Id: I7b0db075dae9910f8e825a22ca2caa2b4c918980
Reviewed-on: https://go-review.googlesource.com/c/go/+/636556
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-01-06 23:44:33 -08:00
Joel Sing
d8ad4af78b cmd/internal/disasm: correct instruction length handling for riscv64
disasm_riscv64 currently always returns an instruction length of four,
which is not correct if compressed instructions are in use. Return the
length of the decoded instruction, defaulting to two bytes if the
instruction is unknown.

With this change it is possible to correctly objdump a binary that is
written in C and includes compressed instructions:

$ go tool objdump ./hello
TEXT _start(SB)
  :0                    0x5b0                   ef002002                CALL 8(PC)
  :0                    0x5b4                   aa87                    ADD X10, X0, X15
  :0                    0x5b6                   17250000                AUIPC $2, X10
  :0                    0x5ba                   033525a3                MOV -1486(X10), X10
  :0                    0x5be                   8265                    MOV (X2), X11
  :0                    0x5c0                   3000                    ADDI $8, X2, X12
  ...

Fixes #71102

Change-Id: Ia99eb114a98c6d535de872ce8a526cd5e6203fff
Reviewed-on: https://go-review.googlesource.com/c/go/+/639995
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2025-01-06 23:43:06 -08:00
Filippo Valsorda
a76cc5a4ec crypto/rsa: use λ(N) instead of φ(N)
This has no practical advantage, and requires extra variable time code,
but is an explicit FIPS 186-5 requirement.

Note that the new behavior is consistent with Go+BoringCrypto, but not
with Go 1.23. The resulting keys are essentially interchangeable, but
it's not impossible for applications to notice (google/go-tpm#383).

gcd_lcm_tests.txt is from BoringSSL.

Change-Id: I6a6a4656fd5e92912c87bedc667456d0e8787023
Reviewed-on: https://go-review.googlesource.com/c/go/+/639936
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-01-06 16:16:41 -08:00
Michael Anthony Knyszek
3f002abb60 internal/sync: add test from issue 70970
This test checks a use-case of sync.Map that's expected to be more
common in Go 1.24 and beyond, as a concurrent weak cache.

The test will also fail if CompareAndSwap is not properly atomic with
CompareAndDelete, which is what #70970 is actually about. We should have
more explicit tests checking mutual atomicity of operations, but
for now this is OK, and still useful.

For #70970.

Change-Id: I6db508660691586a8af9ad511c9a96432d333343
Reviewed-on: https://go-review.googlesource.com/c/go/+/640737
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-06 11:54:59 -08:00
yincong
7a2e88e911 net/http: update NewRequestWithContext wrong link to NewRequest
Fixes #70874

Change-Id: Icbcfc95e6b45521880287dcc3bc8609461a3b401
GitHub-Last-Rev: 05276c56b0
GitHub-Pull-Request: golang/go#70877
Reviewed-on: https://go-review.googlesource.com/c/go/+/637035
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-06 11:01:12 -08:00
Michael Knyszek
c112c0af13 Revert "internal/sync: optimize CompareAndSwap and Swap"
This reverts CL 606462.

Reason for revert: Breaks atomicity between operations. See #70970.

Change-Id: I1a899f2784da5a0f9da3193e3267275c23aea661
Reviewed-on: https://go-review.googlesource.com/c/go/+/638615
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Commit-Queue: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2025-01-06 09:57:18 -08:00
Filippo Valsorda
705b5a569a crypto/ecdsa: drop SEC 1 reference from package doc
FIPS 186-4 used to defer to ANSI X9.62-2005, which is not freely
available, so we were referring to SEC 1 instead. Our new reference,
FIPS 186-5, actually specifies the full algorithm, so there is no need
to refer to SEC 1 anymore.

Change-Id: Ief499d0f7778f3221547993e9e8951ae873aacef
Reviewed-on: https://go-review.googlesource.com/c/go/+/640115
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-01-03 14:40:11 -08:00
Damien Neil
f966695cce context: use "canceled" in docs to refer to timed-out contexts
In documentation, we've usually but not always referred to a
context with a closed Done channel as "done" rather than
"canceled", to avoid ambiguity between a context canceled
by calling a CancelFunc and one past its deadline.

This actually adds ambiguity, however, since it's common to
see references to a "canceled context" that are intended to
cover contexts past their deadline. If you see "function F
returns if its context is canceled", you can reasonably
assume that F will return if its context passes its
deadline, unless something says otherwise.

Update the context package docs to explicitly state that
a context is canceled when its deadline passes. Drop references
to contexts becoming "done" and just use "canceled" throughout.

Fixes #70945

Change-Id: I99fbd800c6049deaa37015a304f7f9d9a84100e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/640095
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-01-03 14:30:13 -08:00
Ian Lance Taylor
5da026354c cmd/go/internal/vcweb: close the .access file
For #71112

Change-Id: Ifda4fc8de148c42a2154da54b53d7215b9a6faa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/640175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-03 14:12:15 -08:00
Filippo Valsorda
31cabcf084 crypto/internal/fips140: mark OpenBSD unsupported
Since OpenBSD 7.3, external linking uses -fexecute-only, which breaks
the integrity check. Since we are not validating on OpenBSD anyway,
mark it as unsupported at least for now.

Fixes #70880

Change-Id: I6a6a4656b6c7a97c0962b4158d920f9e6b19678e
Reviewed-on: https://go-review.googlesource.com/c/go/+/639337
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: صادق <sadq04724@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-03 10:53:43 -08:00
Filippo Valsorda
eb0c2b2f96 crypto/internal/fips140: add Supported
Move the logic duplicated in multiple places to a central function.

Change-Id: I6a6a4656469c91dd62b0be716ec8367358f4a3e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/639336
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2025-01-03 10:12:06 -08:00
Jakub Ciolek
f0a9b6df45 internal/fuzz: remove the exp2 method
It's not being used anywhere, remove it.

Change-Id: I9c3eecacd4e5d44b18243bdec24ad88bc38c82bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/639957
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
2025-01-03 10:10:07 -08:00
yaxum62
5d626c49ec spec: fix a dead link
Change-Id: If99aa8073cc0e7fe36d3775c635eaaab230fcd04
GitHub-Last-Rev: 06dbd990c7
GitHub-Pull-Request: golang/go#71083
Reviewed-on: https://go-review.googlesource.com/c/go/+/638638
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Jorropo <jorropo.pgm@gmail.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-03 09:23:39 -08:00
Mateusz Poliwczak
81566aff3a internal/exportdata: add missing return
Change-Id: I9703c6a4a2ae4a608d33cf706106c92e9bd2aef7
GitHub-Last-Rev: 3eee41957d
GitHub-Pull-Request: golang/go#71096
Reviewed-on: https://go-review.googlesource.com/c/go/+/637962
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-03 08:43:47 -08:00
Filippo Valsorda
e7a8bd5d8b crypto/internal/fips140/check: remove Enabled
check.Enabled, internal/fips140.Enabled, and crypto/fips140.Enabled were
redundant. Package check can just use internal/fips140.Enabled.

check.Verified is still there for the tests and belt-and-suspenders
assurance in crypto/fips140.Enabled, although it's implied by Enabled.

For #69536

Change-Id: I83921cc925da841aba4da79a9a5e9ac526a3f2bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/638855
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2025-01-03 08:29:24 -08:00
linmaolin
4b652e9f5f cmd/go: fix two typos in helpdoc.go
Change-Id: Ib750438107db6c82020cfb4abbab52435012b7fc
GitHub-Last-Rev: 3fa9b8c7bc
GitHub-Pull-Request: golang/go#71082
Reviewed-on: https://go-review.googlesource.com/c/go/+/639217
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2025-01-02 16:10:54 -08:00
Austin Clements
0afd7e85e5 cmd/go: document GOCACHEPROG in go help environment
This adds GOCACHEPROG to the list of environment variables in "go help
environment" and points to the cacheprog package documentation for
details of the protocol.

Fixes #71032
Updates #59719

Change-Id: Ib8f5804926a8fa59237661076d129c2852665ac3
Reviewed-on: https://go-review.googlesource.com/c/go/+/638997
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2025-01-02 10:36:34 -08:00
Austin Clements
3c8e5b13df cmd/go/internal/cacheprog: drop redundant Prog prefixes
Now that these types are in their own package, drop the unnecessary
Prog prefixes from everything.

Updates #71032
Updates #59719

Change-Id: Id54edf0473754e3b21a71beb72803fb5481206c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/638996
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-02 10:36:30 -08:00
Austin Clements
20da34c6d2 cmd/go: move GOCACHEPROG protocol types to their own package
This is a step toward making it easy to point to them in
documentation. The other option is that we copy-paste all of these
type definitions wholesale, which seems ridiculous.

Updates #71032
Updates #59719

Change-Id: I7117e03308ae0adc721ed7a57792c33ba68ce827
Reviewed-on: https://go-review.googlesource.com/c/go/+/638995
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2025-01-02 10:36:27 -08:00
Roland Shoemaker
858a0e9dfd crypto/tls: properly return ECH retry configs
When ECH is rejected, properly take retry configs from the encrypted
extensions message. Also fix the bogo shim to properly test for this
behavior.

We should properly map the full BoringSSL -> Go errors so that we don't
run into a similar failure in the future, but this is left for a follow
up CL.

Fixes #70915

Change-Id: Icc1878ff6f87df059e7b83e0a431f50f1fea833c
Reviewed-on: https://go-review.googlesource.com/c/go/+/638583
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-01-02 09:38:03 -08:00
Austin Clements
a63aee4955 cmd/go: improve GOCACHEPROG types documentation
This is in preparation for adding a "go help" topic for GOCACHEPROG.

Updates #71032
Updates #59719

Change-Id: I9dbbe56fa328dffe89207b5b41a0f37afd51e2b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/638566
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2025-01-02 09:17:35 -08:00
Sean Liao
847c357bbb cmd/go: remove references to gopath-get
Fixes #70912

Change-Id: Id87a13f7c9bf972502d14c9674a27f743b849715
Reviewed-on: https://go-review.googlesource.com/c/go/+/639155
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
2025-01-02 08:02:15 -08:00
Filippo Valsorda
d1d9312950 crypto/tls: fix Config.Time in tests using expired certificates
Fixes #71077

Change-Id: I6a6a465685f3bd50a5bb35a160f87b59b74fa6af
Reviewed-on: https://go-review.googlesource.com/c/go/+/639655
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-01-01 21:18:59 -08:00
Ian Lance Taylor
94f15810e6 cmd/go: document default GOARM value
For #24904
For #58884

Change-Id: I0fc61f1a0bc6ebb22bdfd7a7b13ef36c68879384
Reviewed-on: https://go-review.googlesource.com/c/go/+/639276
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-12-31 18:00:57 -08:00
Shulhan
856a7bc8e9 builtin: use list instead of indentation for comments in cap, len, and make
Using list make the document more readable in HTML and CLI.

Change-Id: Ib84c84656f32806e8612b1ca13938d93f618e27f
Reviewed-on: https://go-review.googlesource.com/c/go/+/639315
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-30 15:59:23 -08:00
Robert Griesemer
5efb4239c6 spec: document that string conversions don't guarantee result slice capacity
Fixes #24163.

Change-Id: If389c4abf3b9b6e4eba6f31c3c12779329456df6
Reviewed-on: https://go-review.googlesource.com/c/go/+/637655
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
2024-12-30 12:51:01 -08:00
Robert Griesemer
0d8aa8cce6 spec: describe representation of values
Add a section on the representation of values:
distinguish between values that are self-contained
and values that contain references while avoiding
the notion of "reference types" which is misleading.

Also, use "predeclared identifier nil" rather than
"predeclared value nil" because it is the identifier
that is predeclared.

Fixes #5083.

Change-Id: I2235673c6404f2c055f195e879f198c7ab246d58
Reviewed-on: https://go-review.googlesource.com/c/go/+/635801
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2024-12-30 12:50:25 -08:00
thekuwayama
8857a5a33f crypto/tls: fix misspelling in comment
Change-Id: Ie36a19ed6d6922e68f98e43745a417a24f8a7828
GitHub-Last-Rev: 6fb32e3d1d
GitHub-Pull-Request: golang/go#71060
Reviewed-on: https://go-review.googlesource.com/c/go/+/639215
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-30 12:38:22 -08:00
willboland
3c4102bfd4 encoding/binary: add documentation for endian methods
While the comments are on an unexported type, gopls correctly
shows them when using the exported vars LittleEndian and BigEndian.

Fixes #68083

Change-Id: I53668c3140ad00f7b58437be74e6df773e2916f1
GitHub-Last-Rev: cef717123c
GitHub-Pull-Request: golang/go#71058
Reviewed-on: https://go-review.googlesource.com/c/go/+/638936
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
2024-12-30 12:32:26 -08:00
Sean Liao
b702a26cf8 os: mention fsys modifications during CopyFS
Fixes #70465

Change-Id: I47055df9ca5b1df21a361b0b8eea4c7d157e6403
Reviewed-on: https://go-review.googlesource.com/c/go/+/639156
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-12-30 12:23:28 -08:00
Joe Tsai
15f232456a encoding/json: remove suggestion on Unmarshaler with JSON null
It is not true that Unmarshal always treats a JSON null
as being equivalent to a no-op.
For bools, ints, uints, floats, strings, arrays, and structs,
it treats a JSON null as a no-op. However, for []byte, slice,
map, pointer, or interface, it zeros the underlying value.

Remove this suggestion as the actual behavior is inconsistent.

Note that the proposed behavior in v2 Unmarshal is to consistently
zero out the underlying value.

Change-Id: I02cef0bf7919f25cfd0aceb04486d37498761181
Reviewed-on: https://go-review.googlesource.com/c/go/+/638416
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
2024-12-30 12:21:48 -08:00
willboland
ba1deb1cee cmd/link: document that -s implies -w
Existing documentation does not reference implicit behavior.
Updates the documentation to reflect that -s implies -w.

Fixes #71051

Change-Id: I5c139c37f5f78596365e38479be4c865a4d4dd62
GitHub-Last-Rev: a3e462c416
GitHub-Pull-Request: golang/go#71053
Reviewed-on: https://go-review.googlesource.com/c/go/+/638976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-12-30 12:06:30 -08:00
Sean Liao
fd5e0d26d9 go/doc: resolve imports before predeclared identifiers in examples
Fixes #70611
Fixes #70630

Change-Id: I868e68dbdf50ce34259eeef7b3d7985ede1f4c0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/639175
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-30 09:19:22 -08:00
Koichi Shiraishi
a785d11ac4 unique: fix typo
Change-Id: I9f66e3d7aa7b546ebf34d6aa8c7a6558bf35ca82
Reviewed-on: https://go-review.googlesource.com/c/go/+/639055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-12-30 08:59:20 -08:00
Joe Tsai
2b794ed86c encoding/json: expand and modernize TestInterfaceSet
Add more test cases to cover a wider range of edge cases.
Use a generic addr function to take the address of a value.
Even though redudant, explicitly include a cast to the
top-level Go type so that it is more readable what the
expected input and ouput types are.

Change-Id: I3ef68df6f1beb903ae237cd49f3dcb91e5270fe7
Reviewed-on: https://go-review.googlesource.com/c/go/+/638256
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-27 17:23:24 -08:00
Pedro Tôrres
e3cd55e9d2 cmd/go/internal/work: allow @ character in some -Wl, linker flags on darwin
The GNU linker interprets @file as "read command-line options from file".
Thus, we forbid values starting with @ on linker flags. However, this
causes a problem when targeting Darwin. @executable_path, @loader_path, and
@rpath are special values used in Mach-O to change the library search path
and can be used in conjunction with the -install_name and -rpath linker
flags. Since the GNU linker does not support Mach-O, targeting Darwin
implies not using the GNU linker. Therefore, we allow @ in the linker flags
if and only if cfg.Goos == "darwin".

Fixes #40559

Change-Id: I0896758f0835e444ea0d501ea3fd8423cff97a27
GitHub-Last-Rev: 2b81dcd12e
GitHub-Pull-Request: golang/go#70939
Reviewed-on: https://go-review.googlesource.com/c/go/+/638075
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-27 12:34:09 -08:00
Austin Clements
39794819aa doc/initial: remove fixed-width spacing notice
Ever since CL 362015 in 2021 it hasn't been necessary to set
"fixed-width phrases with non-fixed-width spaces" because the site CSS
now takes care of this typesetting convention.

Change-Id: Id84f711b65cddf389dc485aa362b23c9c531cbfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/638565
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-27 08:54:04 -08:00
Austin Clements
7c03fe70b8 cmd/compile: improve compiler directive docs
This section has gotten long enough that it deserves to be multiple
sections. This also allows us to better structure information shared
by subsets of directives. In particular, this enables a self-contained
section on the wasm directives.

Updates #66984.

Change-Id: I062081d46c6b0aef7887fdaf9efae80f32ad4b21
Reviewed-on: https://go-review.googlesource.com/c/go/+/638881
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-12-27 08:31:59 -08:00
Harald Albrecht
d7c3e93c16 iter: improve documentation with iterator example
In introducing iterators, package iter gives an example of how to
use an iterator in a range-over-func loop, but currently does not
give an example of what an iterator implementation might look like.

This change adds the example of map.Keys() before the usage example.
Additionally, it references to the Go blog for further examples,
as well as the language spec about for-range loops.

Fixes #70986

Change-Id: I7108d341d314d7de146b4c221700736c943a9f5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/638895
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-27 05:44:33 -08:00
Alec Bakholdin
cce75da30b crypto/mlkem: swap order of return values of Encapsulate
Per FIPS 203 (https://csrc.nist.gov/pubs/fips/203/final), the order of return values should be sharedKey, ciphertext. This commit simply swaps those return values and updates any consumers of the Encapsulate() method to respect the new order.

Fixes #70950

Change-Id: I2a0d605e3baf7fe69510d60d3d35bbac18f883c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/638376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-12-26 12:33:05 -08:00
Michael Anthony Knyszek
772f024c61 weak: fix typo in warning about tiny allocator optimization
Fixes #70972.

Change-Id: Ib04c2a3129a1da651a0b4674b372aec73966115a
Reviewed-on: https://go-review.googlesource.com/c/go/+/638377
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-23 17:53:33 -08:00
Cherry Mui
b9955f0ad9 cmd/link, runtime: apply a delta to RODATA->DATA relocations
On AIX, an R_ADDR relocation from an RODATA symbol to a DATA
symbol does not work, as the dynamic loader can change the address
of the data section, and it is not possible to apply a dynamic
relocation to RODATA. In order to get the correct address, we
apply the delta between unrelocated and relocated data section
addresses at run time. The linker saves both the unrelocated and
the relocated addresses, so we can compute the delta.

This is possible because RODATA symbols are generated by the
compiler and so we have full control of. On AIX, the only case
is the on-demand GC pointer masks from the type descriptors, for
very large types.

Perhaps there is a better way.

Fixes #70483.

Change-Id: I2664c0a813b38f7b146794cb1e73ccf5e238ca65
Reviewed-on: https://go-review.googlesource.com/c/go/+/638016
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-23 09:49:40 -08:00
Jorropo
eef35e3bd9 internal/goexperiment: run go generate for synctest
Updates #70954

Change-Id: If5f9c8b8b820b1cc4e41e76b50038c6155b575a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/638355
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-12-23 07:08:40 -08:00
Pedro Tôrres
9f6c80a76a cmd/go/internal/work: allow single character values in -Wl, linker flags
Allow single character values in -Wl, linker flags by modifying the regular
expressions to use the star operator instead of the plus operator.

Fixes #70924

Change-Id: Ie7940197cc8503440a87c6b29409a13377a20534
GitHub-Last-Rev: 42e8ac87d6
GitHub-Pull-Request: golang/go#70937
Reviewed-on: https://go-review.googlesource.com/c/go/+/638035
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-23 07:08:22 -08:00
Simon Ser
05d8984781 net: document LookupTXT behavior with multiple strings per record
CL 8966 ("net: allow a dns TXT record to contain more than
one <character-string>") concatenates strings in a TXT record. Document
that behavior, since it's not obvious whether the strings will be
concatenated or accumulated in the returned slice.

Change-Id: I6acb27b296290361a95a6058a056f8e7c2df9a2b
GitHub-Last-Rev: ec0726c7b8
GitHub-Pull-Request: golang/go#65233
Reviewed-on: https://go-review.googlesource.com/c/go/+/557695
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-22 16:27:28 -08:00
Cherry Mui
500675a7c8 cmd/compile: load map length with the right type
len(map) is lowered to loading the first field of the map
structure, which is the length. Currently it is a load of an int.
With the old map, the first field is indeed an int. With Swiss
map, however, it is a uint64. On big-endian 32-bit machine,
loading an (32-bit) int from a uint64 would load just the high
bits, which are (probably) all 0. Change to a load with the proper
type.

Fixes #70248.

Change-Id: I39cf2d1e6658dac5a8de25c858e1580e2a14b894
Reviewed-on: https://go-review.googlesource.com/c/go/+/638375
Run-TryBot: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2024-12-21 19:25:03 -08:00
Cherry Mui
06b191e11f internal/syscall/unix: apply fstatat fix to linux/mips64le
Apply CL 633280 to linux/mips64le, as it has the same struct as
mips64.

Updates #70659.

Change-Id: Ibab635e69e44682eb214bf6a00f4cd75816b2d34
Reviewed-on: https://go-review.googlesource.com/c/go/+/637739
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-21 12:51:34 -08:00
Alan Donovan
110ab1aaf4 slices: document two oddities
Fixes #70935

Change-Id: Idf4a38a05ba595d616b6469a14419ff873bbd354
Reviewed-on: https://go-review.googlesource.com/c/go/+/638095
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2024-12-21 08:22:08 -08:00
Cosmos Nicolaou
669d87a935 runtime/pprof: continued attempt to deflake the VMInfo test.
This change catches an additional error message to trigger skipping
the test when the underlying system is failing.

Fixes #62352

Change-Id: I5c12b20f3e9023597ff89fc905c0646a80ec4811
Reviewed-on: https://go-review.googlesource.com/c/go/+/637995
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-19 19:19:59 -08:00
Michael Pratt
45f49139f5 runtime: test trap panic parsing in TestTracebackSystem
This mirrors https://go.dev/cl/637755, as x/telemetry is now aware of
sigpanic preceding trap frames.

For #70637.

Change-Id: I13a775f25e89047702d4f2d463ce3210bcf192d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/638015
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-19 19:19:50 -08:00
Russ Cox
e63eb98e98 net/http: fix nil panic in test
Observed on a builder in an unrelated CL.
https://logs.chromium.org/logs/golang/buildbucket/cr-buildbucket/8728107031663629713/+/u/step/11/log/2

goroutine 27937 gp=0xc00000f6c0 m=20 mp=0xc000085008 [running]:
panic({0x560ac0?, 0xa1f400?})
	C:/b/s/w/ir/x/w/goroot/src/runtime/panic.go:806 +0x168 fp=0xc00043fac8 sp=0xc00043fa18 pc=0xa5f88
testing.tRunner.func1.2({0x560ac0, 0xa1f400})
	C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1734 +0x219 fp=0xc00043fb78 sp=0xc00043fac8 pc=0x1537f9
testing.tRunner.func1()
	C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1737 +0x359 fp=0xc00043fce0 sp=0xc00043fb78 pc=0x153259
panic({0x560ac0?, 0xa1f400?})
	C:/b/s/w/ir/x/w/goroot/src/runtime/panic.go:787 +0x132 fp=0xc00043fd90 sp=0xc00043fce0 pc=0xa5f52
runtime.panicmem(...)
	C:/b/s/w/ir/x/w/goroot/src/runtime/panic.go:262
runtime.sigpanic()
	C:/b/s/w/ir/x/w/goroot/src/runtime/signal_windows.go:401 +0x198 fp=0xc00043fdd8 sp=0xc00043fd90 pc=0x87938
net/http_test.testTransportIdleConnTimeout.func3(...)
	C:/b/s/w/ir/x/w/goroot/src/net/http/transport_test.go:5503
net/http_test.testTransportIdleConnTimeout(0xc000e83340, {0x5ec863, 0x2})
	C:/b/s/w/ir/x/w/goroot/src/net/http/transport_test.go:5522 +0x4c1 fp=0xc00043ff20 sp=0xc00043fdd8 pc=0x47a841
net/http_test.run[...].func1()
	C:/b/s/w/ir/x/w/goroot/src/net/http/clientserver_test.go:93 +0xfe fp=0xc00043ff70 sp=0xc00043ff20 pc=0x49a21e
testing.tRunner(0xc000e83340, 0xc0004687b0)
	C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1792 +0xcb fp=0xc00043ffc0 sp=0xc00043ff70 pc=0x152e4b
testing.(*T).Run.gowrap1()
	C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1851 +0x25 fp=0xc00043ffe0 sp=0xc00043ffc0 pc=0x153e65
runtime.goexit({})
	C:/b/s/w/ir/x/w/goroot/src/runtime/asm_amd64.s:1700 +0x1 fp=0xc00043ffe8 sp=0xc00043ffe0 pc=0xadfe1
created by testing.(*T).Run in goroutine 27899
	C:/b/s/w/ir/x/w/goroot/src/testing/testing.go:1851 +0x3f6


Change-Id: I3f8bd7c7863b5031ff43d4837dfe11d26ac75652
Reviewed-on: https://go-review.googlesource.com/c/go/+/637897
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-19 10:59:58 -08:00
Russ Cox
7b6c94dd03 cmd/go: drop fips140 build ID hacks
We were trying to keep all binaries stale in fips140 mode
so that every build would write and leave behind a fips.o
in the work directory for use by validating labs.
That breaks various staleness checks, including the one
in cmd/dist during GOFIPS140=latest ./make.bash.

Revert the fips140 hack. Validating labs will still be able
to find the fips.o when building against a clean cache.

Add the default godebug to the link hash though,
so that it is clear that GOFIPS140=latest
and GOFIPS140=off binaries have different hashes.
(The only effect is the default GODEBUG setting.)
They already had different hashes, because the
default GODEBUG ends up in p.Internal.BuildInfo,
and that gets hashed in a "modinfo" line,
but better to be explicit.

Fixes #70873.

Change-Id: I49a38c180208098c2b6720facef48f4e96d44c54
Reviewed-on: https://go-review.googlesource.com/c/go/+/637116
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-19 10:36:27 -08:00
Russ Cox
cb72406c36 cmd/go: fix two-step toolchain upgrade through go install, GOTOOLCHAIN
If we do one upgrade because of a go install target's go.mod file,
we still might need a second upgrade to implement the GOTOOLCHAIN
minimum. Instead of allowing a two-step switch (which we were
cutting off anyway), skip the first step and go straight to the
GOTOOLCHAIN min upgrade.

Fixes #69051.

Change-Id: I16f060f473574d8b8f84c55fae2fd0cdabc8aa19
Reviewed-on: https://go-review.googlesource.com/c/go/+/637496
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-19 08:12:29 -08:00
Cherry Mui
4f0561f9d3 cmd/dist: skip fips140test in exe mode on Android
Android does not support non-PIE linking. Skip the test.

Change-Id: I53071538c82f1e1f96eed1a2619f92eacd18d263
Reviewed-on: https://go-review.googlesource.com/c/go/+/637495
Run-TryBot: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-12-18 20:48:37 -08:00
Michal Bohuslávek
87dbfb9fa7 weak: improve grammar in doc comments
Change-Id: I577b8a6bf2b7d899cc7ff7211c73549c90db9d94
Reviewed-on: https://go-review.googlesource.com/c/go/+/637355
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-12-18 20:27:29 -08:00
Mauri de Souza Meneguzzo
f4e3ec3dbe crypto/ecdsa: fix condition for fips140=only check
Fixes #70894

Change-Id: I78c9f2e46006ffc5f1d2886218f8aaaf3f1b59eb
GitHub-Last-Rev: 11f0b452f5
GitHub-Pull-Request: golang/go#70904
Reviewed-on: https://go-review.googlesource.com/c/go/+/637455
Reviewed-by: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2024-12-18 14:59:07 -08:00
Filippo Valsorda
6aa46eb750 crypto/tls: normalize spelling of "ClientHello" in comments
Change-Id: I2b62fb37ae390c42682354eaa2a9d03159563b6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/637179
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2024-12-18 08:50:08 -08:00
Filippo Valsorda
10ca5ba4ff crypto/pbkdf2: update RFC reference in package doc
Now that it's published, we don't need to explain how we diverge from
the old one.

Change-Id: If2c22e89dd1b9fc531a363b5fb7b1eb5720eb84e
Reviewed-on: https://go-review.googlesource.com/c/go/+/637215
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-18 08:49:24 -08:00
Filippo Valsorda
8ff4cee564 cmd/go,crypto: reject using Go+BoringCrypto and fips140 together
The combination is untested and nonsensical. Both are solutions to the
same problem.

For #69536

Change-Id: I95cc3baaf03b64ce08096e304e311a29e9577385
Reviewed-on: https://go-review.googlesource.com/c/go/+/637177
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2024-12-18 08:49:21 -08:00
Ian Lance Taylor
971448ddf8 testing: support B.Context and F.Context
CL 603959 added T.Context for #36532.

The discussion on the proposal only mentions t.Context.
However, the implementation of CL 603959 also added B.Context and F.Context.
They were added to the API listing, and B.Context was mentioned in
the release notes.

Unfortunately, the new B.Context and F.Context methods always
returned nil, rather than a context.Context value.

This change adds a working implementation of B.Context and F.Context.

For #36532
Fixes #70866

Change-Id: I8a44e6649fb658e4f641ffb7efd08b4374f578ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/637236
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-12-18 08:18:04 -08:00
Ian Lance Taylor
95b433eed4 debug/elf: adjust version API per issue discussion
This updates the new version API for the discussion on #63952.

Note that the current tests do not have symbols with hidden versions.
Leaving that for later.

For #63952

Change-Id: I1ad4b1e485429a216ba8e5b68f7f4299d120628f
Reviewed-on: https://go-review.googlesource.com/c/go/+/637235
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
2024-12-17 13:28:29 -08:00
Filippo Valsorda
b2c0168893 crypto/internal/fips140/aes/gcm: use aes.EncryptBlockInternal on ppc64x and s390x
Left them out of CL 636775 because I did a search by reference, which
does not span architectures.

Fixes crypto/cipher.TestFIPSServiceIndicator failure on ppc64x and s390x.

For #69536

Change-Id: I34b49705a7099066e8c3871a7a34b394a9298e98
Reviewed-on: https://go-review.googlesource.com/c/go/+/637175
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-17 11:35:53 -08:00
Filippo Valsorda
b9e2ffdcd2 crypto/internal/fips140: add Name and Version
Per ISO/IEC 19790:2012, Section 7.4.3.1.

> A cryptographic module shall [04.12] provide the following services to
> operators.
>
> a) Show module’s versioning information. The cryptographic module
> shall [04.13] output the name or module identifier and the versioning
> information that can be correlated with a validation record (e.g.
> hardware, software and/or firmware versioning information)."

For #69536

Change-Id: I8061f64e4ae60a4666f6abd892cb1301d6bf2452
Reviewed-on: https://go-review.googlesource.com/c/go/+/636558
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-17 11:35:50 -08:00
wangshuo
8790372a8d cmd, go: fix some typos
Change-Id: I0fd54ae5294eb4ef30cdef05adb8825f69077b14
GitHub-Last-Rev: ccfa48cbe4
GitHub-Pull-Request: golang/go#70823
Reviewed-on: https://go-review.googlesource.com/c/go/+/635915
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-17 11:19:09 -08:00
Oleksandr Redko
b057b8872d bytes, strings: add cross-references in docstrings
For newly funcs SplitSeq, SplitAfterSeq, FieldsSeq, FieldsFuncSeq.

Updates #61901.

Change-Id: I3c97bfd9c2250de68aaea348c82a05635ee797af
Reviewed-on: https://go-review.googlesource.com/c/go/+/637176
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-17 11:08:32 -08:00
Oleksandr Redko
e977b83b32 cmd/go/internal/help: use secure link to swig.org
Change-Id: Ifd315128ceeddf92bc16647869c3ace77ed1f430
Reviewed-on: https://go-review.googlesource.com/c/go/+/637195
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-17 10:54:56 -08:00
Damien Neil
4ac8f552e9 syscall, internal/syscall/unix: fix fstatat on linux/mips64
On linux/mips64, the syscall.Stat_t struct does not match the
kernel version of the struct. Functions that operate on a Stat_t
translate between it and the kernel struct.

The fstatat function was not doing this translation.
Make it do so.

Export a syscall.Fstatat on mips64 for usage by
internal/syscall/unix. Perhaps we should just do this on all
architectures, but this is the smaller change for now.

Fixes #70659

Change-Id: I38e36473689be25861953b418c9abc5b270a7bcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/633280
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-17 10:04:38 -08:00
Robert Griesemer
236a0b4ffb spec: explain function invocation and passing of parameters more precisely
- Describe that function invocation allocates space for a functions'
  variables.
- Explain parameter passing in terms of assignments.

Change-Id: Ia693d73a570f7d1aa2ac05e6095b4e602e4e9bf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/635800
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Rob Pike <r@golang.org>
2024-12-17 08:37:52 -08:00
Filippo Valsorda
9f806bb76c go/build: streamline the crypto package graph in TestDependencies
Change-Id: I975243b4897d5161b839f142afbd2a46bfa1fab0
Reviewed-on: https://go-review.googlesource.com/c/go/+/636555
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Bypass: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-12-17 08:07:47 -08:00
qmuntal
0cd833d198 go/build: remove nonexistent package from TestDependencies
crypto/internal/boring/fips140tls is not a package in the Go standard
library, so it should not be listed in TestDependencies.

Change-Id: I6476da397b0204fcbd0a11b27a29112fca4b6023
Reviewed-on: https://go-review.googlesource.com/c/go/+/636415
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-12-17 08:07:44 -08:00
Filippo Valsorda
31e50af5f3 crypto/rsa: revert minimum GenerateKey size to 32 bits
No point in causing breakage even with GODEBUG=rsa1024min=0.

Change-Id: I923254a8c8afaca77be551b19e3555c44ebdbb67
Reviewed-on: https://go-review.googlesource.com/c/go/+/636557
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
2024-12-17 08:05:08 -08:00
Filippo Valsorda
b47ce8b0e9 crypto/cipher: block non-AES CTR and CBC in fips140=only mode
Somehow I had missed these.

For #69536

Change-Id: I5e60b6f052bbfb707742ad15f663517c6c5f68d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/636795
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2024-12-17 08:02:43 -08:00
Filippo Valsorda
dd7a7ba38f crypto/internal/fips140/aes: mark AES-ECB as not approved
NIST SP 800-131Ar3 ipd, scheduled for publication in 2025Q1, marks
AES-ECB as disallowed for encryption, and legacy use for decryption.

There are apparently no details on how the transition is going to work,
so to avoid surprises we just mark direct use of the Block as
non-approved.

We need to use Encrypt from higher level modes without tripping the
service indicator. Within the aes package, we just use the internal
function. For the gcm package we could do something more clever, but
this deep into the freeze, just make an exported function that we commit
to use nowhere else.

I could not figure out a decent way to block ECB on GODEBUG=fips140=only.

For #69536

Change-Id: I972a4b5da8efd0a0ab68d7dd509bec73aa2d6b68
Reviewed-on: https://go-review.googlesource.com/c/go/+/636775
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-17 08:02:39 -08:00
Michael Matloob
427a2401af cmd/go/testdata/script: update test_flags for new test output
With CL 635856, an error for a package missing go files is now caught at
load time rather than at build time, so it's reported differently.
Update the test to check for the correct output unbreak the builders.

For #70820

Change-Id: I91fcac17961635b9a92782caa58c9a6f057a7e02
Reviewed-on: https://go-review.googlesource.com/c/go/+/637115
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-17 07:54:16 -08:00
Ian Lance Taylor
75736cc169 fmt, strconv: document that exponent is always two digits
Except for %b where it is only one.

Fixes #70862

Change-Id: Ic423a799b73bfa534f4083f6544bb9cd639fef06
Reviewed-on: https://go-review.googlesource.com/c/go/+/636915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-17 07:54:13 -08:00
Cherry Mui
1218566fe5 cmd/link: update runtime dependency list
There have been a number of internal packages that the runtime
package depends on. Update the list. We should stop using a hard-
coded list.

Change-Id: I6f9338d6690d955b8200f3301addd0e133a1bfe2
Reviewed-on: https://go-review.googlesource.com/c/go/+/636478
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-12-16 18:19:39 -08:00
Michael Matloob
d92c34a387 cmd/go: don't create test actions for incomplete packages
If a package is incomplete, don't create the actions for building and
testing it. Instead report the errors for the package's dependencies
and report a setup failed error (similar to what we'd to for a load
error when producing the test packages). This produces similar errors to
what were produced by load.CheckPackageErrors while still produing the
test failure actions per package under test.

(I wasn't sure what to do about the last test case in test_setup_error.
I think it should be treated the same as other load errors?)

Fixes #70820

Change-Id: Ie95e3c158c50ed35a1f27237ef3db40502719993
Reviewed-on: https://go-review.googlesource.com/c/go/+/635856
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Matloob <matloob@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2024-12-16 13:43:25 -08:00
Michael Anthony Knyszek
3bd08b9792 runtime: usleep in TestWeakToStrongMarkTermination
There's a subtle bug in this test (big surprise): time.Sleep allocates,
so the time.Sleep(100*time.Millisecond) before unblocking gcMarkDone
might itself end up in gcMarkDone.

Work around this by using usleep here instead.

Fixes #70532.

Change-Id: I4c642ebb12f737cdb0d79ccff64b6059fc3d8b34
Reviewed-on: https://go-review.googlesource.com/c/go/+/636155
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-16 08:57:31 -08:00
Austin Clements
18b5435fc8 testing: don't measure cleanup time after B.Loop
B.Loop resets the timer on the first iteration so that setup code
isn't measured, but it currently leaves the timer running after the
last iteration, meaning that cleanup code will still be measured. Fix
this by stopping the timer when B.Loop returns false to indicate the
end of the benchmark.

Updates #61515

Change-Id: I0e0502cb2ce3c24cf872682b88d74e8be2c4529b
Reviewed-on: https://go-review.googlesource.com/c/go/+/635898
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-12-15 21:41:28 -08:00
Austin Clements
c1f2542c8b testing: improve B.Loop test
This moves the B.Loop test from package testing_test to package
testing, where it can check on more of the internals of the benchmark
state.

Updates #61515.

Change-Id: Ia32d7104526125c5e8a1e35dab7660008afcbf80
Reviewed-on: https://go-review.googlesource.com/c/go/+/635897
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2024-12-15 21:41:26 -08:00
Austin Clements
6bd56fcaeb testing: improve b.Loop example
The current b.Loop example doesn't focus on the basic usage of b.Loop.
Replace this with a new example that uses (slightly) more realistic
things to demonstrate the most salient points of b.Loop.

We also move the example into an example file so that we can write a
real Benchmark function and a real function to be benchmarks, which
makes this much closer to what a user would actually write.

Updates #61515.

Change-Id: I4d830b3bfe3eb3cd8cdecef469fea0541baebb43
Reviewed-on: https://go-review.googlesource.com/c/go/+/635896
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-15 21:41:23 -08:00
Austin Clements
090748d6c7 testing: improve B.Loop docs, use B.Loop in examples
This updates the testing documentation to frame B.Loop as the
canonical way to write benchmarks. We retain documentation on b.N
benchmarks because people will definitely continue to see them (and
write them), but it's demoted to clearly second class.

This also attempts to clarify and refine the B.Loop documentation
itself.

Updates #61515
Fixes #70787

Change-Id: If5123435bfe3a5883a753119ecdf7bbc41afd499
Reviewed-on: https://go-review.googlesource.com/c/go/+/635895
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Caleb Spare <cespare@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
2024-12-15 21:41:19 -08:00
Austin Clements
e39e965e0e cmd/go: drop FailedBuild field if gotestjsonbuildtext=1
go test -json has two new effects in Go 1.24: it implies go build
-json, and it adds a FailedBuild field in test events. For
compatibility, CL 629335 added gotestjsonbuildtext=1, which disables
the implicit go build -json, but that CL didn't affect the FailedBuild
field. In principle this shouldn't matter because it's just another
JSON field, but just so we don't have to worry about some intermediate
behavior, this CL makes gotestjsonbuildtext=1 disable the FailedBuild
field as well.

Updates #62067
Updates #70402

Change-Id: I006d1ea0468980ee2564495324e8b4ed082898af
Reviewed-on: https://go-review.googlesource.com/c/go/+/635899
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-12-13 15:07:27 -08:00
Michael Pratt
08770a5b94 cmd/link: make dwarf name slice index self-describing
cmd/compile/internal/dwarfgen.createComplexVar does it this way, which
has the nice property of documenting the expected prefix.

This is primarily for newtype, since defgotype checks for the prefix
immediately prior, but I changed both for consistency.

Change-Id: I49fa7c6166bdcbd19aaf91fe3dc20537080afcfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/635177
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2024-12-13 12:32:22 -08:00
Filippo Valsorda
c4f356dd86 crypto/ecdsa: fix s390x assembly with P-521
I had incorrectly assumed that the blocksize was always the same as the
curve field size. This is true of P-256 and P-384, but not P-521.

Fixes #70660
Fixes #70771

Change-Id: Idb6b510fcd3dd42d9b1e6cf42c1bb92e0ce8bd07
Reviewed-on: https://go-review.googlesource.com/c/go/+/636015
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2024-12-13 11:22:11 -08:00
Filippo Valsorda
08725f9de2 crypto/internal/cryptotest: skip TestAllocations on s390x
TestXAESAllocations fails like #70448, and crypto/rand's fails in FIPS
mode. We can't keep chasing these without even a LUCI builder.

Updates #67307

Change-Id: I5d0edddf470180a321dec55cabfb018db62eb940
Reviewed-on: https://go-review.googlesource.com/c/go/+/636055
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2024-12-13 11:20:55 -08:00
thepudds
1cbfe8c482 fmt: add more function and allocation tests
This is part of a series of CLs that aim to reduce how often interface
arguments escape for the print functions in fmt.

Currently, method values are one of two reasons reflect.Value.Interface
always escapes its reflect.Value.

Our later CLs modify behavior around method values, so we add some tests
of function formatting (including method values) to help reduce the
chances of breaking behavior later.

We also add in some allocation tests focused on interface arguments for
the print functions. These currently do not show any improvements
compared to Go 1.21.

These tests were originally in a later CL in our stack (CL 528538),
but we split them out into this CL and moved them earlier in the stack.

Updates #8618

Change-Id: Iec51abc3b7f86a2711e7497fc2fb7a678b9f8f73
Reviewed-on: https://go-review.googlesource.com/c/go/+/529575
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-13 11:20:04 -08:00
Gopher Robot
16afa6a740 [release-branch.go1.24] go1.24rc1
Change-Id: Ia3b0a8ec25312b73879d2561a2b4d1cfc648c295
Reviewed-on: https://go-review.googlesource.com/c/go/+/636036
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Gopher Robot <gobot@golang.org>
TryBot-Bypass: Carlos Amedee <carlos@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-12-13 08:52:10 -08:00
Michael Pratt
8391579ece runtime: migrate missing map linkname allowlists
The swissmap implementation forgot to copy some of the linkname
allowlists from the old implementation. Copy them from map_noswiss.go.
Some were missing linkname entirely; others were linknamed but missing
the hall of shame comment.

For #54766.

Change-Id: Icc715384123e73d868b4cb729ab639abcd6bbfd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/635995
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-13 07:53:26 -08:00
Robert Griesemer
80a2982a80 spec: align EBNF rules consistently (cosmetic change)
Change-Id: Ib1b14b8880c6de5606f7f425a5fc1c8749d8a4b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/635799
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2024-12-12 15:39:44 -08:00
Ian Lance Taylor
38e9a671d7 syscall: on freebsd-386 only update written for certain errors
Testing on the freebsd-386 gomote seems to show that sendfile returns
a non-zero number of bytes written even when it returns EINVAL.
This confuses the caller. Change the Go code to only return non-zero
on success or EINTR or EAGAIN, which are the only cases where the
man page says that sendfile updates the number of bytes.

For #70763

Change-Id: Icc04e6286b5b29a2029237711d50fe4973234f0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/635815
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-12 14:43:37 -08:00
Oleksandr Redko
6f7a4540b1 net: fix example function name for IP.To4
Change-Id: Ia9a2c3a9f53792173cd1fb9f8e1a078fe3444945
Reviewed-on: https://go-review.googlesource.com/c/go/+/635136
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-12 13:01:47 -08:00
Cherry Mui
14e5093ee5 cmd/internal/obj: disallow linknamed access to builtin symbols
Currently, a symbol reference is counted as a reference to a
builtin symbol if the name matches a builtin. Usually builtin
references are generated by the compiler. But one could manually
write one with linkname. Since the list of builtin functions are
subject to change from time to time, we don't want users to depend
on their names. So we don't count a linknamed reference as a
builtin reference, and instead, count it as a named reference, so
it is checked by the linker.

Change-Id: Id3543295185c6bbd73a8cff82afb8f9cb4fd6f71
Reviewed-on: https://go-review.googlesource.com/c/go/+/635755
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-12 12:58:47 -08:00
Cherry Mui
fb764cdad0 cmd/link: block new standard library linknames
In Go 1.24 we added a number of new linknames for standard library
internal uses. Add them to the linker's blocklist to keep them
internal.

Change-Id: Ibb7fa095506c161604e978ae196a7cf248475b2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/635676
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2024-12-12 11:54:53 -08:00
Carlos Amedee
817d7bdc0a [release-branch.go1.24] all: merge master (9118060) into release-branch.go1.24
Merge List:

+ 2024-12-12 9118060040 builtin: document clear is a no-op if its argument's value is nil
+ 2024-12-11 077d51909d internal/poll: in SendFile treat ENOTSUP like EOPNOTSUPP
+ 2024-12-11 fafd4477f3 cmd/cgo: use full prototype for main in C code

Change-Id: I4c4941eff4a1e842920eb9be47d28351af0e4c36
2024-12-12 12:06:37 -05:00
apocelipes
9118060040 builtin: document clear is a no-op if its argument's value is nil
Just like the builtin function delete's comment does.

Change-Id: Id94a3aaa03c7b09594bae2b1af901d9060d9e255
GitHub-Last-Rev: 30cbebca96
GitHub-Pull-Request: golang/go#70801
Reviewed-on: https://go-review.googlesource.com/c/go/+/635535
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
2024-12-12 07:43:21 -08:00
Ian Lance Taylor
077d51909d internal/poll: in SendFile treat ENOTSUP like EOPNOTSUPP
Fixes #70763

Change-Id: Ifb79b5b0529f7977df0fe1b59d224b8b31df2c9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/635396
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-11 17:52:03 -08:00
Ian Lance Taylor
fafd4477f3 cmd/cgo: use full prototype for main in C code
Avoids pedantic errors from modern C compilers.

Fixes #70769

Change-Id: Ibe0d9960e998eb0346b97d7bd69eb7de0d0e6c60
Reviewed-on: https://go-review.googlesource.com/c/go/+/635095
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-11 15:57:34 -08:00
Carlos Amedee
14bb1e11b9 [release-branch.go1.24] all: merge master (0ca521f) into release-branch.go1.24
Merge List:

+ 2024-12-11 0ca521f9c1 debug/elf: adjust version API per issue discussion

Change-Id: Ibd6f628528dd366837ad0bbacad624474eee0088
2024-12-11 18:55:28 -05:00
Ian Lance Taylor
0ca521f9c1 debug/elf: adjust version API per issue discussion
This updates the new version API for the discussion on #63952.

This change reveals that in fact none of the tests set the
VERSYM_HIDDEN bit. The code before this CL set the hidden flag
for symbols that appear in DynamicVersionNeed, but that is not
an accurate representation of the ELF. The readelf program
does print undefined symbols that way (with a single '@'),
but that doesn't mean that the hidden flag is set.
Leaving tests with the hidden bit set for later.

For #63952

Change-Id: Ida60831e0c9922dfc10f10c7a64bc76a2b197537
Reviewed-on: https://go-review.googlesource.com/c/go/+/635079
Reviewed-by: Austin Clements <austin@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-11 15:40:12 -08:00
Carlos Amedee
2297c34cdf [release-branch.go1.24] all: merge master (c93477b) into release-branch.go1.24
Merge List:

+ 2024-12-11 c93477b5e5 crypto: use provided random Reader in FIPS mode
+ 2024-12-11 3104b6adbb log/slog: make DiscardHandler example package-level
+ 2024-12-11 5424f2e200 cmd/go: add more tests for GOAUTH's user provided authenticator
+ 2024-12-11 d5c1333eb4 net/http: document zero value of Protocols
+ 2024-12-11 a7c4cadce0 cmd/compile: update broken link
+ 2024-12-11 979c1cfbe8 net: avoid unnecessary interface lookup fetching all interface addresses
+ 2024-12-11 e424d78c3d internal/goos: fix bug in gengoos.go
+ 2024-12-11 6c25cf1c5f cmd/internal/objfile: break out dissassemblers to another package
+ 2024-12-11 e0c76d95ab syscall: remove a wrong comment in Clearenv
+ 2024-12-11 a9922d096f reflect: consistently document when value must be settable
+ 2024-12-10 4ce116a884 runtime: avoid panic in expired synctest timer chan read
+ 2024-12-10 e6de1b2deb html/template: escape script tags in JS errors case insensitively
+ 2024-12-10 fce17b0c77 crypto/internal/fips140/ecdsa: fix reseed_counter check for HMAC_DRBG_Generate_algorithm
+ 2024-12-09 d87878c62b runtime: make special offset a uintptr
+ 2024-12-09 6705ac6885 runtime: remove datadog-agent from prof labels hall of shame
+ 2024-12-09 07398d2e57 weak: align weak.Pointer documentation with runtime.AddCleanup
+ 2024-12-09 e3e1d73528 bufio: make the description of Peek's behavior better
+ 2024-12-09 e79b2e1e3a cmd/go: document the build cache as safe for concurrent use
+ 2024-12-08 c8fb6ae617 lib/wasm: provide fs.constants.O_DIRECTORY definition
+ 2024-12-07 8c3e391573 runtime: improve AddCleanup documentation
+ 2024-12-07 04cdaa9984 cmd/go: document c-shared buildmode for building WASI library/reactor
+ 2024-12-06 312f7c1bd3 runtime: add note that Callers never returns an entry PC

Change-Id: I52e035228121de3d8219ab13f195d4293daaaa34
2024-12-11 17:45:39 -05:00
Filippo Valsorda
c93477b5e5 crypto: use provided random Reader in FIPS mode
This removes the difference in behavior between FIPS mode on and off.

Instead of the sentinel type we could have moved the Reader to the
drbg package and checked for equality, but then we would have locked the
crypto/rand.Reader implementation to the one in the FIPS module (which
we might have to support for years).

In internal/ed25519.GenerateKey we remove the random parameter entirely,
since that function is not actually used by crypto/ed25519.GenerateKey,
which instead commits to being deterministic.

Fixes #70772

Change-Id: Ic1c7ca2c1cd59eb9cd090a8b235c0ce218921ac5
Reviewed-on: https://go-review.googlesource.com/c/go/+/635195
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-11 13:26:50 -08:00
Jonathan Amsterdam
3104b6adbb log/slog: make DiscardHandler example package-level
Fixes #70782.

Change-Id: I8e8b763040bd10147eb7d1a30ac0774e28f90911
Reviewed-on: https://go-review.googlesource.com/c/go/+/635217
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-11 13:06:33 -08:00
Sam Thanawalla
5424f2e200 cmd/go: add more tests for GOAUTH's user provided authenticator
For #26232
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: I4b6eb63d4c1d71983e1ae764a6a38744a5f01317
Reviewed-on: https://go-review.googlesource.com/c/go/+/635255
Auto-Submit: Sam Thanawalla <samthanawalla@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2024-12-11 12:29:07 -08:00
Damien Neil
d5c1333eb4 net/http: document zero value of Protocols
For #67814

Change-Id: I182e9c7e720493adb9d2384336e757dace818525
Reviewed-on: https://go-review.googlesource.com/c/go/+/635335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2024-12-11 12:15:29 -08:00
Ian Lance Taylor
a7c4cadce0 cmd/compile: update broken link
Fixes #70778

Change-Id: Ie5ed53aa39446beb0316eb134cc705ea06b37435
Reviewed-on: https://go-review.googlesource.com/c/go/+/635295
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-12-11 10:13:44 -08:00
Antonio Ojea
979c1cfbe8 net: avoid unnecessary interface lookup fetching all interface addresses
InterfaceAddrs returns a list of the system's unicast interface addresses.

In order to do so, the function reuses the existing helpers and
list first all addresses with the netlink call RTM_GETADDR, then
all interfaces with RTM_GETLINK, and later it merge both lists
(each address references an interface).

However, the list of interfaces and addresses are obtained at
different times and there can be inconsistencies and, if an
address references an interface that is not present in the list
of interfaces, the function fails with an error.

Since the function InterfaceAddress is only about the system
addresses, there is no need to list all the interfaces, and we can
obtain the list of addresses directly from the netlink call RTM_GETADDR.
There is no need to correlate this list with the list of interfaces, as
the OS is the source of truth and should be the one providing the
consistency between addresses and interfaces.

Fixes #51934

Change-Id: I3b816e8146b1c07fdfe1bf6af338f001ef75734f
Reviewed-on: https://go-review.googlesource.com/c/go/+/635196
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-11 10:02:08 -08:00
zfdx123
e424d78c3d internal/goos: fix bug in gengoos.go
CL 601357 mistakenly added an extra period.

Change-Id: I54db621663797f094059a4eb86bf5d9626fa59d6
GitHub-Last-Rev: c756e0a824
GitHub-Pull-Request: golang/go#70733
Reviewed-on: https://go-review.googlesource.com/c/go/+/634517
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-12-11 09:54:18 -08:00
Cherry Mui
6c25cf1c5f cmd/internal/objfile: break out dissassemblers to another package
Currently, cmd/internal/objfile provides dissassembly routines for
various architectures, which depend on dissassemblers from x/arch.
cmd/internal/objfile is imported in tools that need dissassembly
(objdump, pprof) and tools that don't need dissassembly (nm,
addr2line). Adding/improving disassembly support for more
architectures can cause binary size increase, and for some tools
(nm, addr2line) it is not necessary.

This CL breaks out dissassembly routines to a different package,
which is only imported in tools that need dissassembly. Other
tools can depend on cmd/internal/objfile without the disassembly
code from x/arch.

This reduces binary sizes for those tools. On darwin/arm64,

                                 old         new
cmd/addr2line                  4554418     3648882   -20%
cmd/addr2line (-ldflags=-w)    3464626     2641650   -24%
cmd/nm                         4503874     3616722   -20%
cmd/nm (-ldflags=-w)           3430594     2609490   -24%

For #70699.

Change-Id: Ie45d5d5c5500c5f3882e8b3c4e6eb81f0d815292
Reviewed-on: https://go-review.googlesource.com/c/go/+/634916
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
2024-12-11 08:53:20 -08:00
Kir Kolyshkin
e0c76d95ab syscall: remove a wrong comment in Clearenv
The comment being removed was added by commit ff3173849e
(which predates Gerrit and Rietveld, so no CL link), and
at the time it made sense.

Since CL 148370043 (and up to the current implementation of Clearenv)
the env map, which is populated by copyenv, is actually used, so the
comment is no longer valid.

It is also misleading, so it's best to remove it.

Change-Id: I8bd2e8bca6262759538e5bcbd396f0c71cca6a4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/635078
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-11 07:58:51 -08:00
Ian Lance Taylor
a9922d096f reflect: consistently document when value must be settable
Fixes #70760

Change-Id: Ia00723698b7e502fa2c63f8f1dbe1143af22e0a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/634799
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-12-11 04:00:12 +00:00
Michael Anthony Knyszek
26682773ca [release-branch.go1.24] update codereview.cfg for release-branch.go1.24
Change-Id: I63ffca43a935bc5ff060f19c01152a20182cba03
Reviewed-on: https://go-review.googlesource.com/c/go/+/634317
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2024-12-06 21:58:36 +00:00
323 changed files with 6429 additions and 2590 deletions

2
VERSION Normal file
View File

@@ -0,0 +1,2 @@
go1.24.0
time 2025-02-10T23:33:55Z

View File

@@ -106,33 +106,26 @@ pkg debug/elf, const VER_FLG_INFO = 4 #63952
pkg debug/elf, const VER_FLG_INFO DynamicVersionFlag #63952
pkg debug/elf, const VER_FLG_WEAK = 2 #63952
pkg debug/elf, const VER_FLG_WEAK DynamicVersionFlag #63952
pkg debug/elf, const VerFlagGlobal = 2 #63952
pkg debug/elf, const VerFlagGlobal SymbolVersionFlag #63952
pkg debug/elf, const VerFlagHidden = 4 #63952
pkg debug/elf, const VerFlagHidden SymbolVersionFlag #63952
pkg debug/elf, const VerFlagLocal = 1 #63952
pkg debug/elf, const VerFlagLocal SymbolVersionFlag #63952
pkg debug/elf, const VerFlagNone = 0 #63952
pkg debug/elf, const VerFlagNone SymbolVersionFlag #63952
pkg debug/elf, method (*File) DynamicVersionNeeds() ([]DynamicVersionNeed, error) #63952
pkg debug/elf, method (*File) DynamicVersions() ([]DynamicVersion, error) #63952
pkg debug/elf, type DynamicVersion struct #63952
pkg debug/elf, type DynamicVersion struct, Deps []string #63952
pkg debug/elf, type DynamicVersion struct, Flags DynamicVersionFlag #63952
pkg debug/elf, type DynamicVersion struct, Name string #63952
pkg debug/elf, type DynamicVersion struct, Index uint16 #63952
pkg debug/elf, type DynamicVersion struct, Version uint16 #63952
pkg debug/elf, type DynamicVersionDep struct #63952
pkg debug/elf, type DynamicVersionDep struct, Dep string #63952
pkg debug/elf, type DynamicVersionDep struct, Flags DynamicVersionFlag #63952
pkg debug/elf, type DynamicVersionDep struct, Other uint16 #63952
pkg debug/elf, type DynamicVersionDep struct, Index uint16 #63952
pkg debug/elf, type DynamicVersionFlag uint16 #63952
pkg debug/elf, type DynamicVersionNeed struct #63952
pkg debug/elf, type DynamicVersionNeed struct, Name string #63952
pkg debug/elf, type DynamicVersionNeed struct, Needs []DynamicVersionDep #63952
pkg debug/elf, type DynamicVersionNeed struct, Version uint16 #63952
pkg debug/elf, type Symbol struct, VersionFlags SymbolVersionFlag #63952
pkg debug/elf, type Symbol struct, VersionIndex int16 #63952
pkg debug/elf, type SymbolVersionFlag uint8 #63952
pkg debug/elf, type Symbol struct, HasVersion bool #63952
pkg debug/elf, type Symbol struct, VersionIndex VersionIndex #63952
pkg debug/elf, method (VersionIndex) Index() uint16 #63952
pkg debug/elf, method (VersionIndex) IsHidden() bool #63952
pkg debug/elf, type VersionIndex uint16 #63952
pkg encoding, type BinaryAppender interface { AppendBinary } #62384
pkg encoding, type BinaryAppender interface, AppendBinary([]uint8) ([]uint8, error) #62384
pkg encoding, type TextAppender interface { AppendText } #62384

View File

@@ -1 +1,2 @@
branch: master
branch: release-branch.go1.24
parent-branch: master

View File

@@ -1,6 +1,6 @@
<!--{
"Title": "The Go Programming Language Specification",
"Subtitle": "Language version go1.24 (Nov 20, 2024)",
"Subtitle": "Language version go1.24 (Dec 30, 2024)",
"Path": "/ref/spec"
}-->
@@ -798,7 +798,6 @@ If a variable has not yet been assigned a value, its value is the
<a href="#The_zero_value">zero value</a> for its type.
</p>
<h2 id="Types">Types</h2>
<p>
@@ -810,12 +809,12 @@ from existing types.
</p>
<pre class="ebnf">
Type = TypeName [ TypeArgs ] | TypeLit | "(" Type ")" .
TypeName = identifier | QualifiedIdent .
TypeArgs = "[" TypeList [ "," ] "]" .
TypeList = Type { "," Type } .
TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType |
SliceType | MapType | ChannelType .
Type = TypeName [ TypeArgs ] | TypeLit | "(" Type ")" .
TypeName = identifier | QualifiedIdent .
TypeArgs = "[" TypeList [ "," ] "]" .
TypeList = Type { "," Type } .
TypeLit = ArrayType | StructType | PointerType | FunctionType | InterfaceType |
SliceType | MapType | ChannelType .
</pre>
<p>
@@ -1200,7 +1199,7 @@ type (
<p>
A pointer type denotes the set of all pointers to <a href="#Variables">variables</a> of a given
type, called the <i>base type</i> of the pointer.
The value of an uninitialized pointer is <code>nil</code>.
The <a href="#Representation_of_values">value</a> of an uninitialized pointer is <code>nil</code>.
</p>
<pre class="ebnf">
@@ -1216,18 +1215,18 @@ BaseType = Type .
<h3 id="Function_types">Function types</h3>
<p>
A function type denotes the set of all functions with the same parameter
and result types. The value of an uninitialized variable of function type
is <code>nil</code>.
A function type denotes the set of all functions with the same parameter and result types.
The <a href="#Representation_of_values">value</a> of an uninitialized variable of function
type is <code>nil</code>.
</p>
<pre class="ebnf">
FunctionType = "func" Signature .
Signature = Parameters [ Result ] .
Result = Parameters | Type .
Parameters = "(" [ ParameterList [ "," ] ] ")" .
ParameterList = ParameterDecl { "," ParameterDecl } .
ParameterDecl = [ IdentifierList ] [ "..." ] Type .
FunctionType = "func" Signature .
Signature = Parameters [ Result ] .
Result = Parameters | Type .
Parameters = "(" [ ParameterList [ "," ] ] ")" .
ParameterList = ParameterDecl { "," ParameterDecl } .
ParameterDecl = [ IdentifierList ] [ "..." ] Type .
</pre>
<p>
@@ -1267,7 +1266,8 @@ An interface type defines a <i>type set</i>.
A variable of interface type can store a value of any type that is in the type
set of the interface. Such a type is said to
<a href="#Implementing_an_interface">implement the interface</a>.
The value of an uninitialized variable of interface type is <code>nil</code>.
The <a href="#Representation_of_values">value</a> of an uninitialized variable of
interface type is <code>nil</code>.
</p>
<pre class="ebnf">
@@ -1630,12 +1630,12 @@ implements the interface.
A map is an unordered group of elements of one type, called the
element type, indexed by a set of unique <i>keys</i> of another type,
called the key type.
The value of an uninitialized map is <code>nil</code>.
The <a href="#Representation_of_values">value</a> of an uninitialized map is <code>nil</code>.
</p>
<pre class="ebnf">
MapType = "map" "[" KeyType "]" ElementType .
KeyType = Type .
MapType = "map" "[" KeyType "]" ElementType .
KeyType = Type .
</pre>
<p>
@@ -1693,7 +1693,7 @@ to communicate by
<a href="#Send_statements">sending</a> and
<a href="#Receive_operator">receiving</a>
values of a specified element type.
The value of an uninitialized channel is <code>nil</code>.
The <a href="#Representation_of_values">value</a> of an uninitialized channel is <code>nil</code>.
</p>
<pre class="ebnf">
@@ -1772,6 +1772,57 @@ received in the order sent.
<h2 id="Properties_of_types_and_values">Properties of types and values</h2>
<h3 id="Representation_of_values">Representation of values</h3>
<p>
Values of predeclared types (see below for the interfaces <code>any</code>
and <code>error</code>), arrays, and structs are self-contained:
Each such value contains a complete copy of all its data,
and <a href="#Variables">variables</a> of such types store the entire value.
For instance, an array variable provides the storage (the variables)
for all elements of the array.
The respective <a href="#The_zero_value">zero values</a> are specific to the
value's types; they are never <code>nil</code>.
</p>
<p>
Non-nil pointer, function, slice, map, and channel values contain references
to underlying data which may be shared by multiple values:
</p>
<ul>
<li>
A pointer value is a reference to the variable holding
the pointer base type value.
</li>
<li>
A function value contains references to the (possibly
<a href="#Function_literals">anonymous</a>) function
and enclosed variables.
</li>
<li>
A slice value contains the slice length, capacity, and
a reference to its <a href="#Slice_types">underlying array</a>.
</li>
<li>
A map or channel value is a reference to the implementation-specific
data structure of the map or channel.
</li>
</ul>
<p>
An interface value may be self-contained or contain references to underlying data
depending on the interface's <a href="#Variables">dynamic type</a>.
The predeclared identifier <code>nil</code> is the zero value for types whose values
can contain references.
</p>
<p>
When multiple values share underlying data, changing one value may change another.
For instance, changing an element of a <a href="#Slice_types">slice</a> will change
that element in the underlying array for all slices that share the array.
</p>
<h3 id="Underlying_types">Underlying types</h3>
<p>
@@ -2176,7 +2227,7 @@ within matching brace brackets.
</p>
<pre class="ebnf">
Block = "{" StatementList "}" .
Block = "{" StatementList "}" .
StatementList = { Statement ";" } .
</pre>
@@ -2233,8 +2284,8 @@ and like the blank identifier it does not introduce a new binding.
</p>
<pre class="ebnf">
Declaration = ConstDecl | TypeDecl | VarDecl .
TopLevelDecl = Declaration | FunctionDecl | MethodDecl .
Declaration = ConstDecl | TypeDecl | VarDecl .
TopLevelDecl = Declaration | FunctionDecl | MethodDecl .
</pre>
<p>
@@ -2679,9 +2730,9 @@ in square brackets rather than parentheses
</p>
<pre class="ebnf">
TypeParameters = "[" TypeParamList [ "," ] "]" .
TypeParamList = TypeParamDecl { "," TypeParamDecl } .
TypeParamDecl = IdentifierList TypeConstraint .
TypeParameters = "[" TypeParamList [ "," ] "]" .
TypeParamList = TypeParamDecl { "," TypeParamDecl } .
TypeParamDecl = IdentifierList TypeConstraint .
</pre>
<p>
@@ -2819,7 +2870,7 @@ values or variables, or components of other, non-interface types.
<p>
A type argument <code>T</code><i> satisfies</i> a type constraint <code>C</code>
if <code>T</code> is an element of the type set defined by <code>C</code>; i.e.,
if <code>T</code> is an element of the type set defined by <code>C</code>; in other words,
if <code>T</code> <a href="#Implementing_an_interface">implements</a> <code>C</code>.
As an exception, a <a href="#Comparison_operators">strictly comparable</a>
type constraint may also be satisfied by a <a href="#Comparison_operators">comparable</a>
@@ -2869,8 +2920,8 @@ binds corresponding identifiers to them, and gives each a type and an initial va
</p>
<pre class="ebnf">
VarDecl = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) .
VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
VarDecl = "var" ( VarSpec | "(" { VarSpec ";" } ")" ) .
VarSpec = IdentifierList ( Type [ "=" ExpressionList ] | "=" ExpressionList ) .
</pre>
<pre>
@@ -2899,7 +2950,7 @@ initialization value in the assignment.
If that value is an untyped constant, it is first implicitly
<a href="#Conversions">converted</a> to its <a href="#Constants">default type</a>;
if it is an untyped boolean value, it is first implicitly converted to type <code>bool</code>.
The predeclared value <code>nil</code> cannot be used to initialize a variable
The predeclared identifier <code>nil</code> cannot be used to initialize a variable
with no explicit type.
</p>
@@ -3210,15 +3261,15 @@ Each element may optionally be preceded by a corresponding key.
</p>
<pre class="ebnf">
CompositeLit = LiteralType LiteralValue .
LiteralType = StructType | ArrayType | "[" "..." "]" ElementType |
SliceType | MapType | TypeName [ TypeArgs ] .
LiteralValue = "{" [ ElementList [ "," ] ] "}" .
ElementList = KeyedElement { "," KeyedElement } .
KeyedElement = [ Key ":" ] Element .
Key = FieldName | Expression | LiteralValue .
FieldName = identifier .
Element = Expression | LiteralValue .
CompositeLit = LiteralType LiteralValue .
LiteralType = StructType | ArrayType | "[" "..." "]" ElementType |
SliceType | MapType | TypeName [ TypeArgs ] .
LiteralValue = "{" [ ElementList [ "," ] ] "}" .
ElementList = KeyedElement { "," KeyedElement } .
KeyedElement = [ Key ":" ] Element .
Key = FieldName | Expression | LiteralValue .
FieldName = identifier .
Element = Expression | LiteralValue .
</pre>
<p>
@@ -3450,22 +3501,21 @@ Primary expressions are the operands for unary and binary expressions.
</p>
<pre class="ebnf">
PrimaryExpr =
Operand |
Conversion |
MethodExpr |
PrimaryExpr Selector |
PrimaryExpr Index |
PrimaryExpr Slice |
PrimaryExpr TypeAssertion |
PrimaryExpr Arguments .
PrimaryExpr = Operand |
Conversion |
MethodExpr |
PrimaryExpr Selector |
PrimaryExpr Index |
PrimaryExpr Slice |
PrimaryExpr TypeAssertion |
PrimaryExpr Arguments .
Selector = "." identifier .
Index = "[" Expression [ "," ] "]" .
Slice = "[" [ Expression ] ":" [ Expression ] "]" |
"[" [ Expression ] ":" Expression ":" Expression "]" .
TypeAssertion = "." "(" Type ")" .
Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" .
Selector = "." identifier .
Index = "[" Expression [ "," ] "]" .
Slice = "[" [ Expression ] ":" [ Expression ] "]" |
"[" [ Expression ] ":" Expression ":" Expression "]" .
TypeAssertion = "." "(" Type ")" .
Arguments = "(" [ ( ExpressionList | Type [ "," ExpressionList ] ) [ "..." ] [ "," ] ] ")" .
</pre>
@@ -3638,8 +3688,8 @@ argument that is the receiver of the method.
</p>
<pre class="ebnf">
MethodExpr = ReceiverType "." MethodName .
ReceiverType = Type .
MethodExpr = ReceiverType "." MethodName .
ReceiverType = Type .
</pre>
<p>
@@ -4230,8 +4280,7 @@ calls <code>f</code> with arguments <code>a1, a2, … an</code>.
Except for one special case, arguments must be single-valued expressions
<a href="#Assignability">assignable</a> to the parameter types of
<code>F</code> and are evaluated before the function is called.
The type of the expression is the result type
of <code>F</code>.
The type of the expression is the result type of <code>F</code>.
A method invocation is similar but the method itself
is specified as a selector upon a value of the receiver type for
the method.
@@ -4252,9 +4301,14 @@ or used as a function value.
<p>
In a function call, the function value and arguments are evaluated in
<a href="#Order_of_evaluation">the usual order</a>.
After they are evaluated, the parameters of the call are passed by value to the function
After they are evaluated, new storage is allocated for the function's
<a href="#Variables">variables</a>, which includes its parameters
and results.
Then, the arguments of the call are <i>passed</i> to the function,
which means that they are <a href="#Assignment_statements">assigned</a>
to their corresponding function parameters,
and the called function begins execution.
The return parameters of the function are passed by value
The return parameters of the function are passed
back to the caller when the function returns.
</p>
@@ -4268,9 +4322,9 @@ As a special case, if the return values of a function or method
<code>g</code> are equal in number and individually
assignable to the parameters of another function or method
<code>f</code>, then the call <code>f(g(<i>parameters_of_g</i>))</code>
will invoke <code>f</code> after binding the return values of
<code>g</code> to the parameters of <code>f</code> in order. The call
of <code>f</code> must contain no parameters other than the call of <code>g</code>,
will invoke <code>f</code> after passing the return values of
<code>g</code> to the parameters of <code>f</code> in order.
The call of <code>f</code> must contain no parameters other than the call of <code>g</code>,
and <code>g</code> must have at least one return value.
If <code>f</code> has a final <code>...</code> parameter, it is
assigned the return values of <code>g</code> that remain after
@@ -4316,7 +4370,7 @@ If <code>f</code> is <a href="#Function_types">variadic</a> with a final
parameter <code>p</code> of type <code>...T</code>, then within <code>f</code>
the type of <code>p</code> is equivalent to type <code>[]T</code>.
If <code>f</code> is invoked with no actual arguments for <code>p</code>,
the value passed to <code>p</code> is <code>nil</code>.
the value <a href="#Calls">passed</a> to <code>p</code> is <code>nil</code>.
Otherwise, the value passed is a new slice
of type <code>[]T</code> with a new underlying array whose successive elements
are the actual arguments, which all must be <a href="#Assignability">assignable</a>
@@ -5632,6 +5686,8 @@ myString([]myRune{0x1f30e}) // "\U0001f30e" == "🌎"
<li>
Converting a value of a string type to a slice of bytes type
yields a non-nil slice whose successive elements are the bytes of the string.
The <a href="#Length_and_capacity">capacity</a> of the resulting slice is
implementation-specific and may be larger than the slice length.
<pre>
[]byte("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
@@ -5647,6 +5703,8 @@ bytes("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}
<li>
Converting a value of a string type to a slice of runes type
yields a slice containing the individual Unicode code points of the string.
The <a href="#Length_and_capacity">capacity</a> of the resulting slice is
implementation-specific and may be larger than the slice length.
<pre>
[]rune(myString("白鵬翔")) // []rune{0x767d, 0x9d6c, 0x7fd4}
@@ -5848,7 +5906,7 @@ Otherwise, when evaluating the <a href="#Operands">operands</a> of an
expression, assignment, or
<a href="#Return_statements">return statement</a>,
all function calls, method calls,
<a href="#Receive operator">receive operations</a>,
<a href="#Receive_operator">receive operations</a>,
and <a href="#Logical_operators">binary logical operations</a>
are evaluated in lexical left-to-right order.
</p>
@@ -5916,11 +5974,10 @@ Statements control execution.
</p>
<pre class="ebnf">
Statement =
Declaration | LabeledStmt | SimpleStmt |
GoStmt | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt |
FallthroughStmt | Block | IfStmt | SwitchStmt | SelectStmt | ForStmt |
DeferStmt .
Statement = Declaration | LabeledStmt | SimpleStmt |
GoStmt | ReturnStmt | BreakStmt | ContinueStmt | GotoStmt |
FallthroughStmt | Block | IfStmt | SwitchStmt | SelectStmt | ForStmt |
DeferStmt .
SimpleStmt = EmptyStmt | ExpressionStmt | SendStmt | IncDecStmt | Assignment | ShortVarDecl .
</pre>
@@ -6132,7 +6189,7 @@ matching number of variables.
<pre class="ebnf">
Assignment = ExpressionList assign_op ExpressionList .
assign_op = [ add_op | mul_op ] "=" .
assign_op = [ add_op | mul_op ] "=" .
</pre>
<p>
@@ -6261,6 +6318,26 @@ to the type of the operand to which it is assigned, with the following special c
</li>
</ol>
<p>
When a value is assigned to a variable, only the data that is stored in the variable
is replaced. If the value contains a <a href="#Representation_of_values">reference</a>,
the assignment copies the reference but does not make a copy of the referenced data
(such as the underlying array of a slice).
</p>
<pre>
var s1 = []int{1, 2, 3}
var s2 = s1 // s2 stores the slice descriptor of s1
s1 = s1[:1] // s1's length is 1 but it still shares its underlying array with s2
s2[0] = 42 // setting s2[0] changes s1[0] as well
fmt.Println(s1, s2) // prints [42] [42 2 3]
var m1 = make(map[string]int)
var m2 = m1 // m2 stores the map descriptor of m1
m1["foo"] = 42 // setting m1["foo"] changes m2["foo"] as well
fmt.Println(m2["foo"]) // prints 42
</pre>
<h3 id="If_statements">If statements</h3>
<p>
@@ -6548,7 +6625,7 @@ The iteration may be controlled by a single condition, a "for" clause, or a "ran
</p>
<pre class="ebnf">
ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
ForStmt = "for" [ Condition | ForClause | RangeClause ] Block .
Condition = Expression .
</pre>
@@ -6580,8 +6657,8 @@ an increment or decrement statement. The init statement may be a
<pre class="ebnf">
ForClause = [ InitStmt ] ";" [ Condition ] ";" [ PostStmt ] .
InitStmt = SimpleStmt .
PostStmt = SimpleStmt .
InitStmt = SimpleStmt .
PostStmt = SimpleStmt .
</pre>
<pre>
@@ -7909,7 +7986,7 @@ types, variables, and constants.
</p>
<pre class="ebnf">
SourceFile = PackageClause ";" { ImportDecl ";" } { TopLevelDecl ";" } .
SourceFile = PackageClause ";" { ImportDecl ";" } { TopLevelDecl ";" } .
</pre>
<h3 id="Package_clause">Package clause</h3>
@@ -7920,8 +7997,8 @@ to which the file belongs.
</p>
<pre class="ebnf">
PackageClause = "package" PackageName .
PackageName = identifier .
PackageClause = "package" PackageName .
PackageName = identifier .
</pre>
<p>
@@ -7950,9 +8027,9 @@ that specifies the package to be imported.
</p>
<pre class="ebnf">
ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
ImportSpec = [ "." | PackageName ] ImportPath .
ImportPath = string_lit .
ImportDecl = "import" ( ImportSpec | "(" { ImportSpec ";" } ")" ) .
ImportSpec = [ "." | PackageName ] ImportPath .
ImportPath = string_lit .
</pre>
<p>
@@ -8437,7 +8514,7 @@ var p ptr = nil
<p>
The functions <code>Alignof</code> and <code>Sizeof</code> take an expression <code>x</code>
of any type and return the alignment or size, respectively, of a hypothetical variable <code>v</code>
as if <code>v</code> was declared via <code>var v = x</code>.
as if <code>v</code> were declared via <code>var v = x</code>.
</p>
<p>
The function <code>Offsetof</code> takes a (possibly parenthesized) <a href="#Selectors">selector</a>

View File

@@ -1,9 +1,3 @@
<!--
NOTE: In this document and others in this directory, the convention is to
set fixed-width phrases with non-fixed-width spaces, as in
`hello` `world`.
-->
<style>
main ul li { margin: 0.5em 0; }
</style>

View File

@@ -27,7 +27,7 @@ default:
# copy and edit the 'go run' command by hand to use a different branch.
v%.zip:
git fetch origin master
go run ../../src/cmd/go/internal/fips140/mkzip.go -b master v$*
go run ../../src/cmd/go/internal/fips140/mkzip.go v$*
# normally mkzip refuses to overwrite an existing zip file.
# make v1.2.3.rm removes the zip file and and unpacked

View File

@@ -9,3 +9,4 @@
#
# go test cmd/go/internal/fips140 -update
#
v1.0.0.zip b50508feaeff05d22516b21e1fd210bbf5d6a1e422eaf2cfa23fe379342713b8

BIN
lib/fips140/v1.0.0.zip Normal file

Binary file not shown.

View File

@@ -24,8 +24,8 @@
# in the CL match the update.bash in the CL.
# Versions to use.
CODE=2024b
DATA=2024b
CODE=2025a
DATA=2025a
set -e

Binary file not shown.

View File

@@ -424,6 +424,9 @@ func (tw *Writer) AddFS(fsys fs.FS) error {
return err
}
h.Name = name
if d.IsDir() {
h.Name += "/"
}
if err := tw.WriteHeader(h); err != nil {
return err
}

View File

@@ -1382,7 +1382,11 @@ func TestWriterAddFS(t *testing.T) {
t.Fatal(err)
}
if hdr.Name != name {
tmpName := name
if entryInfo.IsDir() {
tmpName += "/"
}
if hdr.Name != tmpName {
t.Errorf("test fs has filename %v; archive header has %v",
name, hdr.Name)
}

View File

@@ -520,6 +520,9 @@ func (w *Writer) AddFS(fsys fs.FS) error {
return err
}
h.Name = name
if d.IsDir() {
h.Name += "/"
}
h.Method = Deflate
fw, err := w.CreateHeader(h)
if err != nil {

View File

@@ -633,7 +633,7 @@ func TestWriterAddFS(t *testing.T) {
t.Fatal(err)
}
// Add subfolder into fsys to match what we'll read from the tar.
// Add subfolder into fsys to match what we'll read from the zip.
tests = append(tests[:2:2], WriteTest{Name: "subfolder", Mode: 0o555 | os.ModeDir}, tests[2])
// read it back
@@ -642,6 +642,9 @@ func TestWriterAddFS(t *testing.T) {
t.Fatal(err)
}
for i, wt := range tests {
if wt.Mode.IsDir() {
wt.Name += "/"
}
testReadFile(t, r.File[i], &wt)
}
}

View File

@@ -162,12 +162,12 @@ func delete(m map[Type]Type1, key Type)
// The len built-in function returns the length of v, according to its type:
//
// Array: the number of elements in v.
// Pointer to array: the number of elements in *v (even if v is nil).
// Slice, or map: the number of elements in v; if v is nil, len(v) is zero.
// String: the number of bytes in v.
// Channel: the number of elements queued (unread) in the channel buffer;
// if v is nil, len(v) is zero.
// - Array: the number of elements in v.
// - Pointer to array: the number of elements in *v (even if v is nil).
// - Slice, or map: the number of elements in v; if v is nil, len(v) is zero.
// - String: the number of bytes in v.
// - Channel: the number of elements queued (unread) in the channel buffer;
// if v is nil, len(v) is zero.
//
// For some arguments, such as a string literal or a simple array expression, the
// result can be a constant. See the Go language specification's "Length and
@@ -176,12 +176,12 @@ func len(v Type) int
// The cap built-in function returns the capacity of v, according to its type:
//
// Array: the number of elements in v (same as len(v)).
// Pointer to array: the number of elements in *v (same as len(v)).
// Slice: the maximum length the slice can reach when resliced;
// if v is nil, cap(v) is zero.
// Channel: the channel buffer capacity, in units of elements;
// if v is nil, cap(v) is zero.
// - Array: the number of elements in v (same as len(v)).
// - Pointer to array: the number of elements in *v (same as len(v)).
// - Slice: the maximum length the slice can reach when resliced;
// if v is nil, cap(v) is zero.
// - Channel: the channel buffer capacity, in units of elements;
// if v is nil, cap(v) is zero.
//
// For some arguments, such as a simple array expression, the result can be a
// constant. See the Go language specification's "Length and capacity" section for
@@ -194,18 +194,18 @@ func cap(v Type) int
// argument, not a pointer to it. The specification of the result depends on
// the type:
//
// Slice: The size specifies the length. The capacity of the slice is
// equal to its length. A second integer argument may be provided to
// specify a different capacity; it must be no smaller than the
// length. For example, make([]int, 0, 10) allocates an underlying array
// of size 10 and returns a slice of length 0 and capacity 10 that is
// backed by this underlying array.
// Map: An empty map is allocated with enough space to hold the
// specified number of elements. The size may be omitted, in which case
// a small starting size is allocated.
// Channel: The channel's buffer is initialized with the specified
// buffer capacity. If zero, or the size is omitted, the channel is
// unbuffered.
// - Slice: The size specifies the length. The capacity of the slice is
// equal to its length. A second integer argument may be provided to
// specify a different capacity; it must be no smaller than the
// length. For example, make([]int, 0, 10) allocates an underlying array
// of size 10 and returns a slice of length 0 and capacity 10 that is
// backed by this underlying array.
// - Map: An empty map is allocated with enough space to hold the
// specified number of elements. The size may be omitted, in which case
// a small starting size is allocated.
// - Channel: The channel's buffer is initialized with the specified
// buffer capacity. If zero, or the size is omitted, the channel is
// unbuffered.
func make(t Type, size ...IntegerType) Type
// The max built-in function returns the largest value of a fixed number of
@@ -247,7 +247,7 @@ func imag(c ComplexType) FloatType
// to the zero value of the respective element type. If the argument
// type is a type parameter, the type parameter's type set must
// contain only map or slice types, and clear performs the operation
// implied by the type argument.
// implied by the type argument. If t is nil, clear is a no-op.
func clear[T ~[]Type | ~map[Type]Type1](t T)
// The close built-in function closes a channel, which must be either

View File

@@ -67,26 +67,26 @@ func splitSeq(s, sep []byte, sepSave int) iter.Seq[[]byte] {
}
}
// SplitSeq returns an iterator over all substrings of s separated by sep.
// The iterator yields the same strings that would be returned by Split(s, sep),
// but without constructing the slice.
// SplitSeq returns an iterator over all subslices of s separated by sep.
// The iterator yields the same subslices that would be returned by [Split](s, sep),
// but without constructing a new slice containing the subslices.
// It returns a single-use iterator.
func SplitSeq(s, sep []byte) iter.Seq[[]byte] {
return splitSeq(s, sep, 0)
}
// SplitAfterSeq returns an iterator over substrings of s split after each instance of sep.
// The iterator yields the same strings that would be returned by SplitAfter(s, sep),
// but without constructing the slice.
// SplitAfterSeq returns an iterator over subslices of s split after each instance of sep.
// The iterator yields the same subslices that would be returned by [SplitAfter](s, sep),
// but without constructing a new slice containing the subslices.
// It returns a single-use iterator.
func SplitAfterSeq(s, sep []byte) iter.Seq[[]byte] {
return splitSeq(s, sep, len(sep))
}
// FieldsSeq returns an iterator over substrings of s split around runs of
// whitespace characters, as defined by unicode.IsSpace.
// The iterator yields the same strings that would be returned by Fields(s),
// but without constructing the slice.
// FieldsSeq returns an iterator over subslices of s split around runs of
// whitespace characters, as defined by [unicode.IsSpace].
// The iterator yields the same subslices that would be returned by [Fields](s),
// but without constructing a new slice containing the subslices.
func FieldsSeq(s []byte) iter.Seq[[]byte] {
return func(yield func([]byte) bool) {
start := -1
@@ -116,10 +116,10 @@ func FieldsSeq(s []byte) iter.Seq[[]byte] {
}
}
// FieldsFuncSeq returns an iterator over substrings of s split around runs of
// FieldsFuncSeq returns an iterator over subslices of s split around runs of
// Unicode code points satisfying f(c).
// The iterator yields the same strings that would be returned by FieldsFunc(s),
// but without constructing the slice.
// The iterator yields the same subslices that would be returned by [FieldsFunc](s),
// but without constructing a new slice containing the subslices.
func FieldsFuncSeq(s []byte, f func(rune) bool) iter.Seq[[]byte] {
return func(yield func([]byte) bool) {
start := -1

View File

@@ -57,7 +57,10 @@ func TestGolden(t *testing.T) {
// TODO(gri) remove extra pkg directory eventually
goldenFile := filepath.Join("testdata", "src", "pkg", fi.Name(), "golden.txt")
w := NewWalker(nil, "testdata/src/pkg")
pkg, _ := w.import_(fi.Name())
pkg, err := w.import_(fi.Name())
if err != nil {
t.Fatalf("import %s: %v", fi.Name(), err)
}
w.export(pkg)
if *updateGolden {
@@ -201,7 +204,13 @@ func BenchmarkAll(b *testing.B) {
for _, context := range contexts {
w := NewWalker(context, filepath.Join(testenv.GOROOT(b), "src"))
for _, name := range w.stdPackages {
pkg, _ := w.import_(name)
pkg, err := w.import_(name)
if _, nogo := err.(*build.NoGoError); nogo {
continue
}
if err != nil {
b.Fatalf("import %s (%s-%s): %v", name, context.GOOS, context.GOARCH, err)
}
w.export(pkg)
}
w.Features()
@@ -239,8 +248,7 @@ func TestIssue21181(t *testing.T) {
w := NewWalker(context, "testdata/src/issue21181")
pkg, err := w.import_("p")
if err != nil {
t.Fatalf("%s: (%s-%s) %s %v", err, context.GOOS, context.GOARCH,
pkg.Name(), w.imported)
t.Fatalf("import %s (%s-%s): %v", "p", context.GOOS, context.GOARCH, err)
}
w.export(pkg)
}

View File

@@ -796,7 +796,7 @@ Instead, the build process generates an object file using dynamic
linkage to the desired libraries. The main function is provided by
_cgo_main.c:
int main() { return 0; }
int main(int argc, char **argv) { return 0; }
void crosscall2(void(*fn)(void*), void *a, int c, uintptr_t ctxt) { }
uintptr_t _cgo_wait_runtime_init_done(void) { return 0; }
void _cgo_release_context(uintptr_t ctxt) { }

View File

@@ -59,7 +59,7 @@ func (p *Package) writeDefs() {
// Write C main file for using gcc to resolve imports.
fmt.Fprintf(fm, "#include <stddef.h>\n") // For size_t below.
fmt.Fprintf(fm, "int main() { return 0; }\n")
fmt.Fprintf(fm, "int main(int argc __attribute__((unused)), char **argv __attribute__((unused))) { return 0; }\n")
if *importRuntimeCgo {
fmt.Fprintf(fm, "void crosscall2(void(*fn)(void*) __attribute__((unused)), void *a __attribute__((unused)), int c __attribute__((unused)), size_t ctxt __attribute__((unused))) { }\n")
fmt.Fprintf(fm, "size_t _cgo_wait_runtime_init_done(void) { return 0; }\n")

View File

@@ -15,7 +15,7 @@ the package and about types used by symbols imported by the package from
other packages. It is therefore not necessary when compiling client C of
package P to read the files of P's dependencies, only the compiled output of P.
Command Line
# Command Line
Usage:
@@ -150,14 +150,21 @@ Flags to debug the compiler itself:
-w
Debug type checking.
Compiler Directives
# Compiler Directives
The compiler accepts directives in the form of comments.
To distinguish them from non-directive comments, directives
require no space between the comment opening and the name of the directive. However, since
they are comments, tools unaware of the directive convention or of a particular
Each directive must be placed its own line, with only leading spaces and tabs
allowed before the comment, and there must be no space between the comment
opening and the name of the directive, to distinguish it from a regular comment.
Tools unaware of the directive convention or of a particular
directive can skip over a directive like any other comment.
Other than the line directive, which is a historical special case;
all other compiler directives are of the form
//go:name, indicating that they are defined by the Go toolchain.
*/
// # Line Directives
//
// Line directives come in several forms:
//
// //line :line
@@ -197,12 +204,9 @@ directive can skip over a directive like any other comment.
// Line directives typically appear in machine-generated code, so that compilers and debuggers
// will report positions in the original input to the generator.
/*
The line directive is a historical special case; all other directives are of the form
//go:name, indicating that they are defined by the Go toolchain.
Each directive must be placed its own line, with only leading spaces and tabs
allowed before the comment.
Each directive applies to the Go code that immediately follows it,
which typically must be a declaration.
# Function Directives
A function directive applies to the Go function that immediately follows it.
//go:noescape
@@ -245,6 +249,8 @@ It specifies that the function must omit its usual stack overflow check.
This is most commonly used by low-level runtime code invoked
at times when it is unsafe for the calling goroutine to be preempted.
# Linkname Directive
//go:linkname localname [importpath.name]
The //go:linkname directive conventionally precedes the var or func
@@ -295,17 +301,34 @@ The declaration of lower.f may also have a linkname directive with a
single argument, f. This is optional, but helps alert the reader that
the function is accessed from outside the package.
# WebAssembly Directives
//go:wasmimport importmodule importname
The //go:wasmimport directive is wasm-only and must be followed by a
function declaration.
function declaration with no body.
It specifies that the function is provided by a wasm module identified
by ``importmodule`` and ``importname``.
by ``importmodule'' and ``importname''. For example,
//go:wasmimport a_module f
func g()
The types of parameters and return values to the Go function are translated to
causes g to refer to the WebAssembly function f from module a_module.
//go:wasmexport exportname
The //go:wasmexport directive is wasm-only and must be followed by a
function definition.
It specifies that the function is exported to the wasm host as ``exportname''.
For example,
//go:wasmexport h
func hWasm() { ... }
make Go function hWasm available outside this WebAssembly module as h.
For both go:wasmimport and go:wasmexport,
the types of parameters and return values to the Go function are translated to
Wasm according to the following table:
Go types Wasm types
@@ -318,24 +341,12 @@ Wasm according to the following table:
pointer i32 (more restrictions below)
string (i32, i32) (only permitted as a parameters, not a result)
Any other parameter types are disallowed by the compiler.
For a pointer type, its element type must be a bool, int8, uint8, int16, uint16,
int32, uint32, int64, uint64, float32, float64, an array whose element type is
a permitted pointer element type, or a struct, which, if non-empty, embeds
structs.HostLayout, and contains only fields whose types are permitted pointer
[structs.HostLayout], and contains only fields whose types are permitted pointer
element types.
Any other parameter types are disallowed by the compiler.
//go:wasmexport exportname
The //go:wasmexport directive is wasm-only and must be followed by a
function definition.
It specifies that the function is exported to the wasm host as ``exportname``.
//go:wasmexport f
func g()
The types of parameters and return values to the Go function are permitted and
translated to Wasm in the same way as //go:wasmimport functions.
*/
package main

View File

@@ -5,7 +5,8 @@
// This program generates Go code that applies rewrite rules to a Value.
// The generated code implements a function of type func (v *Value) bool
// which reports whether if did something.
// Ideas stolen from Swift: http://www.hpl.hp.com/techreports/Compaq-DEC/WRL-2000-2.html
// Ideas stolen from the Swift Java compiler:
// https://bitsavers.org/pdf/dec/tech_reports/WRL-2000-2.pdf
package main

View File

@@ -252,6 +252,7 @@ func writebarrier(f *Func) {
var start, end int
var nonPtrStores int
values := b.Values
hasMove := false
FindSeq:
for i := len(values) - 1; i >= 0; i-- {
w := values[i]
@@ -263,6 +264,9 @@ func writebarrier(f *Func) {
end = i + 1
}
nonPtrStores = 0
if w.Op == OpMoveWB {
hasMove = true
}
case OpVarDef, OpVarLive:
continue
case OpStore:
@@ -273,6 +277,17 @@ func writebarrier(f *Func) {
if nonPtrStores > 2 {
break FindSeq
}
if hasMove {
// We need to ensure that this store happens
// before we issue a wbMove, as the wbMove might
// use the result of this store as its source.
// Even though this store is not write-barrier
// eligible, it might nevertheless be the store
// of a pointer to the stack, which is then the
// source of the move.
// See issue 71228.
break FindSeq
}
default:
if last == nil {
continue

View File

@@ -5452,12 +5452,15 @@ func (s *state) referenceTypeBuiltin(n *ir.UnaryExpr, x *ssa.Value) *ssa.Value {
if n.X.Type().IsChan() && n.Op() == ir.OCAP {
s.Fatalf("cannot inline cap(chan)") // must use runtime.chancap now
}
if n.X.Type().IsMap() && n.Op() == ir.OCAP {
s.Fatalf("cannot inline cap(map)") // cap(map) does not exist
}
// if n == nil {
// return 0
// } else {
// // len
// return *((*int)n)
// // cap
// // len, the actual loadType depends
// return int(*((*loadType)n))
// // cap (chan only, not used for now)
// return *(((*int)n)+1)
// }
lenType := n.Type()
@@ -5485,7 +5488,9 @@ func (s *state) referenceTypeBuiltin(n *ir.UnaryExpr, x *ssa.Value) *ssa.Value {
case ir.OLEN:
if buildcfg.Experiment.SwissMap && n.X.Type().IsMap() {
// length is stored in the first word.
s.vars[n] = s.load(lenType, x)
loadType := reflectdata.SwissMapType().Field(0).Type // uint64
load := s.load(loadType, x)
s.vars[n] = s.conv(nil, load, loadType, lenType) // integer conversion doesn't need Node
} else {
// length is stored in the first word for map/chan
s.vars[n] = s.load(lenType, x)

View File

@@ -0,0 +1,17 @@
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package p
func _() {
M:
L:
for range 0 {
break L
break /* ERROR invalid break label M */ M
}
for range 0 {
break /* ERROR invalid break label L */ L
}
}

View File

@@ -152,12 +152,14 @@ func mapassign_fast32ptr(mapType *byte, hmap map[any]any, key unsafe.Pointer) (v
func mapassign_fast64(mapType *byte, hmap map[any]any, key uint64) (val *any)
func mapassign_fast64ptr(mapType *byte, hmap map[any]any, key unsafe.Pointer) (val *any)
func mapassign_faststr(mapType *byte, hmap map[any]any, key string) (val *any)
func mapiterinit(mapType *byte, hmap map[any]any, hiter *any)
func mapiterinit(mapType *byte, hmap map[any]any, hiter *any) // old maps
func mapIterStart(mapType *byte, hmap map[any]any, hiter *any) // swiss maps
func mapdelete(mapType *byte, hmap map[any]any, key *any)
func mapdelete_fast32(mapType *byte, hmap map[any]any, key uint32)
func mapdelete_fast64(mapType *byte, hmap map[any]any, key uint64)
func mapdelete_faststr(mapType *byte, hmap map[any]any, key string)
func mapiternext(hiter *any)
func mapiternext(hiter *any) // old maps
func mapIterNext(hiter *any) // swiss maps
func mapclear(mapType *byte, hmap map[any]any)
// *byte is really *runtime.Type

View File

@@ -131,11 +131,13 @@ var runtimeDecls = [...]struct {
{"mapassign_fast64ptr", funcTag, 96},
{"mapassign_faststr", funcTag, 89},
{"mapiterinit", funcTag, 97},
{"mapIterStart", funcTag, 97},
{"mapdelete", funcTag, 97},
{"mapdelete_fast32", funcTag, 98},
{"mapdelete_fast64", funcTag, 99},
{"mapdelete_faststr", funcTag, 100},
{"mapiternext", funcTag, 101},
{"mapIterNext", funcTag, 101},
{"mapclear", funcTag, 102},
{"makechan64", funcTag, 104},
{"makechan", funcTag, 105},

View File

@@ -56,7 +56,7 @@ The tests are in:
Tests are .go files annotated with `/* ERROR "msg" */` or `/* ERRORx "msg" */`
comments (or the respective line comment form).
For each such error comment, typechecking the respective file is expected to
report an error at the position of the syntactic token _immediately preceeding_
report an error at the position of the syntactic token _immediately preceding_
the comment.
For `ERROR`, the `"msg"` string must be a substring of the error message
reported by the typechecker;

View File

@@ -208,11 +208,19 @@ type Info struct {
//
// The Types map does not record the type of every identifier,
// only those that appear where an arbitrary expression is
// permitted. For instance, the identifier f in a selector
// expression x.f is found only in the Selections map, the
// identifier z in a variable declaration 'var z int' is found
// only in the Defs map, and identifiers denoting packages in
// qualified identifiers are collected in the Uses map.
// permitted. For instance:
// - an identifier f in a selector expression x.f is found
// only in the Selections map;
// - an identifier z in a variable declaration 'var z int'
// is found only in the Defs map;
// - an identifier p denoting a package in a qualified
// identifier p.X is found only in the Uses map.
//
// Similarly, no type is recorded for the (synthetic) FuncType
// node in a FuncDecl.Type field, since there is no corresponding
// syntactic function type expression in the source in this case
// Instead, the function type is found in the Defs.map entry for
// the corresponding function declaration.
Types map[syntax.Expr]TypeAndValue
// If StoreTypesInSyntax is set, type information identical to

View File

@@ -142,6 +142,9 @@ func (check *Checker) instantiateSignature(pos syntax.Pos, expr syntax.Expr, typ
}()
}
// For signatures, Checker.instance will always succeed because the type argument
// count is correct at this point (see assertion above); hence the type assertion
// to *Signature will always succeed.
inst := check.instance(pos, typ, targs, nil, check.context()).(*Signature)
assert(inst.TypeParams().Len() == 0) // signature is not generic anymore
check.recordInstance(expr, targs, inst)

View File

@@ -10,6 +10,7 @@ import (
"fmt"
. "internal/types/errors"
"slices"
"sort"
)
// initOrder computes the Info.InitOrder for package variables.
@@ -139,7 +140,16 @@ func findPath(objMap map[Object]*declInfo, from, to Object, seen map[Object]bool
}
seen[from] = true
// sort deps for deterministic result
var deps []Object
for d := range objMap[from].deps {
deps = append(deps, d)
}
sort.Slice(deps, func(i, j int) bool {
return deps[i].order() < deps[j].order()
})
for _, d := range deps {
if d == to {
return []Object{d}
}

View File

@@ -74,7 +74,8 @@ func Instantiate(ctxt *Context, orig Type, targs []Type, validate bool) (Type, e
// instance instantiates the given original (generic) function or type with the
// provided type arguments and returns the resulting instance. If an identical
// instance exists already in the given contexts, it returns that instance,
// otherwise it creates a new one.
// otherwise it creates a new one. If there is an error (such as wrong number
// of type arguments), the result is Typ[Invalid].
//
// If expanding is non-nil, it is the Named instance type currently being
// expanded. If ctxt is non-nil, it is the context associated with the current
@@ -133,9 +134,13 @@ func (check *Checker) instance(pos syntax.Pos, orig genericType, targs []Type, e
assert(expanding == nil) // Alias instances cannot be reached from Named types
}
// verify type parameter count (see go.dev/issue/71198 for a test case)
tparams := orig.TypeParams()
// TODO(gri) investigate if this is needed (type argument and parameter count seem to be correct here)
if !check.validateTArgLen(pos, orig.String(), tparams.Len(), len(targs)) {
if !check.validateTArgLen(pos, orig.obj.Name(), tparams.Len(), len(targs)) {
// TODO(gri) Consider returning a valid alias instance with invalid
// underlying (aliased) type to match behavior of *Named
// types. Then this function will never return an invalid
// result.
return Typ[Invalid]
}
if tparams.Len() == 0 {

View File

@@ -174,7 +174,7 @@ func (check *Checker) collectRecv(rparam *syntax.Field, scopePos syntax.Pos) (*V
} else {
// If there are type parameters, rbase must denote a generic base type.
// Important: rbase must be resolved before declaring any receiver type
// parameters (wich may have the same name, see below).
// parameters (which may have the same name, see below).
var baseType *Named // nil if not valid
var cause string
if t := check.genericType(rbase, &cause); isValid(t) {

View File

@@ -1057,8 +1057,13 @@ func rangeKeyVal(typ Type, allowVersion func(goVersion) bool) (key, val Type, ca
return bad("func must be func(yield func(...) bool): argument is not func")
case cb.Params().Len() > 2:
return bad("func must be func(yield func(...) bool): yield func has too many parameters")
case cb.Results().Len() != 1 || !isBoolean(cb.Results().At(0).Type()):
return bad("func must be func(yield func(...) bool): yield func does not return bool")
case cb.Results().Len() != 1 || !Identical(cb.Results().At(0).Type(), universeBool):
// see go.dev/issues/71131, go.dev/issues/71164
if cb.Results().Len() == 1 && isBoolean(cb.Results().At(0).Type()) {
return bad("func must be func(yield func(...) bool): yield func returns user-defined boolean, not bool")
} else {
return bad("func must be func(yield func(...) bool): yield func does not return bool")
}
}
assert(cb.Recv() == nil)
// determine key and value types, if any

View File

@@ -0,0 +1,14 @@
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package p
const (
B /* ERROR "initialization cycle: B refers to itself" */ = A + B
A /* ERRORx "initialization cycle for A\\s+.*A refers to B\\s+.*B refers to A" */ = A + B
C /* ERRORx "initialization cycle for C\\s+.*C refers to D\\s+.*D refers to C" */ = E + D
D /* ERRORx "initialization cycle for D\\s+.*D refers to C\\s+.*C refers to D" */ = E + C
E = D + C
)

View File

@@ -1,4 +1,4 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

View File

@@ -423,11 +423,6 @@ func setDefType(def *TypeName, typ Type) {
if def != nil {
switch t := def.typ.(type) {
case *Alias:
// t.fromRHS should always be set, either to an invalid type
// in the beginning, or to typ in certain cyclic declarations.
if t.fromRHS != Typ[Invalid] && t.fromRHS != typ {
panic(sprintf(nil, true, "t.fromRHS = %s, typ = %s\n", t.fromRHS, typ))
}
t.fromRHS = typ
case *Basic:
assert(t == Typ[Invalid])
@@ -475,9 +470,14 @@ func (check *Checker) instantiatedType(x syntax.Expr, xlist []syntax.Expr, def *
}
// create instance
// The instance is not generic anymore as it has type arguments, but it still
// satisfies the genericType interface because it has type parameters, too.
inst := check.instance(x.Pos(), gtyp, targs, nil, check.context()).(genericType)
// The instance is not generic anymore as it has type arguments, but unless
// instantiation failed, it still satisfies the genericType interface because
// it has type parameters, too.
ityp := check.instance(x.Pos(), gtyp, targs, nil, check.context())
inst, _ := ityp.(genericType)
if inst == nil {
return Typ[Invalid]
}
// For Named types, orig.tparams may not be set up, so we need to do expansion later.
check.later(func() {

View File

@@ -21,6 +21,7 @@ var Unsafe *Package
var (
universeIota Object
universeBool Type
universeByte Type // uint8 alias, but has name "byte"
universeRune Type // int32 alias, but has name "rune"
universeAnyNoAlias *TypeName
@@ -275,6 +276,7 @@ func init() {
defPredeclaredFuncs()
universeIota = Universe.Lookup("iota")
universeBool = Universe.Lookup("bool").Type()
universeByte = Universe.Lookup("byte").Type()
universeRune = Universe.Lookup("rune").Type()
universeError = Universe.Lookup("error").Type()

View File

@@ -244,19 +244,24 @@ func walkRange(nrange *ir.RangeStmt) ir.Node {
// depends on layout of iterator struct.
// See cmd/compile/internal/reflectdata/reflect.go:MapIterType
var keysym, elemsym *types.Sym
var iterInit, iterNext string
if buildcfg.Experiment.SwissMap {
keysym = th.Field(0).Sym
elemsym = th.Field(1).Sym // ditto
iterInit = "mapIterStart"
iterNext = "mapIterNext"
} else {
keysym = th.Field(0).Sym
elemsym = th.Field(1).Sym // ditto
iterInit = "mapiterinit"
iterNext = "mapiternext"
}
fn := typecheck.LookupRuntime("mapiterinit", t.Key(), t.Elem(), th)
fn := typecheck.LookupRuntime(iterInit, t.Key(), t.Elem(), th)
init = append(init, mkcallstmt1(fn, reflectdata.RangeMapRType(base.Pos, nrange), ha, typecheck.NodAddr(hit)))
nfor.Cond = ir.NewBinaryExpr(base.Pos, ir.ONE, ir.NewSelectorExpr(base.Pos, ir.ODOT, hit, keysym), typecheck.NodNil())
fn = typecheck.LookupRuntime("mapiternext", th)
fn = typecheck.LookupRuntime(iterNext, th)
nfor.Post = mkcallstmt1(fn, typecheck.NodAddr(hit))
key := ir.NewStarExpr(base.Pos, typecheck.ConvNop(ir.NewSelectorExpr(base.Pos, ir.ODOT, hit, keysym), types.NewPtr(t.Key())))

View File

@@ -331,7 +331,7 @@ func (d *dstate) Finish() {
d.format.EmitFuncs(os.Stdout)
}
if d.textfmtoutf != nil {
if err := d.format.EmitTextual(d.textfmtoutf); err != nil {
if err := d.format.EmitTextual(nil, d.textfmtoutf); err != nil {
fatal("writing to %s: %v", *textfmtoutflag, err)
}
}

25
src/cmd/dist/test.go vendored
View File

@@ -876,16 +876,18 @@ func (t *tester) registerTests() {
}
if t.extLink() && !t.compileOnly {
t.registerTest("external linking, -buildmode=exe",
&goTest{
variant: "exe_external",
timeout: 60 * time.Second,
buildmode: "exe",
ldflags: "-linkmode=external",
env: []string{"CGO_ENABLED=1"},
pkg: "crypto/internal/fips140test",
runTests: "TestFIPSCheck",
})
if goos != "android" { // Android does not support non-PIE linking
t.registerTest("external linking, -buildmode=exe",
&goTest{
variant: "exe_external",
timeout: 60 * time.Second,
buildmode: "exe",
ldflags: "-linkmode=external",
env: []string{"CGO_ENABLED=1"},
pkg: "crypto/internal/fips140test",
runTests: "TestFIPSCheck",
})
}
if t.externalLinkPIE() && !disablePIE {
t.registerTest("external linking, -buildmode=pie",
&goTest{
@@ -1795,6 +1797,8 @@ func isEnvSet(evar string) bool {
}
func (t *tester) fipsSupported() bool {
// Keep this in sync with [crypto/internal/fips140.Supported].
// Use GOFIPS140 or GOEXPERIMENT=boringcrypto, but not both.
if strings.Contains(goexperiment, "boringcrypto") {
return false
@@ -1808,6 +1812,7 @@ func (t *tester) fipsSupported() bool {
case goarch == "wasm",
goos == "windows" && goarch == "386",
goos == "windows" && goarch == "arm",
goos == "openbsd",
goos == "aix":
return false
}

View File

@@ -11,7 +11,7 @@ require (
golang.org/x/sys v0.28.0
golang.org/x/telemetry v0.0.0-20241204182053-c0ac0e154df3
golang.org/x/term v0.27.0
golang.org/x/tools v0.28.0
golang.org/x/tools v0.28.1-0.20250131145412-98746475647e
)
require (

View File

@@ -22,7 +22,7 @@ golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q=
golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM=
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
golang.org/x/tools v0.28.1-0.20250131145412-98746475647e h1:6Kzwg7JxW2HRWToKpIKqlpF8l8XMasoALX3OcAMdgL8=
golang.org/x/tools v0.28.1-0.20250131145412-98746475647e/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef h1:mqLYrXCXYEZOop9/Dbo6RPX11539nwiCNBb1icVPmw8=
rsc.io/markdown v0.0.0-20240306144322-0bf8f97ee8ef/go.mod h1:8xcPgWmwlZONN1D9bjxtHEjrUtSEa3fakVF8iaewYKQ=

View File

@@ -739,11 +739,6 @@
//
// For more about specifying packages, see 'go help packages'.
//
// This text describes the behavior of get using modules to manage source
// code and dependencies. If instead the go command is running in GOPATH
// mode, the details of get's flags and effects change, as does 'go help get'.
// See 'go help gopath-get'.
//
// See also: go build, go install, go clean, go mod.
//
// # Compile and install packages and dependencies
@@ -2186,7 +2181,7 @@
// fields of all events to reconstruct the text format output, as it would
// have appeared from go build without the -json flag.
//
// Note that there may also be non-JSON error text on stdnard error, even
// Note that there may also be non-JSON error text on standard error, even
// with the -json flag. Typically, this indicates an early, serious error.
// Consumers should be robust to this.
//
@@ -2250,7 +2245,7 @@
//
// The second is the SWIG program, which is a general tool for
// interfacing between languages. For information on SWIG see
// http://swig.org/. When running go build, any file with a .swig
// https://swig.org/. When running go build, any file with a .swig
// extension will be passed to SWIG. Any file with a .swigcxx extension
// will be passed to SWIG with the -c++ option.
//
@@ -2338,9 +2333,14 @@
// GOCACHE
// The directory where the go command will store cached
// information for reuse in future builds.
// GOCACHEPROG
// A command (with optional space-separated flags) that implements an
// external go command build cache.
// See 'go doc cmd/go/internal/cacheprog'.
// GODEBUG
// Enable various debugging facilities. See https://go.dev/doc/godebug
// for details.
// Enable various debugging facilities for programs built with Go,
// including the go command. Cannot be set using 'go env -w'.
// See https://go.dev/doc/godebug for details.
// GOENV
// The location of the Go environment configuration file.
// Cannot be set using 'go env -w'.
@@ -2448,6 +2448,11 @@
// GOARM
// For GOARCH=arm, the ARM architecture for which to compile.
// Valid values are 5, 6, 7.
// When the Go tools are built on an arm system,
// the default value is set based on what the build system supports.
// When the Go tools are not built on an arm system
// (that is, when building a cross-compiler),
// the default value is 7.
// The value can be followed by an option specifying how to implement floating point instructions.
// Valid options are ,softfloat (default for 5) and ,hardfloat (default for 6 and 7).
// GOARM64
@@ -2612,7 +2617,7 @@
// Example: Data
//
// If the server responds with any 4xx code, the go command will write the
// following to the programs' stdin:
// following to the program's stdin:
// Response = StatusLine { HeaderLine } BlankLine .
// StatusLine = Protocol Space Status '\n' .
// Protocol = /* HTTP protocol */ .
@@ -2627,8 +2632,7 @@
// Content-Type: text/plain; charset=utf-8
// Date: Thu, 07 Nov 2024 18:43:09 GMT
//
// Note: at least for HTTP 1.1, the contents written to stdin can be parsed
// as an HTTP response.
// Note: it is safe to use net/http.ReadResponse to parse this input.
//
// Before the first HTTPS fetch, the go command will invoke each GOAUTH
// command in the list with no additional arguments and no input.
@@ -2969,11 +2973,7 @@
// same meta tag and then git clone https://code.org/r/p/exproj into
// GOPATH/src/example.org.
//
// When using GOPATH, downloaded packages are written to the first directory
// listed in the GOPATH environment variable.
// (See 'go help gopath-get' and 'go help gopath'.)
//
// When using modules, downloaded packages are stored in the module cache.
// Downloaded packages are stored in the module cache.
// See https://golang.org/ref/mod#module-cache.
//
// When using modules, an additional variant of the go-import meta tag is

View File

@@ -12,7 +12,6 @@ import (
"log"
"net/http"
"os"
"path"
"path/filepath"
"slices"
"strings"
@@ -71,9 +70,15 @@ func runGoAuth(client *http.Client, res *http.Response, url string) {
case "netrc":
lines, err := readNetrc()
if err != nil {
base.Fatalf("go: could not parse netrc (GOAUTH=%s): %v", cfg.GOAUTH, err)
cmdErrs = append(cmdErrs, fmt.Errorf("GOAUTH=%s: %v", command, err))
continue
}
for _, l := range lines {
// Process lines in reverse so that if the same machine is listed
// multiple times, we end up saving the earlier one
// (overwriting later ones). This matches the way the go command
// worked before GOAUTH.
for i := len(lines) - 1; i >= 0; i-- {
l := lines[i]
r := http.Request{Header: make(http.Header)}
r.SetBasicAuth(l.login, l.password)
storeCredential(l.machine, r.Header)
@@ -137,11 +142,13 @@ func runGoAuth(client *http.Client, res *http.Response, url string) {
func loadCredential(req *http.Request, url string) bool {
currentPrefix := strings.TrimPrefix(url, "https://")
// Iteratively try prefixes, moving up the path hierarchy.
for currentPrefix != "/" && currentPrefix != "." && currentPrefix != "" {
for {
headers, ok := credentialCache.Load(currentPrefix)
if !ok {
// Move to the parent directory.
currentPrefix = path.Dir(currentPrefix)
currentPrefix, _, ok = strings.Cut(currentPrefix, "/")
if !ok {
return false
}
continue
}
for key, values := range headers.(http.Header) {
@@ -151,7 +158,6 @@ func loadCredential(req *http.Request, url string) bool {
}
return true
}
return false
}
// storeCredential caches or removes credentials (represented by HTTP headers)

View File

@@ -25,7 +25,29 @@ func TestCredentialCache(t *testing.T) {
got := &http.Request{Header: make(http.Header)}
ok := loadCredential(got, tc.machine)
if !ok || !reflect.DeepEqual(got.Header, want.Header) {
t.Errorf("loadCredential:\nhave %q\nwant %q", got.Header, want.Header)
t.Errorf("loadCredential(%q):\nhave %q\nwant %q", tc.machine, got.Header, want.Header)
}
}
// Having stored those credentials, we should be able to look up longer URLs too.
extraCases := []netrcLine{
{"https://api.github.com/foo", "user", "pwd"},
{"https://api.github.com/foo/bar/baz", "user", "pwd"},
{"https://example.com/abc", "", ""},
{"https://example.com/?/../api.github.com/", "", ""},
{"https://example.com/?/../api.github.com", "", ""},
{"https://example.com/../api.github.com/", "", ""},
{"https://example.com/../api.github.com", "", ""},
}
for _, tc := range extraCases {
want := http.Request{Header: make(http.Header)}
if tc.login != "" {
want.SetBasicAuth(tc.login, tc.password)
}
got := &http.Request{Header: make(http.Header)}
loadCredential(got, tc.machine)
if !reflect.DeepEqual(got.Header, want.Header) {
t.Errorf("loadCredential(%q):\nhave %q\nwant %q", tc.machine, got.Header, want.Header)
}
}
}

View File

@@ -0,0 +1,173 @@
// Copyright 2019 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Code copied from x/net/http/httpguts/httplex.go
package auth
var isTokenTable = [256]bool{
'!': true,
'#': true,
'$': true,
'%': true,
'&': true,
'\'': true,
'*': true,
'+': true,
'-': true,
'.': true,
'0': true,
'1': true,
'2': true,
'3': true,
'4': true,
'5': true,
'6': true,
'7': true,
'8': true,
'9': true,
'A': true,
'B': true,
'C': true,
'D': true,
'E': true,
'F': true,
'G': true,
'H': true,
'I': true,
'J': true,
'K': true,
'L': true,
'M': true,
'N': true,
'O': true,
'P': true,
'Q': true,
'R': true,
'S': true,
'T': true,
'U': true,
'W': true,
'V': true,
'X': true,
'Y': true,
'Z': true,
'^': true,
'_': true,
'`': true,
'a': true,
'b': true,
'c': true,
'd': true,
'e': true,
'f': true,
'g': true,
'h': true,
'i': true,
'j': true,
'k': true,
'l': true,
'm': true,
'n': true,
'o': true,
'p': true,
'q': true,
'r': true,
's': true,
't': true,
'u': true,
'v': true,
'w': true,
'x': true,
'y': true,
'z': true,
'|': true,
'~': true,
}
// isLWS reports whether b is linear white space, according
// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
//
// LWS = [CRLF] 1*( SP | HT )
func isLWS(b byte) bool { return b == ' ' || b == '\t' }
// isCTL reports whether b is a control byte, according
// to http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2
//
// CTL = <any US-ASCII control character
// (octets 0 - 31) and DEL (127)>
func isCTL(b byte) bool {
const del = 0x7f // a CTL
return b < ' ' || b == del
}
// validHeaderFieldName reports whether v is a valid HTTP/1.x header name.
// HTTP/2 imposes the additional restriction that uppercase ASCII
// letters are not allowed.
//
// RFC 7230 says:
//
// header-field = field-name ":" OWS field-value OWS
// field-name = token
// token = 1*tchar
// tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /
// "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA
func validHeaderFieldName(v string) bool {
if len(v) == 0 {
return false
}
for i := 0; i < len(v); i++ {
if !isTokenTable[v[i]] {
return false
}
}
return true
}
// validHeaderFieldValue reports whether v is a valid "field-value" according to
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2 :
//
// message-header = field-name ":" [ field-value ]
// field-value = *( field-content | LWS )
// field-content = <the OCTETs making up the field-value
// and consisting of either *TEXT or combinations
// of token, separators, and quoted-string>
//
// http://www.w3.org/Protocols/rfc2616/rfc2616-sec2.html#sec2.2 :
//
// TEXT = <any OCTET except CTLs,
// but including LWS>
// LWS = [CRLF] 1*( SP | HT )
// CTL = <any US-ASCII control character
// (octets 0 - 31) and DEL (127)>
//
// RFC 7230 says:
//
// field-value = *( field-content / obs-fold )
// obj-fold = N/A to http2, and deprecated
// field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
// field-vchar = VCHAR / obs-text
// obs-text = %x80-FF
// VCHAR = "any visible [USASCII] character"
//
// http2 further says: "Similarly, HTTP/2 allows header field values
// that are not valid. While most of the values that can be encoded
// will not alter header field parsing, carriage return (CR, ASCII
// 0xd), line feed (LF, ASCII 0xa), and the zero character (NUL, ASCII
// 0x0) might be exploited by an attacker if they are translated
// verbatim. Any request or response that contains a character not
// permitted in a header field value MUST be treated as malformed
// (Section 8.1.2.6). Valid characters are defined by the
// field-content ABNF rule in Section 3.2 of [RFC7230]."
//
// This function does not (yet?) properly handle the rejection of
// strings that begin or end with SP or HTAB.
func validHeaderFieldValue(v string) bool {
for i := 0; i < len(v); i++ {
b := v[i]
if isCTL(b) && !isLWS(b) {
return false
}
}
return true
}

View File

@@ -6,14 +6,11 @@
package auth
import (
"bufio"
"bytes"
"cmd/internal/quoted"
"fmt"
"io"
"maps"
"net/http"
"net/textproto"
"net/url"
"os/exec"
"strings"
)
@@ -42,7 +39,7 @@ func runAuthCommand(command string, url string, res *http.Response) (map[string]
if err != nil {
return nil, fmt.Errorf("could not run command %s: %v\n%s", command, err, cmd.Stderr)
}
credentials, err := parseUserAuth(bytes.NewReader(out))
credentials, err := parseUserAuth(string(out))
if err != nil {
return nil, fmt.Errorf("cannot parse output of GOAUTH command %s: %v", command, err)
}
@@ -54,53 +51,47 @@ func runAuthCommand(command string, url string, res *http.Response) (map[string]
// or an error if the data does not follow the expected format.
// Returns an nil error and an empty map if the data is empty.
// See the expected format in 'go help goauth'.
func parseUserAuth(data io.Reader) (map[string]http.Header, error) {
func parseUserAuth(data string) (map[string]http.Header, error) {
credentials := make(map[string]http.Header)
reader := textproto.NewReader(bufio.NewReader(data))
for {
// Return the processed credentials if the reader is at EOF.
if _, err := reader.R.Peek(1); err == io.EOF {
return credentials, nil
for data != "" {
var line string
var ok bool
var urls []string
// Parse URLS first.
for {
line, data, ok = strings.Cut(data, "\n")
if !ok {
return nil, fmt.Errorf("invalid format: missing empty line after URLs")
}
if line == "" {
break
}
u, err := url.ParseRequestURI(line)
if err != nil {
return nil, fmt.Errorf("could not parse URL %s: %v", line, err)
}
urls = append(urls, u.String())
}
urls, err := readURLs(reader)
if err != nil {
return nil, err
}
if len(urls) == 0 {
return nil, fmt.Errorf("invalid format: expected url prefix")
}
mimeHeader, err := reader.ReadMIMEHeader()
if err != nil {
return nil, err
}
header := http.Header(mimeHeader)
// Process the block (urls and headers).
credentialMap := mapHeadersToPrefixes(urls, header)
maps.Copy(credentials, credentialMap)
}
}
// readURLs reads URL prefixes from the given reader until an empty line
// is encountered or an error occurs. It returns the list of URLs or an error
// if the format is invalid.
func readURLs(reader *textproto.Reader) (urls []string, err error) {
for {
line, err := reader.ReadLine()
if err != nil {
return nil, err
}
trimmedLine := strings.TrimSpace(line)
if trimmedLine != line {
return nil, fmt.Errorf("invalid format: leading or trailing white space")
}
if strings.HasPrefix(line, "https://") {
urls = append(urls, line)
} else if line == "" {
return urls, nil
} else {
return nil, fmt.Errorf("invalid format: expected url prefix or empty line")
// Parse Headers second.
header := make(http.Header)
for {
line, data, ok = strings.Cut(data, "\n")
if !ok {
return nil, fmt.Errorf("invalid format: missing empty line after headers")
}
if line == "" {
break
}
name, value, ok := strings.Cut(line, ": ")
value = strings.TrimSpace(value)
if !ok || !validHeaderFieldName(name) || !validHeaderFieldValue(value) {
return nil, fmt.Errorf("invalid format: invalid header line")
}
header.Add(name, value)
}
maps.Copy(credentials, mapHeadersToPrefixes(urls, header))
}
return credentials, nil
}
// mapHeadersToPrefixes returns a mapping of prefix → http.Header without
@@ -127,8 +118,8 @@ func buildCommand(command string) (*exec.Cmd, error) {
func writeResponseToStdin(cmd *exec.Cmd, res *http.Response) error {
var output strings.Builder
output.WriteString(res.Proto + " " + res.Status + "\n")
if err := res.Header.Write(&output); err != nil {
return err
for k, v := range res.Header {
output.WriteString(k + ": " + strings.Join(v, ", ") + "\n")
}
output.WriteString("\n")
cmd.Stdin = strings.NewReader(output.String())

View File

@@ -7,7 +7,6 @@ package auth
import (
"net/http"
"reflect"
"strings"
"testing"
)
@@ -40,7 +39,7 @@ Data: Test567
"Test567",
},
}
credentials, err := parseUserAuth(strings.NewReader(data))
credentials, err := parseUserAuth(data)
if err != nil {
t.Errorf("parseUserAuth(%s): %v", data, err)
}
@@ -100,10 +99,55 @@ Authorization: Basic GVuc2VzYW1lYWxhZGRpbjpvc
Authorization: Basic 1lYWxhZGRplW1lYWxhZGRpbs
Data: Test567
`,
// Continuation in URL line
`https://example.com/
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
`,
// Continuation in header line
`https://example.com
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb
`,
// Continuation in multiple header lines
`https://example.com
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb
Authorization: Basic dGhpc2lzYWxvbmdzdHJpbmc=
`,
// Continuation with mixed spacing
`https://example.com
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb
`,
// Continuation with tab character
`https://example.com
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
Authorization: Basic jpvcGVuc2VzYW1lYWxhZGRpb
`,
// Continuation at the start of a block
` https://example.com
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
`,
// Continuation after a blank line
`https://example.com
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
`,
}
for _, tc := range testCases {
if credentials, err := parseUserAuth(strings.NewReader(tc)); err == nil {
if credentials, err := parseUserAuth(tc); err == nil {
t.Errorf("parseUserAuth(%s) should have failed, but got: %v", tc, credentials)
}
}
@@ -132,7 +176,7 @@ Data: Test567
"Test567",
},
}
credentials, err := parseUserAuth(strings.NewReader(data))
credentials, err := parseUserAuth(data)
if err != nil {
t.Errorf("parseUserAuth(%s): %v", data, err)
}
@@ -146,7 +190,7 @@ func TestParseUserAuthEmptyHeader(t *testing.T) {
data := "https://example.com\n\n\n"
// Build the expected header
header := http.Header{}
credentials, err := parseUserAuth(strings.NewReader(data))
credentials, err := parseUserAuth(data)
if err != nil {
t.Errorf("parseUserAuth(%s): %v", data, err)
}
@@ -159,7 +203,7 @@ func TestParseUserAuthEmptyHeader(t *testing.T) {
func TestParseUserAuthEmpty(t *testing.T) {
data := ``
// Build the expected header
credentials, err := parseUserAuth(strings.NewReader(data))
credentials, err := parseUserAuth(data)
if err != nil {
t.Errorf("parseUserAuth(%s) should have succeeded", data)
}

View File

@@ -38,8 +38,8 @@ type Cache interface {
// Get returns the cache entry for the provided ActionID.
// On miss, the error type should be of type *entryNotFoundError.
//
// After a success call to Get, OutputFile(Entry.OutputID) must
// exist on disk for until Close is called (at the end of the process).
// After a successful call to Get, OutputFile(Entry.OutputID) must
// exist on disk until Close is called (at the end of the process).
Get(ActionID) (Entry, error)
// Put adds an item to the cache.
@@ -50,14 +50,14 @@ type Cache interface {
// As a special case, if the ReadSeeker is of type noVerifyReadSeeker,
// the verification from GODEBUG=goverifycache=1 is skipped.
//
// After a success call to Get, OutputFile(Entry.OutputID) must
// exist on disk for until Close is called (at the end of the process).
// After a successful call to Put, OutputFile(OutputID) must
// exist on disk until Close is called (at the end of the process).
Put(ActionID, io.ReadSeeker) (_ OutputID, size int64, _ error)
// Close is called at the end of the go process. Implementations can do
// cache cleanup work at this phase, or wait for and report any errors from
// background cleanup work started earlier. Any cache trimming should in one
// process should not violate cause the invariants of this interface to be
// background cleanup work started earlier. Any cache trimming in one
// process should not cause the invariants of this interface to be
// violated in another process. Namely, a cache trim from one process should
// not delete an ObjectID from disk that was recently Get or Put from
// another process. As a rule of thumb, don't trim things used in the last
@@ -296,19 +296,19 @@ func GetBytes(c Cache, id ActionID) ([]byte, Entry, error) {
// GetMmap looks up the action ID in the cache and returns
// the corresponding output bytes.
// GetMmap should only be used for data that can be expected to fit in memory.
func GetMmap(c Cache, id ActionID) ([]byte, Entry, error) {
func GetMmap(c Cache, id ActionID) ([]byte, Entry, bool, error) {
entry, err := c.Get(id)
if err != nil {
return nil, entry, err
return nil, entry, false, err
}
md, err := mmap.Mmap(c.OutputFile(entry.OutputID))
md, opened, err := mmap.Mmap(c.OutputFile(entry.OutputID))
if err != nil {
return nil, Entry{}, err
return nil, Entry{}, opened, err
}
if int64(len(md.Data)) != entry.Size {
return nil, Entry{}, &entryNotFoundError{Err: errors.New("file incomplete")}
return nil, Entry{}, true, &entryNotFoundError{Err: errors.New("file incomplete")}
}
return md.Data, entry, nil
return md.Data, entry, true, nil
}
// OutputFile returns the name of the cache file storing output with the given OutputID.

View File

@@ -54,8 +54,8 @@ func initDefaultCache() Cache {
base.Fatalf("failed to initialize build cache at %s: %s\n", dir, err)
}
if v := cfg.Getenv("GOCACHEPROG"); v != "" {
return startCacheProg(v, diskCache)
if cfg.GOCACHEPROG != "" {
return startCacheProg(cfg.GOCACHEPROG, diskCache)
}
return diskCache

View File

@@ -7,6 +7,7 @@ package cache
import (
"bufio"
"cmd/go/internal/base"
"cmd/go/internal/cacheprog"
"cmd/internal/quoted"
"context"
"crypto/sha256"
@@ -38,7 +39,7 @@ type ProgCache struct {
// can are the commands that the child process declared that it supports.
// This is effectively the versioning mechanism.
can map[ProgCmd]bool
can map[cacheprog.Cmd]bool
// fuzzDirCache is another Cache implementation to use for the FuzzDir
// method. In practice this is the default GOCACHE disk-based
@@ -55,7 +56,7 @@ type ProgCache struct {
mu sync.Mutex // guards following fields
nextID int64
inFlight map[int64]chan<- *ProgResponse
inFlight map[int64]chan<- *cacheprog.Response
outputFile map[OutputID]string // object => abs path on disk
// writeMu serializes writing to the child process.
@@ -63,95 +64,6 @@ type ProgCache struct {
writeMu sync.Mutex
}
// ProgCmd is a command that can be issued to a child process.
//
// If the interface needs to grow, we can add new commands or new versioned
// commands like "get2".
type ProgCmd string
const (
cmdGet = ProgCmd("get")
cmdPut = ProgCmd("put")
cmdClose = ProgCmd("close")
)
// ProgRequest is the JSON-encoded message that's sent from cmd/go to
// the GOCACHEPROG child process over stdin. Each JSON object is on its
// own line. A ProgRequest of Type "put" with BodySize > 0 will be followed
// by a line containing a base64-encoded JSON string literal of the body.
type ProgRequest struct {
// ID is a unique number per process across all requests.
// It must be echoed in the ProgResponse from the child.
ID int64
// Command is the type of request.
// The cmd/go tool will only send commands that were declared
// as supported by the child.
Command ProgCmd
// ActionID is non-nil for get and puts.
ActionID []byte `json:",omitempty"` // or nil if not used
// OutputID is set for Type "put".
//
// Prior to Go 1.24, when GOCACHEPROG was still an experiment, this was
// accidentally named ObjectID. It was renamed to OutputID in Go 1.24.
OutputID []byte `json:",omitempty"` // or nil if not used
// Body is the body for "put" requests. It's sent after the JSON object
// as a base64-encoded JSON string when BodySize is non-zero.
// It's sent as a separate JSON value instead of being a struct field
// send in this JSON object so large values can be streamed in both directions.
// The base64 string body of a ProgRequest will always be written
// immediately after the JSON object and a newline.
Body io.Reader `json:"-"`
// BodySize is the number of bytes of Body. If zero, the body isn't written.
BodySize int64 `json:",omitempty"`
// ObjectID is the accidental spelling of OutputID that was used prior to Go
// 1.24.
//
// Deprecated: use OutputID. This field is only populated temporarily for
// backwards compatibility with Go 1.23 and earlier when
// GOEXPERIMENT=gocacheprog is set. It will be removed in Go 1.25.
ObjectID []byte `json:",omitempty"`
}
// ProgResponse is the JSON response from the child process to cmd/go.
//
// With the exception of the first protocol message that the child writes to its
// stdout with ID==0 and KnownCommands populated, these are only sent in
// response to a ProgRequest from cmd/go.
//
// ProgResponses can be sent in any order. The ID must match the request they're
// replying to.
type ProgResponse struct {
ID int64 // that corresponds to ProgRequest; they can be answered out of order
Err string `json:",omitempty"` // if non-empty, the error
// KnownCommands is included in the first message that cache helper program
// writes to stdout on startup (with ID==0). It includes the
// ProgRequest.Command types that are supported by the program.
//
// This lets us extend the protocol gracefully over time (adding "get2",
// etc), or fail gracefully when needed. It also lets us verify the program
// wants to be a cache helper.
KnownCommands []ProgCmd `json:",omitempty"`
// For Get requests.
Miss bool `json:",omitempty"` // cache miss
OutputID []byte `json:",omitempty"`
Size int64 `json:",omitempty"` // in bytes
Time *time.Time `json:",omitempty"` // an Entry.Time; when the object was added to the docs
// DiskPath is the absolute path on disk of the ObjectID corresponding
// a "get" request's ActionID (on cache hit) or a "put" request's
// provided ObjectID.
DiskPath string `json:",omitempty"`
}
// startCacheProg starts the prog binary (with optional space-separated flags)
// and returns a Cache implementation that talks to it.
//
@@ -183,6 +95,8 @@ func startCacheProg(progAndArgs string, fuzzDirCache Cache) Cache {
base.Fatalf("StdinPipe to GOCACHEPROG: %v", err)
}
cmd.Stderr = os.Stderr
// On close, we cancel the context. Rather than killing the helper,
// close its stdin.
cmd.Cancel = in.Close
if err := cmd.Start(); err != nil {
@@ -197,14 +111,14 @@ func startCacheProg(progAndArgs string, fuzzDirCache Cache) Cache {
stdout: out,
stdin: in,
bw: bufio.NewWriter(in),
inFlight: make(map[int64]chan<- *ProgResponse),
inFlight: make(map[int64]chan<- *cacheprog.Response),
outputFile: make(map[OutputID]string),
readLoopDone: make(chan struct{}),
}
// Register our interest in the initial protocol message from the child to
// us, saying what it can do.
capResc := make(chan *ProgResponse, 1)
capResc := make(chan *cacheprog.Response, 1)
pc.inFlight[0] = capResc
pc.jenc = json.NewEncoder(pc.bw)
@@ -219,7 +133,7 @@ func startCacheProg(progAndArgs string, fuzzDirCache Cache) Cache {
case <-timer.C:
log.Printf("# still waiting for GOCACHEPROG %v ...", prog)
case capRes := <-capResc:
can := map[ProgCmd]bool{}
can := map[cacheprog.Cmd]bool{}
for _, cmd := range capRes.KnownCommands {
can[cmd] = true
}
@@ -236,9 +150,15 @@ func (c *ProgCache) readLoop(readLoopDone chan<- struct{}) {
defer close(readLoopDone)
jd := json.NewDecoder(c.stdout)
for {
res := new(ProgResponse)
res := new(cacheprog.Response)
if err := jd.Decode(res); err != nil {
if c.closing.Load() {
c.mu.Lock()
for _, ch := range c.inFlight {
close(ch)
}
c.inFlight = nil
c.mu.Unlock()
return // quietly
}
if err == io.EOF {
@@ -261,13 +181,18 @@ func (c *ProgCache) readLoop(readLoopDone chan<- struct{}) {
}
}
func (c *ProgCache) send(ctx context.Context, req *ProgRequest) (*ProgResponse, error) {
resc := make(chan *ProgResponse, 1)
var errCacheprogClosed = errors.New("GOCACHEPROG program closed unexpectedly")
func (c *ProgCache) send(ctx context.Context, req *cacheprog.Request) (*cacheprog.Response, error) {
resc := make(chan *cacheprog.Response, 1)
if err := c.writeToChild(req, resc); err != nil {
return nil, err
}
select {
case res := <-resc:
if res == nil {
return nil, errCacheprogClosed
}
if res.Err != "" {
return nil, errors.New(res.Err)
}
@@ -277,8 +202,11 @@ func (c *ProgCache) send(ctx context.Context, req *ProgRequest) (*ProgResponse,
}
}
func (c *ProgCache) writeToChild(req *ProgRequest, resc chan<- *ProgResponse) (err error) {
func (c *ProgCache) writeToChild(req *cacheprog.Request, resc chan<- *cacheprog.Response) (err error) {
c.mu.Lock()
if c.inFlight == nil {
return errCacheprogClosed
}
c.nextID++
req.ID = c.nextID
c.inFlight[req.ID] = resc
@@ -287,7 +215,9 @@ func (c *ProgCache) writeToChild(req *ProgRequest, resc chan<- *ProgResponse) (e
defer func() {
if err != nil {
c.mu.Lock()
delete(c.inFlight, req.ID)
if c.inFlight != nil {
delete(c.inFlight, req.ID)
}
c.mu.Unlock()
}
}()
@@ -328,7 +258,7 @@ func (c *ProgCache) writeToChild(req *ProgRequest, resc chan<- *ProgResponse) (e
}
func (c *ProgCache) Get(a ActionID) (Entry, error) {
if !c.can[cmdGet] {
if !c.can[cacheprog.CmdGet] {
// They can't do a "get". Maybe they're a write-only cache.
//
// TODO(bradfitz,bcmills): figure out the proper error type here. Maybe
@@ -338,8 +268,8 @@ func (c *ProgCache) Get(a ActionID) (Entry, error) {
// error types on the Cache interface.
return Entry{}, &entryNotFoundError{}
}
res, err := c.send(c.ctx, &ProgRequest{
Command: cmdGet,
res, err := c.send(c.ctx, &cacheprog.Request{
Command: cacheprog.CmdGet,
ActionID: a[:],
})
if err != nil {
@@ -395,7 +325,7 @@ func (c *ProgCache) Put(a ActionID, file io.ReadSeeker) (_ OutputID, size int64,
return OutputID{}, 0, err
}
if !c.can[cmdPut] {
if !c.can[cacheprog.CmdPut] {
// Child is a read-only cache. Do nothing.
return out, size, nil
}
@@ -407,8 +337,8 @@ func (c *ProgCache) Put(a ActionID, file io.ReadSeeker) (_ OutputID, size int64,
deprecatedValue = out[:]
}
res, err := c.send(c.ctx, &ProgRequest{
Command: cmdPut,
res, err := c.send(c.ctx, &cacheprog.Request{
Command: cacheprog.CmdPut,
ActionID: a[:],
OutputID: out[:],
ObjectID: deprecatedValue, // TODO(bradfitz): remove in Go 1.25
@@ -432,10 +362,16 @@ func (c *ProgCache) Close() error {
// First write a "close" message to the child so it can exit nicely
// and clean up if it wants. Only after that exchange do we cancel
// the context that kills the process.
if c.can[cmdClose] {
_, err = c.send(c.ctx, &ProgRequest{Command: cmdClose})
if c.can[cacheprog.CmdClose] {
_, err = c.send(c.ctx, &cacheprog.Request{Command: cacheprog.CmdClose})
if errors.Is(err, errCacheprogClosed) {
// Allow the child to quit without responding to close.
err = nil
}
}
// Cancel the context, which will close the helper's stdin.
c.ctxCancel()
// Wait until the helper closes its stdout.
<-c.readLoopDone
return err
}

View File

@@ -0,0 +1,137 @@
// Copyright 2024 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package cacheprog defines the protocol for a GOCACHEPROG program.
//
// By default, the go command manages a build cache stored in the file system
// itself. GOCACHEPROG can be set to the name of a command (with optional
// space-separated flags) that implements the go command build cache externally.
// This permits defining a different cache policy.
//
// The go command will start the GOCACHEPROG as a subprocess and communicate
// with it via JSON messages over stdin/stdout. The subprocess's stderr will be
// connected to the go command's stderr.
//
// The subprocess should immediately send a [Response] with its capabilities.
// After that, the go command will send a stream of [Request] messages and the
// subprocess should reply to each [Request] with a [Response] message.
package cacheprog
import (
"io"
"time"
)
// Cmd is a command that can be issued to a child process.
//
// If the interface needs to grow, the go command can add new commands or new
// versioned commands like "get2" in the future. The initial [Response] from
// the child process indicates which commands it supports.
type Cmd string
const (
// CmdPut tells the cache program to store an object in the cache.
//
// [Request.ActionID] is the cache key of this object. The cache should
// store [Request.OutputID] and [Request.Body] under this key for a
// later "get" request. It must also store the Body in a file in the local
// file system and return the path to that file in [Response.DiskPath],
// which must exist at least until a "close" request.
CmdPut = Cmd("put")
// CmdGet tells the cache program to retrieve an object from the cache.
//
// [Request.ActionID] specifies the key of the object to get. If the
// cache does not contain this object, it should set [Response.Miss] to
// true. Otherwise, it should populate the fields of [Response],
// including setting [Response.OutputID] to the OutputID of the original
// "put" request and [Response.DiskPath] to the path of a local file
// containing the Body of the original "put" request. That file must
// continue to exist at least until a "close" request.
CmdGet = Cmd("get")
// CmdClose requests that the cache program exit gracefully.
//
// The cache program should reply to this request and then exit
// (thus closing its stdout).
CmdClose = Cmd("close")
)
// Request is the JSON-encoded message that's sent from the go command to
// the GOCACHEPROG child process over stdin. Each JSON object is on its own
// line. A ProgRequest of Type "put" with BodySize > 0 will be followed by a
// line containing a base64-encoded JSON string literal of the body.
type Request struct {
// ID is a unique number per process across all requests.
// It must be echoed in the Response from the child.
ID int64
// Command is the type of request.
// The go command will only send commands that were declared
// as supported by the child.
Command Cmd
// ActionID is the cache key for "put" and "get" requests.
ActionID []byte `json:",omitempty"` // or nil if not used
// OutputID is stored with the body for "put" requests.
//
// Prior to Go 1.24, when GOCACHEPROG was still an experiment, this was
// accidentally named ObjectID. It was renamed to OutputID in Go 1.24.
OutputID []byte `json:",omitempty"` // or nil if not used
// Body is the body for "put" requests. It's sent after the JSON object
// as a base64-encoded JSON string when BodySize is non-zero.
// It's sent as a separate JSON value instead of being a struct field
// send in this JSON object so large values can be streamed in both directions.
// The base64 string body of a Request will always be written
// immediately after the JSON object and a newline.
Body io.Reader `json:"-"`
// BodySize is the number of bytes of Body. If zero, the body isn't written.
BodySize int64 `json:",omitempty"`
// ObjectID is the accidental spelling of OutputID that was used prior to Go
// 1.24.
//
// Deprecated: use OutputID. This field is only populated temporarily for
// backwards compatibility with Go 1.23 and earlier when
// GOEXPERIMENT=gocacheprog is set. It will be removed in Go 1.25.
ObjectID []byte `json:",omitempty"`
}
// Response is the JSON response from the child process to the go command.
//
// With the exception of the first protocol message that the child writes to its
// stdout with ID==0 and KnownCommands populated, these are only sent in
// response to a Request from the go command.
//
// Responses can be sent in any order. The ID must match the request they're
// replying to.
type Response struct {
ID int64 // that corresponds to Request; they can be answered out of order
Err string `json:",omitempty"` // if non-empty, the error
// KnownCommands is included in the first message that cache helper program
// writes to stdout on startup (with ID==0). It includes the
// Request.Command types that are supported by the program.
//
// This lets the go command extend the protocol gracefully over time (adding
// "get2", etc), or fail gracefully when needed. It also lets the go command
// verify the program wants to be a cache helper.
KnownCommands []Cmd `json:",omitempty"`
// For "get" requests.
Miss bool `json:",omitempty"` // cache miss
OutputID []byte `json:",omitempty"` // the ObjectID stored with the body
Size int64 `json:",omitempty"` // body size in bytes
Time *time.Time `json:",omitempty"` // when the object was put in the cache (optional; used for cache expiration)
// For "get" and "put" requests.
// DiskPath is the absolute path on disk of the body corresponding to a
// "get" (on cache hit) or "put" request's ActionID.
DiskPath string `json:",omitempty"`
}

View File

@@ -425,8 +425,9 @@ var (
GOROOTpkg string
GOROOTsrc string
GOBIN = Getenv("GOBIN")
GOMODCACHE, GOMODCACHEChanged = EnvOrAndChanged("GOMODCACHE", gopathDir("pkg/mod"))
GOBIN = Getenv("GOBIN")
GOCACHEPROG, GOCACHEPROGChanged = EnvOrAndChanged("GOCACHEPROG", "")
GOMODCACHE, GOMODCACHEChanged = EnvOrAndChanged("GOMODCACHE", gopathDir("pkg/mod"))
// Used in envcmd.MkEnv and build ID computations.
GOARM64, goARM64Changed = EnvOrAndChanged("GOARM64", buildcfg.DefaultGOARM64)

View File

@@ -85,6 +85,7 @@ func MkEnv() []cfg.EnvVar {
{Name: "GOAUTH", Value: cfg.GOAUTH, Changed: cfg.GOAUTHChanged},
{Name: "GOBIN", Value: cfg.GOBIN},
{Name: "GOCACHE"},
{Name: "GOCACHEPROG", Value: cfg.GOCACHEPROG, Changed: cfg.GOCACHEPROGChanged},
{Name: "GODEBUG", Value: os.Getenv("GODEBUG")},
{Name: "GOENV", Value: envFile, Changed: envFileChanged},
{Name: "GOEXE", Value: cfg.ExeSuffix},

View File

@@ -40,14 +40,8 @@
//
// GOFIPS140=latest go build -work my/binary
//
// will leave fips.o behind in $WORK/b001. Auditors like to be able to
// see that file. Accordingly, when [Enabled] returns true,
// [cmd/go/internal/work.Builder.useCache] arranges never to cache linker
// output, so that the link step always runs, and fips.o is always left
// behind in the link step. If this proves too slow, we could always
// cache fips.o as an extra link output and then restore it when -work is
// set, but we went a very long time never caching link steps at all, so
// not caching them in FIPS mode seems perfectly fine.
// will leave fips.o behind in $WORK/b001
// (unless the build result is cached, of course).
//
// When GOFIPS140 is set to something besides off and latest, [Snapshot]
// returns true, indicating that the build should replace the latest copy
@@ -119,6 +113,10 @@ func Init() {
if Snapshot() {
fsys.Bind(Dir(), filepath.Join(cfg.GOROOT, "src/crypto/internal/fips140"))
}
if cfg.Experiment.BoringCrypto && Enabled() {
base.Fatalf("go: cannot use GOFIPS140 with GOEXPERIMENT=boringcrypto")
}
}
var initDone bool

View File

@@ -17,7 +17,7 @@ information on how to use it see the cgo documentation (go doc cmd/cgo).
The second is the SWIG program, which is a general tool for
interfacing between languages. For information on SWIG see
http://swig.org/. When running go build, any file with a .swig
https://swig.org/. When running go build, any file with a .swig
extension will be passed to SWIG. Any file with a .swigcxx extension
will be passed to SWIG with the -c++ option.
@@ -270,11 +270,7 @@ the go tool will verify that https://example.org/?go-get=1 contains the
same meta tag and then git clone https://code.org/r/p/exproj into
GOPATH/src/example.org.
When using GOPATH, downloaded packages are written to the first directory
listed in the GOPATH environment variable.
(See 'go help gopath-get' and 'go help gopath'.)
When using modules, downloaded packages are stored in the module cache.
Downloaded packages are stored in the module cache.
See https://golang.org/ref/mod#module-cache.
When using modules, an additional variant of the go-import meta tag is
@@ -510,9 +506,14 @@ General-purpose environment variables:
GOCACHE
The directory where the go command will store cached
information for reuse in future builds.
GOCACHEPROG
A command (with optional space-separated flags) that implements an
external go command build cache.
See 'go doc cmd/go/internal/cacheprog'.
GODEBUG
Enable various debugging facilities. See https://go.dev/doc/godebug
for details.
Enable various debugging facilities for programs built with Go,
including the go command. Cannot be set using 'go env -w'.
See https://go.dev/doc/godebug for details.
GOENV
The location of the Go environment configuration file.
Cannot be set using 'go env -w'.
@@ -620,6 +621,11 @@ Architecture-specific environment variables:
GOARM
For GOARCH=arm, the ARM architecture for which to compile.
Valid values are 5, 6, 7.
When the Go tools are built on an arm system,
the default value is set based on what the build system supports.
When the Go tools are not built on an arm system
(that is, when building a cross-compiler),
the default value is 7.
The value can be followed by an option specifying how to implement floating point instructions.
Valid options are ,softfloat (default for 5) and ,hardfloat (default for 6 and 7).
GOARM64
@@ -1029,7 +1035,7 @@ command
Example: Data
If the server responds with any 4xx code, the go command will write the
following to the programs' stdin:
following to the program's stdin:
Response = StatusLine { HeaderLine } BlankLine .
StatusLine = Protocol Space Status '\n' .
Protocol = /* HTTP protocol */ .
@@ -1044,8 +1050,7 @@ command
Content-Type: text/plain; charset=utf-8
Date: Thu, 07 Nov 2024 18:43:09 GMT
Note: at least for HTTP 1.1, the contents written to stdin can be parsed
as an HTTP response.
Note: it is safe to use net/http.ReadResponse to parse this input.
Before the first HTTPS fetch, the go command will invoke each GOAUTH
command in the list with no additional arguments and no input.
@@ -1097,7 +1102,7 @@ Furthermore, as with TestEvent, parsers can simply concatenate the Output
fields of all events to reconstruct the text format output, as it would
have appeared from go build without the -json flag.
Note that there may also be non-JSON error text on stdnard error, even
Note that there may also be non-JSON error text on standard error, even
with the -json flag. Typically, this indicates an early, serious error.
Consumers should be robust to this.
`,

View File

@@ -3068,7 +3068,15 @@ func setPGOProfilePath(pkgs []*Package) {
// CheckPackageErrors prints errors encountered loading pkgs and their
// dependencies, then exits with a non-zero status if any errors were found.
func CheckPackageErrors(pkgs []*Package) {
var anyIncomplete bool
PackageErrors(pkgs, func(p *Package) {
DefaultPrinter().Errorf(p, "%v", p.Error)
})
base.ExitIfErrors()
}
// PackageErrors calls report for errors encountered loading pkgs and their dependencies.
func PackageErrors(pkgs []*Package, report func(*Package)) {
var anyIncomplete, anyErrors bool
for _, pkg := range pkgs {
if pkg.Incomplete {
anyIncomplete = true
@@ -3078,11 +3086,14 @@ func CheckPackageErrors(pkgs []*Package) {
all := PackageList(pkgs)
for _, p := range all {
if p.Error != nil {
DefaultPrinter().Errorf(p, "%v", p.Error)
report(p)
anyErrors = true
}
}
}
base.ExitIfErrors()
if anyErrors {
return
}
// Check for duplicate loads of the same package.
// That should be impossible, but if it does happen then
@@ -3105,7 +3116,9 @@ func CheckPackageErrors(pkgs []*Package) {
}
seen[key] = true
}
base.ExitIfErrors()
if len(reported) > 0 {
base.ExitIfErrors()
}
}
// mainPackagesOnly filters out non-main packages matched only by arguments

View File

@@ -22,10 +22,11 @@ type Data struct {
}
// Mmap maps the given file into memory.
func Mmap(file string) (Data, error) {
func Mmap(file string) (Data, bool, error) {
f, err := os.Open(file)
if err != nil {
return Data{}, err
return Data{}, false, err
}
return mmapFile(f)
data, err := mmapFile(f)
return data, true, err
}

View File

@@ -0,0 +1,32 @@
// Copyright 2025 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package mmap
import (
"bytes"
"testing"
)
// TestMmap does a round trip to make sure the slice returned by
// mmap contains the same data as was written to the file. It's
// a test on one of the issues in #71059: on Windows we were
// returning a slice containing all the data in the mmapped pages,
// which could be longer than the file.
func TestMmap(t *testing.T) {
// Use an already existing file as our test data. Avoid creating
// a temporary file so that we don't have to close the mapping on
// Windows before deleting the file during test cleanup.
f := "testdata/small_file.txt"
want := []byte("This file is shorter than 4096 bytes.\n")
data, _, err := Mmap(f)
if err != nil {
t.Fatalf("calling Mmap: %v", err)
}
if !bytes.Equal(data.Data, want) {
t.Fatalf("mmapped data slice: got %q; want %q", data.Data, want)
}
}

View File

@@ -37,5 +37,11 @@ func mmapFile(f *os.File) (Data, error) {
return Data{}, fmt.Errorf("VirtualQuery %s: %w", f.Name(), err)
}
data := unsafe.Slice((*byte)(unsafe.Pointer(addr)), int(info.RegionSize))
return Data{f, data}, nil
if len(data) < int(size) {
// In some cases, especially on 386, we may not receive a in incomplete mapping:
// one that is shorter than the file itself. Return an error in those cases because
// incomplete mappings are not useful.
return Data{}, fmt.Errorf("mmapFile: received incomplete mapping of file")
}
return Data{f, data[:int(size)]}, nil
}

View File

@@ -0,0 +1 @@
This file is shorter than 4096 bytes.

View File

@@ -113,6 +113,13 @@ func DownloadDir(ctx context.Context, m module.Version) (string, error) {
return dir, err
}
// Special case: ziphash is not required for the golang.org/fips140 module,
// because it is unpacked from a file in GOROOT, not downloaded.
// We've already checked that it's not a partial unpacking, so we're happy.
if m.Path == "golang.org/fips140" {
return dir, nil
}
// Check if a .ziphash file exists. It should be created before the
// zip is extracted, but if it was deleted (by another program?), we need
// to re-calculate it. Note that checkMod will repopulate the ziphash

View File

@@ -649,7 +649,21 @@ func (r *gitRepo) statLocal(ctx context.Context, version, rev string) (*RevInfo,
}
}
}
sort.Strings(info.Tags)
// Git 2.47.1 does not send the tags during shallow clone anymore
// (perhaps the exact version that changed behavior is an earlier one),
// so we have to also add tags from the refs list we fetched with ls-remote.
if refs, err := r.loadRefs(ctx); err == nil {
for ref, h := range refs {
if h == hash {
if tag, found := strings.CutPrefix(ref, "refs/tags/"); found {
info.Tags = append(info.Tags, tag)
}
}
}
}
slices.Sort(info.Tags)
info.Tags = slices.Compact(info.Tags)
// Used hash as info.Version above.
// Use caller's suggested version if it appears in the tag list

View File

@@ -125,11 +125,6 @@ suggested Go toolchain, see https://go.dev/doc/toolchain.
For more about specifying packages, see 'go help packages'.
This text describes the behavior of get using modules to manage source
code and dependencies. If instead the go command is running in GOPATH
mode, the details of get's flags and effects change, as does 'go help get'.
See 'go help gopath-get'.
See also: go build, go install, go clean, go mod.
`,
}

View File

@@ -33,10 +33,7 @@ import (
"cmd/internal/par"
)
// enabled is used to flag off the behavior of the module index on tip.
// It will be removed before the release.
// TODO(matloob): Remove enabled once we have more confidence on the
// module index.
// enabled is used to flag off the behavior of the module index on tip, for debugging.
var enabled = godebug.New("#goindex").Value() != "0"
// Module represents and encoded module index file. It is used to
@@ -126,6 +123,7 @@ var ErrNotIndexed = errors.New("not in module index")
var (
errDisabled = fmt.Errorf("%w: module indexing disabled", ErrNotIndexed)
errNotFromModuleCache = fmt.Errorf("%w: not from module cache", ErrNotIndexed)
errFIPS140 = fmt.Errorf("%w: fips140 snapshots not indexed", ErrNotIndexed)
)
// GetPackage returns the IndexPackage for the directory at the given path.
@@ -143,6 +141,11 @@ func GetPackage(modroot, pkgdir string) (*IndexPackage, error) {
if cfg.BuildContext.Compiler == "gccgo" && str.HasPathPrefix(modroot, cfg.GOROOTsrc) {
return nil, err // gccgo has no sources for GOROOT packages.
}
// The pkgdir for fips140 has been replaced in the fsys overlay,
// but the module index does not see that. Do not try to use the module index.
if strings.Contains(filepath.ToSlash(pkgdir), "internal/fips140/v") {
return nil, errFIPS140
}
return openIndexPackage(modroot, pkgdir)
}
@@ -183,16 +186,21 @@ func openIndexModule(modroot string, ismodcache bool) (*Module, error) {
if err != nil {
return nil, err
}
data, _, err := cache.GetMmap(cache.Default(), id)
data, _, opened, err := cache.GetMmap(cache.Default(), id)
if err != nil {
// Couldn't read from modindex. Assume we couldn't read from
// the index because the module hasn't been indexed yet.
// But double check on Windows that we haven't opened the file yet,
// because once mmap opens the file, we can't close it, and
// Windows won't let us open an already opened file.
data, err = indexModule(modroot)
if err != nil {
return nil, err
}
if err = cache.PutBytes(cache.Default(), id, data); err != nil {
return nil, err
if runtime.GOOS != "windows" || !opened {
if err = cache.PutBytes(cache.Default(), id, data); err != nil {
return nil, err
}
}
}
mi, err := fromBytes(modroot, data)
@@ -212,13 +220,18 @@ func openIndexPackage(modroot, pkgdir string) (*IndexPackage, error) {
if err != nil {
return nil, err
}
data, _, err := cache.GetMmap(cache.Default(), id)
data, _, opened, err := cache.GetMmap(cache.Default(), id)
if err != nil {
// Couldn't read from index. Assume we couldn't read from
// the index because the package hasn't been indexed yet.
// But double check on Windows that we haven't opened the file yet,
// because once mmap opens the file, we can't close it, and
// Windows won't let us open an already opened file.
data = indexPackage(modroot, pkgdir)
if err = cache.PutBytes(cache.Default(), id, data); err != nil {
return nil, err
if runtime.GOOS != "windows" || !opened {
if err = cache.PutBytes(cache.Default(), id, data); err != nil {
return nil, err
}
}
}
pkg, err := packageFromBytes(modroot, data)

View File

@@ -44,6 +44,17 @@ func ReadModFile(gomod string, fix modfile.VersionFixer) (data []byte, f *modfil
f, err = modfile.Parse(gomod, data, fix)
if err != nil {
f, laxErr := modfile.ParseLax(gomod, data, fix)
if laxErr == nil {
if f.Go != nil && gover.Compare(f.Go.Version, gover.Local()) > 0 {
toolchain := ""
if f.Toolchain != nil {
toolchain = f.Toolchain.Name
}
return nil, nil, &gover.TooNewError{What: base.ShortPath(gomod), GoVersion: f.Go.Version, Toolchain: toolchain}
}
}
// Errors returned by modfile.Parse begin with file:line.
return nil, nil, fmt.Errorf("errors parsing %s:\n%w", base.ShortPath(gomod), shortPathErrorList(err))
}

View File

@@ -994,14 +994,15 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) {
// Prepare build + run + print actions for all packages being tested.
for _, p := range pkgs {
buildTest, runTest, printTest, perr, err := builderTest(b, ctx, pkgOpts, p, allImports[p], writeCoverMetaAct)
if err != nil {
reportErr := func(perr *load.Package, err error) {
str := err.Error()
if p.ImportPath != "" {
load.DefaultPrinter().Errorf(perr, "# %s\n%s", p.ImportPath, str)
} else {
load.DefaultPrinter().Errorf(perr, "%s", str)
}
}
reportSetupFailed := func(perr *load.Package, err error) {
var stdout io.Writer = os.Stdout
if testJSON {
json := test2json.NewConverter(stdout, p.ImportPath, test2json.Timestamp)
@@ -1009,11 +1010,34 @@ func runTest(ctx context.Context, cmd *base.Command, args []string) {
json.Exited(err)
json.Close()
}()
json.SetFailedBuild(perr.Desc())
if gotestjsonbuildtext.Value() == "1" {
// While this flag is about go build -json, the other effect
// of that change was to include "FailedBuild" in the test JSON.
gotestjsonbuildtext.IncNonDefault()
} else {
json.SetFailedBuild(perr.Desc())
}
stdout = json
}
fmt.Fprintf(stdout, "FAIL\t%s [setup failed]\n", p.ImportPath)
base.SetExitStatus(1)
}
var firstErrPkg *load.Package // arbitrarily report setup failed error for first error pkg reached in DFS
load.PackageErrors([]*load.Package{p}, func(p *load.Package) {
reportErr(p, p.Error)
if firstErrPkg == nil {
firstErrPkg = p
}
})
if firstErrPkg != nil {
reportSetupFailed(firstErrPkg, firstErrPkg.Error)
continue
}
buildTest, runTest, printTest, perr, err := builderTest(b, ctx, pkgOpts, p, allImports[p], writeCoverMetaAct)
if err != nil {
reportErr(perr, err)
reportSetupFailed(perr, err)
continue
}
builds = append(builds, buildTest)
@@ -1437,7 +1461,11 @@ func (r *runTestActor) Act(b *work.Builder, ctx context.Context, a *work.Action)
if a.Failed != nil {
// We were unable to build the binary.
if json != nil && a.Failed.Package != nil {
json.SetFailedBuild(a.Failed.Package.Desc())
if gotestjsonbuildtext.Value() == "1" {
gotestjsonbuildtext.IncNonDefault()
} else {
json.SetFailedBuild(a.Failed.Package.Desc())
}
}
a.Failed = nil
fmt.Fprintf(stdout, "FAIL\t%s [build failed]\n", a.Package.ImportPath)

View File

@@ -169,7 +169,7 @@ func Select() {
}
gotoolchain = minToolchain
if (mode == "auto" || mode == "path") && !goInstallVersion() {
if (mode == "auto" || mode == "path") && !goInstallVersion(minVers) {
// Read go.mod to find new minimum and suggested toolchain.
file, goVers, toolchain := modGoToolchain()
gover.Startup.AutoFile = file
@@ -549,7 +549,7 @@ func modGoToolchain() (file, goVers, toolchain string) {
// goInstallVersion reports whether the command line is go install m@v or go run m@v.
// If so, Select must not read the go.mod or go.work file in "auto" or "path" mode.
func goInstallVersion() bool {
func goInstallVersion(minVers string) bool {
// Note: We assume there are no flags between 'go' and 'install' or 'run'.
// During testing there are some debugging flags that are accepted
// in that position, but in production go binaries there are not.
@@ -708,7 +708,11 @@ func goInstallVersion() bool {
if errors.Is(err, gover.ErrTooNew) {
// Run early switch, same one go install or go run would eventually do,
// if it understood all the command-line flags.
SwitchOrFatal(ctx, err)
var s Switcher
s.Error(err)
if s.TooNew != nil && gover.Compare(s.TooNew.GoVersion, minVers) > 0 {
SwitchOrFatal(ctx, err)
}
}
return true // pkg@version found

View File

@@ -63,6 +63,7 @@ func (h *authHandler) Handler(dir string, env []string, logger *log.Logger) (htt
var err error
accessFile, err = fs.Open(path.Join(accessDir, ".access"))
if err == nil {
defer accessFile.Close()
break
}

View File

@@ -15,7 +15,6 @@ import (
"cmd/go/internal/base"
"cmd/go/internal/cache"
"cmd/go/internal/cfg"
"cmd/go/internal/fips140"
"cmd/go/internal/fsys"
"cmd/go/internal/str"
"cmd/internal/buildid"
@@ -447,19 +446,6 @@ func (b *Builder) useCache(a *Action, actionHash cache.ActionID, target string,
a.buildID = actionID + buildIDSeparator + mainpkg.buildID + buildIDSeparator + contentID
}
// In FIPS mode, we disable any link caching,
// so that we always leave fips.o in $WORK/b001.
// This makes sure that labs validating the FIPS
// implementation can always run 'go build -work'
// and then find fips.o in $WORK/b001/fips.o.
// We could instead also save the fips.o and restore it
// to $WORK/b001 from the cache,
// but we went years without caching binaries anyway,
// so not caching them for FIPS will be fine, at least to start.
if a.Mode == "link" && fips140.Enabled() && a.Package != nil && !strings.HasSuffix(a.Package.ImportPath, ".test") {
return false
}
// If user requested -a, we force a rebuild, so don't use the cache.
if cfg.BuildA {
if p := a.Package; p != nil && !p.Stale {
@@ -519,7 +505,7 @@ func (b *Builder) useCache(a *Action, actionHash cache.ActionID, target string,
oldBuildID := a.buildID
a.buildID = id[1] + buildIDSeparator + id[2]
linkID := buildid.HashToString(b.linkActionID(a.triggers[0]))
if id[0] == linkID && !fips140.Enabled() {
if id[0] == linkID {
// Best effort attempt to display output from the compile and link steps.
// If it doesn't work, it doesn't work: reusing the cached binary is more
// important than reprinting diagnostic information.

View File

@@ -1374,6 +1374,7 @@ func (b *Builder) linkActionID(a *Action) cache.ActionID {
fmt.Fprintf(h, "buildmode %s goos %s goarch %s\n", cfg.BuildBuildmode, cfg.Goos, cfg.Goarch)
fmt.Fprintf(h, "import %q\n", p.ImportPath)
fmt.Fprintf(h, "omitdebug %v standard %v local %v prefix %q\n", p.Internal.OmitDebug, p.Standard, p.Internal.Local, p.Internal.LocalPrefix)
fmt.Fprintf(h, "defaultgodebug %q\n", p.DefaultGODEBUG)
if cfg.BuildTrimpath {
fmt.Fprintln(h, "trimpath")
}

View File

@@ -201,23 +201,23 @@ var validLinkerFlags = []*lazyregexp.Regexp{
re(`-Wl,--end-group`),
re(`-Wl,--(no-)?export-dynamic`),
re(`-Wl,-E`),
re(`-Wl,-framework,[^,@\-][^,]+`),
re(`-Wl,-framework,[^,@\-][^,]*`),
re(`-Wl,--hash-style=(sysv|gnu|both)`),
re(`-Wl,-headerpad_max_install_names`),
re(`-Wl,--no-undefined`),
re(`-Wl,--pop-state`),
re(`-Wl,--push-state`),
re(`-Wl,-R,?([^@\-,][^,@]*$)`),
re(`-Wl,--just-symbols[=,]([^,@\-][^,@]+)`),
re(`-Wl,-rpath(-link)?[=,]([^,@\-][^,]+)`),
re(`-Wl,--just-symbols[=,]([^,@\-][^,@]*)`),
re(`-Wl,-rpath(-link)?[=,]([^,@\-][^,]*)`),
re(`-Wl,-s`),
re(`-Wl,-search_paths_first`),
re(`-Wl,-sectcreate,([^,@\-][^,]+),([^,@\-][^,]+),([^,@\-][^,]+)`),
re(`-Wl,-sectcreate,([^,@\-][^,]*),([^,@\-][^,]*),([^,@\-][^,]*)`),
re(`-Wl,--start-group`),
re(`-Wl,-?-static`),
re(`-Wl,-?-subsystem,(native|windows|console|posix|xbox)`),
re(`-Wl,-syslibroot[=,]([^,@\-][^,]+)`),
re(`-Wl,-undefined[=,]([^,@\-][^,]+)`),
re(`-Wl,-syslibroot[=,]([^,@\-][^,]*)`),
re(`-Wl,-undefined[=,]([^,@\-][^,]*)`),
re(`-Wl,-?-unresolved-symbols=[^,]+`),
re(`-Wl,--(no-)?warn-([^,]+)`),
re(`-Wl,-?-wrap[=,][^,@\-][^,]*`),

View File

@@ -182,6 +182,13 @@ var goodLinkerFlags = [][]string{
{"-Wl,--pop-state"},
{"-Wl,--push-state,--as-needed"},
{"-Wl,--push-state,--no-as-needed,-Bstatic"},
{"-Wl,--just-symbols,."},
{"-Wl,-framework,."},
{"-Wl,-rpath,."},
{"-Wl,-rpath-link,."},
{"-Wl,-sectcreate,.,.,."},
{"-Wl,-syslibroot,."},
{"-Wl,-undefined,."},
}
var badLinkerFlags = [][]string{

View File

@@ -0,0 +1,27 @@
[short] skip 'builds go programs'
go build -o cacheprog$GOEXE cacheprog.go
env GOCACHEPROG=$GOPATH/src/cacheprog$GOEXE
# This should not deadlock
go build simple.go
! stderr 'cacheprog closed'
-- simple.go --
package main
func main() {}
-- cacheprog.go --
// This is a minimal GOCACHEPROG program that doesn't respond to close.
package main
import (
"encoding/json"
"os"
)
func main() {
json.NewEncoder(os.Stdout).Encode(map[string][]string{"KnownCommands": {"close"}})
var res struct{}
json.NewDecoder(os.Stdin).Decode(&res)
}

View File

@@ -51,7 +51,7 @@ go version -m example$GOEXE
stdout '\s+mod\s+example\s+v1.0.1\s+'
rm example$GOEXE
# Use tag+dirty when there are uncomitted changes present.
# Use tag+dirty when there are uncommitted changes present.
cp $WORK/copy/README $WORK/repo/README
go build
go version -m example$GOEXE
@@ -82,7 +82,7 @@ go version -m example$GOEXE
stdout '\s+mod\s+example\s+v1.0.3-0.20220719150702-deaeab06f7fe\s+'
rm example$GOEXE
# Use pseudo+dirty when uncomitted changes are present.
# Use pseudo+dirty when uncommitted changes are present.
mv README2 README3
go build
go version -m example$GOEXE

View File

@@ -0,0 +1,50 @@
# Testcase for #70244. In this bug we're doing a "go test -coverprofile"
# run for a pair of packages, the first one without tests and the second
# one with tests. When writing the profile for the second test, profile
# data from the first package was leaking into the output (we should
# only see lines in the output profile for the package whose test is
# being run).
[short] skip
# Kick off test.
go test -vet=off -count=1 -coverprofile=cov.p ./...
# Generate a function profile.
go tool cover -func=cov.p
# Prior to GOEXPERIMENT=coverageredesign we should see no output at all for
# pkg1 (since it has no tests).
[!GOEXPERIMENT:coverageredesign] ! stdout 'pkg1'
# With GOEXPERIMENT=coverageredesign enabled we should see zero percent
# coverage for pkg1's DoSomething, not 100% (as in the bug).
[GOEXPERIMENT:coverageredesign] stdout 'cov/pkg1/file.go:3:\s+DoSomething\s+0.0%'
-- go.mod --
module cov
-- pkg1/file.go --
package pkg1
func DoSomething() bool {
return true
}
-- pkg2/file.go --
package pkg2
func DoSomething() bool {
return true
}
-- pkg2/file_test.go --
package pkg2
import (
"cov/pkg1"
"testing"
)
func TestSmth(t *testing.T) {
pkg1.DoSomething()
DoSomething()
}

View File

@@ -1,5 +1,8 @@
# Test query for non-defaults in the env
# Go+BoringCrypto conflicts with GOFIPS140.
[GOEXPERIMENT:boringcrypto] skip
env GOROOT=./a
env GOTOOLCHAIN=local
env GOSUMDB=nodefault

View File

@@ -0,0 +1,42 @@
# GOCACHEPROG unset
env GOCACHEPROG=
go env
stdout 'GOCACHEPROG=''?''?'
go env -changed
! stdout 'GOCACHEPROG'
go env -changed -json
! stdout 'GOCACHEPROG'
# GOCACHEPROG set
[short] skip 'compiles and runs a go program'
go build -o cacheprog$GOEXE cacheprog.go
env GOCACHEPROG=$GOPATH/src/cacheprog$GOEXE
go env
stdout 'GOCACHEPROG=''?'$GOCACHEPROG'''?'
go env -changed
stdout 'GOCACHEPROG=''?'$GOCACHEPROG'''?'
go env -changed -json
stdout '"GOCACHEPROG": ".*cacheprog'$GOEXE'"'
-- cacheprog.go --
// This is a minimal GOCACHEPROG program that can't actually do anything but exit.
package main
import (
"encoding/json"
"os"
)
func main() {
json.NewEncoder(os.Stdout).Encode(map[string][]string{"KnownCommands": {"close"}})
var res struct{}
json.NewDecoder(os.Stdin).Decode(&res)
}

View File

@@ -1,3 +1,6 @@
# Go+BoringCrypto conflicts with GOFIPS140.
[GOEXPERIMENT:boringcrypto] skip
# list with GOFIPS140=off
env GOFIPS140=off
go list -f '{{.DefaultGODEBUG}}'
@@ -17,12 +20,12 @@ go build -x -o x.exe
go build -x -o x.exe
! stderr link
# build with GOFIPS140=latest is NOT cached (need fipso)
# build with GOFIPS140=latest is cached too
env GOFIPS140=latest
go build -x -o x.exe
stderr link.*-fipso
go build -x -o x.exe
stderr link.*-fipso
! stderr link.*-fipso
# build test with GOFIPS140=off is cached
env GOFIPS140=off
@@ -38,8 +41,6 @@ stderr link.*-fipso
go test -x -c
! stderr link
-- go.mod --
module m
-- x.go --

View File

@@ -1,12 +1,11 @@
## Note: Need a snapshot in lib/fips140 to run this test.
## For local testing, can run 'cd lib/fips140; make v0.0.1.test'
## and then remove the skip.
env snap=v0.0.1
env snap=v1.0.0
env alias=inprocess
skip 'no snapshots yet'
env GOFIPS140=$snap
# Go+BoringCrypto conflicts with GOFIPS140.
[GOEXPERIMENT:boringcrypto] skip
# default GODEBUG includes fips140=on
go list -f '{{.DefaultGODEBUG}}'
stdout fips140=on
@@ -24,7 +23,8 @@ stdout crypto/internal/fips140/$snap/sha256
! stdout crypto/internal/fips140/check
# again with GOFIPS140=$alias
env GOFIPS140=$alias
# TODO: enable when we add inprocess.txt
# env GOFIPS140=$alias
# default GODEBUG includes fips140=on
go list -f '{{.DefaultGODEBUG}}'
@@ -44,11 +44,11 @@ stdout crypto/internal/fips140/$snap/sha256
[short] skip
# build with GOFIPS140=snap is NOT cached (need fipso)
# build with GOFIPS140=snap is cached
go build -x -o x.exe
stderr link.*-fipso
go build -x -o x.exe
stderr link.*-fipso
! stderr link.*-fipso
# build test with GOFIPS140=snap is cached
go test -x -c

View File

@@ -2,8 +2,6 @@
# credentials passed in HTTPS requests to VCS servers.
# See golang.org/issue/26232
[short] skip
env GOPROXY=direct
env GOSUMDB=off
@@ -56,6 +54,18 @@ env NETRC=$WORK/missing
! go get vcs-test.golang.org/auth/or401
stderr '^\tserver response: ACCESS DENIED, buddy$'
[short] skip 'requires a remote vcs lookup'
[!git] skip
# An unset home directory should warn the user but not cause a failure.
env NETRC=
env HOME=
env USERPROFILE=
env home=
go get -x vcs-test.golang.org/git/emptytest.git
[!GOOS:windows] [!GOOS:plan9] stderr 'GOAUTH=netrc: \$HOME is not defined'
[GOOS:windows] stderr 'GOAUTH=netrc: \%userprofile\% is not defined'
[GOOS:plan9] stderr 'GOAUTH=netrc: \$home is not defined'
-- go.mod --
module private.example.com
-- $WORK/empty --
@@ -63,3 +73,7 @@ module private.example.com
machine vcs-test.golang.org
login aladdin
password opensesame
# first one should override this one
machine vcs-test.golang.org
login aladdin
password ignored

View File

@@ -3,13 +3,8 @@
env GOPROXY=direct
env GOSUMDB=off
# Use a custom authenticator to provide custom credentials
mkdir $WORK/bin
env PATH=$WORK/bin${:}$PATH
cd auth
go build -o $WORK/bin/my-auth$GOEXE .
cd ..
# Without credentials, downloading a module from a path that requires HTTPS
# basic auth should fail.
@@ -21,8 +16,10 @@ stderr '^\tserver response: ACCESS DENIED, buddy$'
! go mod tidy
stderr '^\tserver response: ACCESS DENIED, buddy$'
# With credentials from the my-auth binary, it should succeed.
env GOAUTH='my-auth'$GOEXE' --arg1 "value with spaces"'
# Initial invocation of authenticator is successful.
go build -o $WORK/bin/basic$GOEXE scripts/basic.go
# With credentials from the binary, it should succeed.
env GOAUTH='basic'$GOEXE
cp go.mod.orig go.mod
go get vcs-test.golang.org/auth/or401
# go imports should resolve correctly as well.
@@ -30,7 +27,54 @@ go mod tidy
go list all
stdout vcs-test.golang.org/auth/or401
-- auth/main.go --
# Second invocation of authenticator is successful.
go build -o $WORK/bin/reinvocation$GOEXE scripts/reinvocation.go
# With credentials from the binary, it should succeed.
env GOAUTH='reinvocation'$GOEXE
cp go.mod.orig go.mod
go get vcs-test.golang.org/auth/or401
# go imports should resolve correctly as well.
go mod tidy
go list all
stdout vcs-test.golang.org/auth/or401
# Authenticator can parse arguments correctly.
go build -o $WORK/bin/arguments$GOEXE scripts/arguments.go
# With credentials from the binary, it should succeed.
env GOAUTH='arguments'$GOEXE' --arg1 "value with spaces"'
cp go.mod.orig go.mod
go get vcs-test.golang.org/auth/or401
# go imports should resolve correctly as well.
go mod tidy
go list all
stdout vcs-test.golang.org/auth/or401
# Authenticator provides bad credentials.
go build -o $WORK/bin/invalid$GOEXE scripts/invalid.go
# With credentials from the binary, it should fail.
env GOAUTH='invalid'$GOEXE
cp go.mod.orig go.mod
! go get vcs-test.golang.org/auth/or401
stderr '^\tserver response: ACCESS DENIED, buddy$'
# go imports should fail as well.
! go mod tidy
stderr '^\tserver response: ACCESS DENIED, buddy$'
-- go.mod.orig --
module private.example.com
-- main.go --
package useprivate
import "vcs-test.golang.org/auth/or401"
-- scripts/basic.go --
package main
import "fmt"
func main() {
fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\n\n")
}
-- scripts/reinvocation.go --
package main
import(
@@ -45,11 +89,7 @@ import(
)
func main() {
arg1 := flag.String("arg1", "", "")
flag.Parse()
if *arg1 != "value with spaces" {
log.Fatal("argument with spaces does not work")
}
// wait for re-invocation
if !strings.HasPrefix(flag.Arg(0), "https://vcs-test.golang.org") {
return
@@ -68,12 +108,28 @@ func main() {
}
fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\n\n")
}
-- scripts/arguments.go --
package main
-- auth/go.mod --
module my-auth
-- go.mod.orig --
module private.example.com
-- main.go --
package useprivate
import(
"flag"
"fmt"
"log"
)
import "vcs-test.golang.org/auth/or401"
func main() {
arg1 := flag.String("arg1", "", "")
flag.Parse()
if *arg1 != "value with spaces" {
log.Fatal("argument with spaces does not work")
}
fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l\n\n")
}
-- scripts/invalid.go --
package main
import "fmt"
func main() {
fmt.Printf("https://vcs-test.golang.org\n\nAuthorization: Basic invalid\n\n")
}

View File

@@ -197,6 +197,17 @@ go mod edit -go=1.501 -toolchain=none
go version
stdout go1.501
# avoid two-step switch, first from install target requirement, then from GOTOOLCHAIN min
# instead, just jump directly to GOTOOLCHAIN min
env TESTGO_VERSION=go1.2.3
env GODEBUG=toolchaintrace=1
env GOTOOLCHAIN=go1.23.0+auto
! go install rsc.io/fortune/nonexist@v0.0.1
! stderr 'switching to go1.22.9'
stderr 'using go1.23.0'
env GODEBUG=
env GOTOOLCHAIN=auto
# go install m@v and go run m@v should ignore go.mod and use m@v
env TESTGO_VERSION=go1.2.3
go mod edit -go=1.999 -toolchain=go1.998

View File

@@ -3,4 +3,4 @@ env GO111MODULE=on
# go help get shows usage for get
go help get
stdout 'usage: go get'
stdout 'get using modules to manage source'
stdout 'updates go.mod to require those versions'

View File

@@ -0,0 +1,11 @@
env GOTOOLCHAIN=local
! go list .
stderr 'go: go.mod requires go >= 1.999'
-- go.mod --
module example.com
go 1.999
anewblock foo

View File

@@ -15,8 +15,8 @@ stdout '\Aok\s+example.com/x\s+[0-9.s]+\n\z'
# Even though ./x looks like a package path, the real package should be
# the implicit '.'.
! go test --answer=42 ./x
stdout '^FAIL\t. \[build failed\]'
stderr '^\.: no Go files in '$PWD'$'
stdout '^FAIL\t. \[setup failed\]'
stderr '^# \.\nno Go files in '$PWD'$'
# However, *flags* that appear after unrecognized flags should still be
# interpreted as flags, under the (possibly-erroneous) assumption that

View File

@@ -0,0 +1,47 @@
[!fuzz] skip
[short] skip
env GOCACHE=$WORK/cache
# Test fuzz.Context.
go test -vet=off context_fuzz_test.go
stdout ^ok
! stdout FAIL
go test -vet=off -fuzz=Fuzz -fuzztime=1x context_fuzz_test.go
stdout ok
! stdout FAIL
-- context_fuzz_test.go --
package context_fuzz
import (
"context"
"errors"
"testing"
)
func Fuzz(f *testing.F) {
ctx := f.Context()
if err := ctx.Err(); err != nil {
f.Fatalf("expected non-canceled context, got %v", err)
}
f.Fuzz(func(t *testing.T, data []byte) {
innerCtx := t.Context()
if err := innerCtx.Err(); err != nil {
t.Fatalf("expected inner test to not inherit canceled context, got %v", err)
}
t.Cleanup(func() {
if !errors.Is(innerCtx.Err(), context.Canceled) {
t.Fatal("expected context of inner test to be canceled after its fuzz function finished")
}
})
})
f.Cleanup(func() {
if !errors.Is(ctx.Err(), context.Canceled) {
f.Fatal("expected context canceled before cleanup")
}
})
}

View File

@@ -40,6 +40,18 @@ stdout '"Action":"output","Package":"m/loaderror","Output":"FAIL\\tm/loaderror \
stdout '"Action":"fail","Package":"m/loaderror","Elapsed":.*,"FailedBuild":"x"'
! stderr '.'
# Test an import cycle loading error in a non test file. (#70820)
! go test -json -o=$devnull ./cycle/p
stdout '"ImportPath":"m/cycle/q","Action":"build-output","Output":"# m/cycle/p\\n"'
stdout '"ImportPath":"m/cycle/q","Action":"build-output","Output":"package m/cycle/p\\n"'
stdout '"ImportPath":"m/cycle/q","Action":"build-output","Output":"\\timports m/cycle/q from p.go\\n"'
stdout '"ImportPath":"m/cycle/q","Action":"build-output","Output":"\\timports m/cycle/q from q.go: import cycle not allowed\\n"'
stdout '"ImportPath":"m/cycle/q","Action":"build-fail"'
stdout '"Action":"start","Package":"m/cycle/p"'
stdout '"Action":"output","Package":"m/cycle/p","Output":"FAIL\\tm/cycle/p \[setup failed\]\\n"'
stdout '"Action":"fail","Package":"m/cycle/p","Elapsed":.*,"FailedBuild":"m/cycle/q"'
! stderr '.'
# Test a vet error
! go test -json -o=$devnull ./veterror
stdout '"ImportPath":"m/veterror \[m/veterror.test\]","Action":"build-output","Output":"# m/veterror\\n"'
@@ -58,8 +70,9 @@ stderr '# m/builderror \[m/builderror.test\]\n'
stderr 'builderror'${/}'main_test.go:3:11: undefined: y\n'
stdout '"Action":"start","Package":"m/builderror"'
stdout '"Action":"output","Package":"m/builderror","Output":"FAIL\\tm/builderror \[build failed\]\\n"'
stdout '"Action":"fail","Package":"m/builderror","Elapsed":.*,"FailedBuild":"m/builderror \[m/builderror\.test\]"'
stdout '"Action":"fail","Package":"m/builderror","Elapsed":[0-9.]+\}'
# FailedBuild should NOT appear in the output in this mode.
! stdout '"FailedBuild"'
-- go.mod --
module m
@@ -98,3 +111,13 @@ import (
func TestVetError(t *testing.T) {
fmt.Printf("%s")
}
-- cycle/p/p.go --
package p
import "m/cycle/q"
-- cycle/q/q.go --
package q
import (
"m/cycle/q"
)

View File

@@ -33,10 +33,23 @@ stderr '# m/t2/p\n.*package x is not in std'
stdout 'FAIL m/t2/p \[setup failed\]'
stdout 'ok m/t'
# Finally, this one is a build error, but produced by cmd/go directly
# Test that an import cycle error is reported. Test for #70820
! go test -o=$devnull ./cycle/p ./t
stderr '# m/cycle/p\n.*package m/cycle/p\n\timports m/cycle/p from p\.go: import cycle not allowed'
stdout 'FAIL m/cycle/p \[setup failed\]'
stdout 'ok m/t'
# Test that multiple errors for the same package under test are reported.
! go test -o=$devnull ./cycle/q ./t
stderr '# m/cycle/q\n.*package m/cycle/q\n\timports m/cycle/p from q\.go\n\timports m/cycle/p from p\.go: import cycle not allowed'
stdout 'FAIL m/cycle/q \[setup failed\]'
stdout 'ok m/t'
# Finally, this one is a non-import-cycle load error that
# is produced for the package under test.
! go test -o=$devnull . ./t
stderr '^\.: no Go files in '$PWD'$'
stdout 'FAIL . \[build failed\]'
stderr '# \.\n.*no Go files in '$PWD'$'
stdout 'FAIL . \[setup failed\]'
stdout 'ok m/t'
-- go.mod --
@@ -68,6 +81,17 @@ package p
package p
import "m/bad"
-- cycle/p/p.go --
package p
import "m/cycle/p"
-- cycle/q/q.go --
package q
import (
"m/bad"
"m/cycle/p"
)
-- bad/bad.go --
package bad

View File

@@ -2,13 +2,16 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package objfile
// Package disasm provides disassembly routines.
//
// It is broken out from cmd/internal/objfile so tools that don't need
// disassembling don't need to depend on x/arch disassembler code.
package disasm
import (
"bufio"
"bytes"
"container/list"
"debug/gosym"
"encoding/binary"
"fmt"
"io"
@@ -19,6 +22,7 @@ import (
"strings"
"text/tabwriter"
"cmd/internal/objfile"
"cmd/internal/src"
"golang.org/x/arch/arm/armasm"
@@ -32,8 +36,8 @@ import (
// Disasm is a disassembler for a given File.
type Disasm struct {
syms []Sym //symbols in file, sorted by address
pcln Liner // pcln table
syms []objfile.Sym // symbols in file, sorted by address
pcln objfile.Liner // pcln table
text []byte // bytes of text segment (actual instructions)
textStart uint64 // start PC of text
textEnd uint64 // end PC of text
@@ -42,8 +46,12 @@ type Disasm struct {
byteOrder binary.ByteOrder // byte order for goarch
}
// Disasm returns a disassembler for the file f.
func (e *Entry) Disasm() (*Disasm, error) {
// DisasmForFile returns a disassembler for the file f.
func DisasmForFile(f *objfile.File) (*Disasm, error) {
return disasmForEntry(f.Entries()[0])
}
func disasmForEntry(e *objfile.Entry) (*Disasm, error) {
syms, err := e.Symbols()
if err != nil {
return nil, err
@@ -269,7 +277,7 @@ func (d *Disasm) Print(w io.Writer, filter *regexp.Regexp, start, end uint64, pr
}
// Decode disassembles the text segment range [start, end), calling f for each instruction.
func (d *Disasm) Decode(start, end uint64, relocs []Reloc, gnuAsm bool, f func(pc, size uint64, file string, line int, text string)) {
func (d *Disasm) Decode(start, end uint64, relocs []objfile.Reloc, gnuAsm bool, f func(pc, size uint64, file string, line int, text string)) {
if start < d.textStart {
start = d.textStart
}
@@ -402,14 +410,16 @@ func disasm_ppc64(code []byte, pc uint64, lookup lookupFunc, byteOrder binary.By
func disasm_riscv64(code []byte, pc uint64, lookup lookupFunc, byteOrder binary.ByteOrder, gnuAsm bool) (string, int) {
inst, err := riscv64asm.Decode(code)
var text string
size := inst.Len
if err != nil || inst.Op == 0 {
size = 2
text = "?"
} else if gnuAsm {
text = fmt.Sprintf("%-36s // %s", riscv64asm.GoSyntax(inst, pc, lookup, textReader{code, pc}), riscv64asm.GNUSyntax(inst))
} else {
text = riscv64asm.GoSyntax(inst, pc, lookup, textReader{code, pc})
}
return text, 4
return text, size
}
func disasm_s390x(code []byte, pc uint64, lookup lookupFunc, _ binary.ByteOrder, gnuAsm bool) (string, int) {
@@ -452,9 +462,3 @@ var byteOrders = map[string]binary.ByteOrder{
"riscv64": binary.LittleEndian,
"s390x": binary.BigEndian,
}
type Liner interface {
// Given a pc, returns the corresponding file, line, and function data.
// If unknown, returns "",0,nil.
PCToLine(uint64) (string, int, *gosym.Func)
}

View File

@@ -110,11 +110,13 @@ var builtins = [...]struct {
{"runtime.mapassign_fast64ptr", 1},
{"runtime.mapassign_faststr", 1},
{"runtime.mapiterinit", 1},
{"runtime.mapIterStart", 1},
{"runtime.mapdelete", 1},
{"runtime.mapdelete_fast32", 1},
{"runtime.mapdelete_fast64", 1},
{"runtime.mapdelete_faststr", 1},
{"runtime.mapiternext", 1},
{"runtime.mapIterNext", 1},
{"runtime.mapclear", 1},
{"runtime.makechan64", 1},
{"runtime.makechan", 1},

View File

@@ -5,22 +5,33 @@
// Package hash implements hash functions used in the compiler toolchain.
package hash
// TODO(rsc): Delete the 16 and 20 forms and use 32 at all call sites.
import (
"crypto/md5"
"crypto/sha1"
"crypto/sha256"
"hash"
)
const (
// Size32 is the size of 32 bytes hash checksum.
Size32 = sha256.Size
// Size20 is the size of 20 bytes hash checksum.
Size20 = sha1.Size
// Size16 is the size of 16 bytes hash checksum.
Size16 = md5.Size
// Size32 is the size of the 32-byte hash checksum.
Size32 = 32
// Size20 is the size of the 20-byte hash checksum.
Size20 = 20
// Size16 is the size of the 16-byte hash checksum.
Size16 = 16
)
type shortHash struct {
hash.Hash
n int
}
func (h *shortHash) Sum(b []byte) []byte {
old := b
sum := h.Hash.Sum(b)
return sum[:len(old)+h.n]
}
// New32 returns a new [hash.Hash] computing the 32 bytes hash checksum.
func New32() hash.Hash {
h := sha256.New()
@@ -30,12 +41,12 @@ func New32() hash.Hash {
// New20 returns a new [hash.Hash] computing the 20 bytes hash checksum.
func New20() hash.Hash {
return sha1.New()
return &shortHash{New32(), 20}
}
// New16 returns a new [hash.Hash] computing the 16 bytes hash checksum.
func New16() hash.Hash {
return md5.New()
return &shortHash{New32(), 16}
}
// Sum32 returns the 32 bytes checksum of the data.
@@ -47,10 +58,16 @@ func Sum32(data []byte) [Size32]byte {
// Sum20 returns the 20 bytes checksum of the data.
func Sum20(data []byte) [Size20]byte {
return sha1.Sum(data)
sum := Sum32(data)
var short [Size20]byte
copy(short[:], sum[4:])
return short
}
// Sum16 returns the 16 bytes checksum of the data.
func Sum16(data []byte) [Size16]byte {
return md5.Sum(data)
sum := Sum32(data)
var short [Size16]byte
copy(short[:], sum[8:])
return short
}

View File

@@ -320,7 +320,7 @@ func (ctxt *Link) NumberSyms() {
// Assign special index for builtin symbols.
// Don't do it when linking against shared libraries, as the runtime
// may be in a different library.
if i := goobj.BuiltinIdx(rs.Name, int(rs.ABI())); i != -1 {
if i := goobj.BuiltinIdx(rs.Name, int(rs.ABI())); i != -1 && !rs.IsLinkname() {
rs.PkgIdx = goobj.PkgIdxBuiltin
rs.SymIdx = int32(i)
rs.Set(AttrIndexed, true)

View File

@@ -129,6 +129,7 @@ var (
morestackNoCtxt *obj.LSym
sigpanic *obj.LSym
wasm_pc_f_loop_export *obj.LSym
runtimeNotInitialized *obj.LSym
)
const (
@@ -149,6 +150,7 @@ func instinit(ctxt *obj.Link) {
morestackNoCtxt = ctxt.Lookup("runtime.morestack_noctxt")
sigpanic = ctxt.LookupABI("runtime.sigpanic", obj.ABIInternal)
wasm_pc_f_loop_export = ctxt.Lookup("wasm_pc_f_loop_export")
runtimeNotInitialized = ctxt.Lookup("runtime.notInitialized")
}
func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
@@ -255,7 +257,7 @@ func preprocess(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
p = appendp(p, AEnd)
}
if framesize > 0 {
if framesize > 0 && s.Func().WasmExport == nil { // genWasmExportWrapper has its own prologue generation
p := s.Func().Text
p = appendp(p, AGet, regAddr(REG_SP))
p = appendp(p, AI32Const, constAddr(framesize))
@@ -935,6 +937,23 @@ func genWasmExportWrapper(s *obj.LSym, appendp func(p *obj.Prog, as obj.As, args
panic("wrapper functions for WASM export should not have a body")
}
// Detect and error out if called before runtime initialization
// SP is 0 if not initialized
p = appendp(p, AGet, regAddr(REG_SP))
p = appendp(p, AI32Eqz)
p = appendp(p, AIf)
p = appendp(p, ACall, obj.Addr{Type: obj.TYPE_MEM, Name: obj.NAME_EXTERN, Sym: runtimeNotInitialized})
p = appendp(p, AEnd)
// Now that we've checked the SP, generate the prologue
if framesize > 0 {
p = appendp(p, AGet, regAddr(REG_SP))
p = appendp(p, AI32Const, constAddr(framesize))
p = appendp(p, AI32Sub)
p = appendp(p, ASet, regAddr(REG_SP))
p.Spadj = int32(framesize)
}
// Store args
for i, f := range we.Params {
p = appendp(p, AGet, regAddr(REG_SP))
@@ -1056,6 +1075,7 @@ var notUsePC_B = map[string]bool{
"runtime.gcWriteBarrier6": true,
"runtime.gcWriteBarrier7": true,
"runtime.gcWriteBarrier8": true,
"runtime.notInitialized": true,
"runtime.wasmDiv": true,
"runtime.wasmTruncS": true,
"runtime.wasmTruncU": true,
@@ -1121,7 +1141,8 @@ func assemble(ctxt *obj.Link, s *obj.LSym, newprog obj.ProgAlloc) {
"runtime.gcWriteBarrier5",
"runtime.gcWriteBarrier6",
"runtime.gcWriteBarrier7",
"runtime.gcWriteBarrier8":
"runtime.gcWriteBarrier8",
"runtime.notInitialized":
// no locals
useAssemblyRegMap()
default:

View File

@@ -119,10 +119,6 @@ func (f *File) DWARF() (*dwarf.Data, error) {
return f.entries[0].DWARF()
}
func (f *File) Disasm() (*Disasm, error) {
return f.entries[0].Disasm()
}
func (e *Entry) Name() string {
return e.name
}
@@ -181,3 +177,9 @@ func (e *Entry) LoadAddress() (uint64, error) {
func (e *Entry) DWARF() (*dwarf.Data, error) {
return e.raw.dwarf()
}
type Liner interface {
// Given a pc, returns the corresponding file, line, and function data.
// If unknown, returns "",0,nil.
PCToLine(uint64) (string, int, *gosym.Func)
}

View File

@@ -118,6 +118,7 @@ Flags:
Link with race detection libraries.
-s
Omit the symbol table and debug information.
Implies the -w flag, which can be negated with -w=0.
-tmpdir dir
Write temporary files to dir.
Temporary files are only used in external linking mode.

View File

@@ -55,17 +55,31 @@ import (
)
// isRuntimeDepPkg reports whether pkg is the runtime package or its dependency.
// TODO: just compute from the runtime package, and remove this hardcoded list.
func isRuntimeDepPkg(pkg string) bool {
switch pkg {
case "runtime",
"sync/atomic", // runtime may call to sync/atomic, due to go:linkname
"internal/abi", // used by reflectcall (and maybe more)
"internal/bytealg", // for IndexByte
"sync/atomic", // runtime may call to sync/atomic, due to go:linkname // TODO: this is not true?
"internal/abi", // used by reflectcall (and maybe more)
"internal/asan",
"internal/bytealg", // for IndexByte
"internal/byteorder",
"internal/chacha8rand", // for rand
"internal/cpu": // for cpu features
"internal/coverage/rtcov",
"internal/cpu", // for cpu features
"internal/goarch",
"internal/godebugs",
"internal/goexperiment",
"internal/goos",
"internal/msan",
"internal/profilerecord",
"internal/race",
"internal/stringslite",
"unsafe":
return true
}
return strings.HasPrefix(pkg, "runtime/internal/") && !strings.HasSuffix(pkg, "_test")
return (strings.HasPrefix(pkg, "runtime/internal/") || strings.HasPrefix(pkg, "internal/runtime/")) &&
!strings.HasSuffix(pkg, "_test")
}
// Estimate the max size needed to hold any new trampolines created for this function. This
@@ -410,6 +424,9 @@ func (st *relocSymState) relocsym(s loader.Sym, P []byte) {
// FIXME: It should be forbidden to have R_ADDR from a
// symbol which isn't in .data. However, as .text has the
// same address once loaded, this is possible.
// TODO: .text (including rodata) to .data relocation
// doesn't work correctly, so we should really disallow it.
// See also aixStaticDataBase in symtab.go and in runtime.
if ldr.SymSect(s).Seg == &Segdata {
Xcoffadddynrel(target, ldr, syms, s, r, ri)
}

View File

@@ -520,7 +520,7 @@ func (d *dwctxt) defgotype(gotype loader.Sym) loader.Sym {
d.linkctxt.Errorf(gotype, "dwarf: type name doesn't start with \"type:\"")
return d.mustFind("<unspecified>")
}
name := sn[5:] // could also decode from Type.string
name := sn[len("type:"):] // could also decode from Type.string
sdie := d.find(name)
if sdie != 0 {
@@ -534,7 +534,7 @@ func (d *dwctxt) defgotype(gotype loader.Sym) loader.Sym {
func (d *dwctxt) newtype(gotype loader.Sym) *dwarf.DWDie {
sn := d.ldr.SymName(gotype)
name := sn[5:] // could also decode from Type.string
name := sn[len("type:"):] // could also decode from Type.string
tdata := d.ldr.Data(gotype)
if len(tdata) == 0 {
d.linkctxt.Errorf(gotype, "missing type")

View File

@@ -707,6 +707,17 @@ func (ctxt *Link) symtab(pcln *pclntab) []sym.SymKind {
// except go:buildid which is generated late and not used by the program.
addRef("go:buildid")
}
if ctxt.IsAIX() {
// On AIX, an R_ADDR relocation from an RODATA symbol to a DATA symbol
// does not work. See data.go:relocsym, case R_ADDR.
// Here we record the unrelocated address in aixStaticDataBase (it is
// unrelocated as it is in RODATA) so we can compute the delta at
// run time.
sb := ldr.CreateSymForUpdate("runtime.aixStaticDataBase", 0)
sb.SetSize(0)
sb.AddAddr(ctxt.Arch, ldr.Lookup("runtime.data", 0))
sb.SetType(sym.SRODATA)
}
// text section information
slice(textsectionmapSym, uint64(nsections))

View File

@@ -2338,6 +2338,45 @@ var blockedLinknames = map[string][]string{
"runtime.newcoro": {"iter"},
// fips info
"go:fipsinfo": {"crypto/internal/fips140/check"},
// New internal linknames in Go 1.24
// Pushed from runtime
"crypto/internal/fips140.fatal": {"crypto/internal/fips140"},
"crypto/internal/fips140.getIndicator": {"crypto/internal/fips140"},
"crypto/internal/fips140.setIndicator": {"crypto/internal/fips140"},
"crypto/internal/sysrand.fatal": {"crypto/internal/sysrand"},
"crypto/rand.fatal": {"crypto/rand"},
"internal/runtime/maps.errNilAssign": {"internal/runtime/maps"},
"internal/runtime/maps.fatal": {"internal/runtime/maps"},
"internal/runtime/maps.mapKeyError": {"internal/runtime/maps"},
"internal/runtime/maps.newarray": {"internal/runtime/maps"},
"internal/runtime/maps.newobject": {"internal/runtime/maps"},
"internal/runtime/maps.typedmemclr": {"internal/runtime/maps"},
"internal/runtime/maps.typedmemmove": {"internal/runtime/maps"},
"internal/sync.fatal": {"internal/sync"},
"internal/sync.runtime_canSpin": {"internal/sync"},
"internal/sync.runtime_doSpin": {"internal/sync"},
"internal/sync.runtime_nanotime": {"internal/sync"},
"internal/sync.runtime_Semrelease": {"internal/sync"},
"internal/sync.runtime_SemacquireMutex": {"internal/sync"},
"internal/sync.throw": {"internal/sync"},
"internal/synctest.Run": {"internal/synctest"},
"internal/synctest.Wait": {"internal/synctest"},
"internal/synctest.acquire": {"internal/synctest"},
"internal/synctest.release": {"internal/synctest"},
"internal/synctest.inBubble": {"internal/synctest"},
"runtime.getStaticuint64s": {"reflect"},
"sync.runtime_SemacquireWaitGroup": {"sync"},
"time.runtimeNow": {"time"},
"time.runtimeNano": {"time"},
// Pushed to runtime from internal/runtime/maps
// (other map functions are already linknamed in Go 1.23)
"runtime.mapaccess1": {"runtime"},
"runtime.mapaccess1_fast32": {"runtime"},
"runtime.mapaccess1_fast64": {"runtime"},
"runtime.mapaccess1_faststr": {"runtime"},
"runtime.mapdelete_fast32": {"runtime"},
"runtime.mapdelete_fast64": {"runtime"},
"runtime.mapdelete_faststr": {"runtime"},
}
// check if a linkname reference to symbol s from pkg is allowed
@@ -2355,6 +2394,16 @@ func (l *Loader) checkLinkname(pkg, name string, s Sym) {
if pkg == p {
return // pkg is allowed
}
// crypto/internal/fips140/vX.Y.Z/... is the frozen version of
// crypto/internal/fips140/... and is similarly allowed.
if strings.HasPrefix(pkg, "crypto/internal/fips140/v") {
parts := strings.Split(pkg, "/")
parts = append(parts[:3], parts[4:]...)
pkg := strings.Join(parts, "/")
if pkg == p {
return
}
}
}
error()
}

Some files were not shown because too many files have changed in this diff Show More