Compare commits

...

6 Commits

Author SHA1 Message Date
NARITA a6764c97a8
Merge e693ddf520 into 49cdf0c42e 2025-06-20 15:31:53 -04:00
Damien Neil 49cdf0c42e testing, testing/synctest: handle T.Helper in synctest bubbles
Fixes #74199

Change-Id: I6a15fbd59a3a3f8c496440f56d09d695e1504e4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/682576
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
2025-06-20 12:29:58 -07:00
cuishuang 3bf1eecbd3 runtime: fix struct comment
Change-Id: I0c33830b13c8a187ac82504c7653abb8f8cf7530
Reviewed-on: https://go-review.googlesource.com/c/go/+/681655
Reviewed-by: Sean Liao <sean@liao.dev>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Sean Liao <sean@liao.dev>
2025-06-20 11:28:03 -07:00
Sean Liao 8ed23a2936 crypto/cipher: fix link to crypto/aes
Fixes #74309

Change-Id: I4d97514355d825124a8d879c2590b45b039f5fd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/682596
Reviewed-by: Daniel McCarney <daniel@binaryparadox.net>
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>
2025-06-20 11:09:26 -07:00
Adam Bender ef60769b46 go/doc: add a golden test that reproduces #62640
For #62640.
For #61394.

This is a copy of https://go-review.googlesource.com/c/go/+/528402,
which has stalled in review and the owner is no longer working on Go.

Change-Id: Ic7a1ae65c70d4857ab1061ccae1a926bf5c4ff55
Reviewed-on: https://go-review.googlesource.com/c/go/+/681235
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Junyang Shao <shaojunyang@google.com>
2025-06-20 10:05:12 -07:00
Rikiya Narita e693ddf520 cmd/go: mod edit: add -droptoolchain flag 2025-05-19 21:56:33 +09:00
12 changed files with 177 additions and 13 deletions

View File

@ -1235,6 +1235,8 @@
// This flag is mainly for tools that understand Go version dependencies.
// Users should prefer 'go get toolchain@version'.
//
// The -droptoolchain flag removes the toolchain directive from the go.mod file.
//
// The -exclude=path@version and -dropexclude=path@version flags
// add and drop an exclusion for the given module path and version.
// Note that -exclude=path@version is a no-op if that exclusion already exists.
@ -1264,7 +1266,7 @@
//
// The -godebug, -dropgodebug, -require, -droprequire, -exclude, -dropexclude,
// -replace, -dropreplace, -retract, -dropretract, -tool, -droptool, -ignore,
// and -dropignore editing flags may be repeated, and the changes are applied
// -dropignore, and -droptoolchain editing flags may be repeated, and the changes are applied
// in the order given.
//
// The -print flag prints the final go.mod in its text format instead of
@ -1806,7 +1808,7 @@
// To view the current telemetry mode, run "go telemetry".
// To disable telemetry uploading, but keep local data collection, run
// "go telemetry local".
// To enable both collection and uploading, run “go telemetry on”.
// To enable both collection and uploading, run "go telemetry on".
// To disable both collection and uploading, run "go telemetry off".
//
// The current telemetry mode is also available as the value of the

View File

@ -66,6 +66,8 @@ The -toolchain=version flag sets the Go toolchain to use.
This flag is mainly for tools that understand Go version dependencies.
Users should prefer 'go get toolchain@version'.
The -droptoolchain flag removes the toolchain directive from the go.mod file.
The -exclude=path@version and -dropexclude=path@version flags
add and drop an exclusion for the given module path and version.
Note that -exclude=path@version is a no-op if that exclusion already exists.
@ -95,7 +97,7 @@ for the given path.
The -godebug, -dropgodebug, -require, -droprequire, -exclude, -dropexclude,
-replace, -dropreplace, -retract, -dropretract, -tool, -droptool, -ignore,
and -dropignore editing flags may be repeated, and the changes are applied
-dropignore, and -droptoolchain editing flags may be repeated, and the changes are applied
in the order given.
The -print flag prints the final go.mod in its text format instead of
@ -169,13 +171,14 @@ See https://golang.org/ref/mod#go-mod-edit for more about 'go mod edit'.
}
var (
editFmt = cmdEdit.Flag.Bool("fmt", false, "")
editGo = cmdEdit.Flag.String("go", "", "")
editToolchain = cmdEdit.Flag.String("toolchain", "", "")
editJSON = cmdEdit.Flag.Bool("json", false, "")
editPrint = cmdEdit.Flag.Bool("print", false, "")
editModule = cmdEdit.Flag.String("module", "", "")
edits []func(*modfile.File) // edits specified in flags
editFmt = cmdEdit.Flag.Bool("fmt", false, "")
editGo = cmdEdit.Flag.String("go", "", "")
editToolchain = cmdEdit.Flag.String("toolchain", "", "")
editJSON = cmdEdit.Flag.Bool("json", false, "")
editPrint = cmdEdit.Flag.Bool("print", false, "")
editModule = cmdEdit.Flag.String("module", "", "")
editDropToolchain = cmdEdit.Flag.Bool("droptoolchain", false, "drop the toolchain directive")
edits []func(*modfile.File) // edits specified in flags
)
type flagFunc func(string)
@ -213,6 +216,7 @@ func runEdit(ctx context.Context, cmd *base.Command, args []string) {
*editJSON ||
*editPrint ||
*editFmt ||
*editDropToolchain ||
len(edits) > 0
if !anyFlags {
@ -223,6 +227,10 @@ func runEdit(ctx context.Context, cmd *base.Command, args []string) {
base.Fatalf("go: cannot use both -json and -print")
}
if *editToolchain != "" && *editDropToolchain {
base.Fatalf("go: -toolchain and -droptoolchain are mutually exclusive")
}
if len(args) > 1 {
base.Fatalf("go: too many arguments")
}
@ -278,6 +286,9 @@ func runEdit(ctx context.Context, cmd *base.Command, args []string) {
base.Fatalf("go: internal error: %v", err)
}
}
if *editDropToolchain {
modFile.DropToolchainStmt()
}
if len(edits) > 0 {
for _, edit := range edits {

View File

@ -0,0 +1,35 @@
# Test for go mod edit -droptoolchain
# Setup
env GO111MODULE=on
env GOFLAGS=-mod=mod
# Create a new module
! exists go.mod
go mod init example.com/test
exists go.mod
# Check that the toolchain directive is not present initially
! grep toolchain go.mod
# Add a toolchain directive
go mod edit -toolchain=go1.21
grep 'toolchain go1.21' go.mod
# Remove the toolchain directive using -droptoolchain
go mod edit -droptoolchain
! grep toolchain go.mod
# Add a toolchain directive again
go mod edit -toolchain=go1.22
grep 'toolchain go1.22' go.mod
# Make sure that -toolchain=none still works as before
go mod edit -toolchain=none
! grep toolchain go.mod
# Add a toolchain directive again and use -droptoolchain with an argument (should be ignored)
go mod edit -toolchain=go1.23
grep 'toolchain go1.23' go.mod
go mod edit -droptoolchain
! grep toolchain go.mod

View File

@ -82,7 +82,7 @@ func newGCM(cipher Block, nonceSize, tagSize int) (AEAD, error) {
// NewGCMWithRandomNonce returns the given cipher wrapped in Galois Counter
// Mode, with randomly-generated nonces. The cipher must have been created by
// [aes.NewCipher].
// [crypto/aes.NewCipher].
//
// It generates a random 96-bit nonce, which is prepended to the ciphertext by Seal,
// and is extracted from the ciphertext by Open. The NonceSize of the AEAD is zero,

22
src/go/doc/testdata/issue62640.0.golden vendored Normal file
View File

@ -0,0 +1,22 @@
//
PACKAGE issue62640
IMPORTPATH
testdata/issue62640
FILENAMES
testdata/issue62640.go
TYPES
//
type E struct{}
// F should be hidden within S because of the S.F field.
func (E) F()
//
type S struct {
E
F int
}

22
src/go/doc/testdata/issue62640.1.golden vendored Normal file
View File

@ -0,0 +1,22 @@
//
PACKAGE issue62640
IMPORTPATH
testdata/issue62640
FILENAMES
testdata/issue62640.go
TYPES
//
type E struct{}
// F should be hidden within S because of the S.F field.
func (E) F()
//
type S struct {
E
F int
}

25
src/go/doc/testdata/issue62640.2.golden vendored Normal file
View File

@ -0,0 +1,25 @@
//
PACKAGE issue62640
IMPORTPATH
testdata/issue62640
FILENAMES
testdata/issue62640.go
TYPES
//
type E struct{}
// F should be hidden within S because of the S.F field.
func (E) F()
//
type S struct {
E
F int
}
// F should be hidden within S because of the S.F field.
func (S) F()

15
src/go/doc/testdata/issue62640.go vendored Normal file
View File

@ -0,0 +1,15 @@
// 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 issue62640
type E struct{}
// F should be hidden within S because of the S.F field.
func (E) F() {}
type S struct {
E
F int
}

View File

@ -312,8 +312,10 @@ type heapArena struct {
// during marking.
pageSpecials [pagesPerArena / 8]uint8
// pageUseSpanDartboard is a bitmap that indicates which spans are
// heap spans and also gcUsesSpanDartboard.
// pageUseSpanInlineMarkBits is a bitmap where each bit corresponds
// to a span, as only spans one page in size can have inline mark bits.
// The bit indicates that the span has a spanInlineMarkBits struct
// stored directly at the top end of the span's memory.
pageUseSpanInlineMarkBits [pagesPerArena / 8]uint8
// checkmarks stores the debug.gccheckmark state. It is only

View File

@ -0,0 +1,15 @@
// 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 synctest_test
import "testing"
// helperLog is a t.Helper which logs.
// Since it is a helper, the log prefix should contain
// the caller's file, not helper_test.go.
func helperLog(t *testing.T, s string) {
t.Helper()
t.Log(s)
}

View File

@ -140,6 +140,18 @@ func TestRun(t *testing.T) {
})
}
func TestHelper(t *testing.T) {
runTest(t, []string{"-test.v"}, func() {
synctest.Test(t, func(t *testing.T) {
helperLog(t, "log in helper")
})
}, `^=== RUN TestHelper
synctest_test.go:.* log in helper
--- PASS: TestHelper.*
PASS
$`)
}
func wantPanic(t *testing.T, want string) {
if e := recover(); e != nil {
if got := fmt.Sprint(e); got != want {

View File

@ -1261,6 +1261,9 @@ func (c *common) Skipped() bool {
// When printing file and line information, that function will be skipped.
// Helper may be called simultaneously from multiple goroutines.
func (c *common) Helper() {
if c.isSynctest {
c = c.parent
}
c.mu.Lock()
defer c.mu.Unlock()
if c.helperPCs == nil {