Skip to content

Commit d53373c

Browse files
committed
Merge master
2 parents 21bf051 + 63229bc commit d53373c

File tree

498 files changed

+10235
-7153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

498 files changed

+10235
-7153
lines changed

blog/blog.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -420,7 +420,7 @@ type rootData struct {
420420
BasePath string
421421
GodocURL string
422422
AnalyticsHTML template.HTML
423-
Data interface{}
423+
Data any
424424
}
425425

426426
// ServeHTTP serves the front, index, and article pages

cmd/bundle/gotypesalias.go

-12
This file was deleted.

cmd/callgraph/gotypesalias.go

-12
This file was deleted.

cmd/callgraph/main_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// No testdata on Android.
66

77
//go:build !android && go1.11
8-
// +build !android,go1.11
98

109
package main
1110

cmd/deadcode/deadcode.go

+1-40
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func main() {
175175
}
176176
}
177177

178-
if isGenerated(file) {
178+
if ast.IsGenerated(file) {
179179
generated[p.Fset.File(file.Pos()).Name()] = true
180180
}
181181
}
@@ -414,45 +414,6 @@ func printObjects(format string, objects []any) {
414414
}
415415
}
416416

417-
// TODO(adonovan): use go1.21's ast.IsGenerated.
418-
419-
// isGenerated reports whether the file was generated by a program,
420-
// not handwritten, by detecting the special comment described
421-
// at https://go.dev/s/generatedcode.
422-
//
423-
// The syntax tree must have been parsed with the ParseComments flag.
424-
// Example:
425-
//
426-
// f, err := parser.ParseFile(fset, filename, src, parser.ParseComments|parser.PackageClauseOnly)
427-
// if err != nil { ... }
428-
// gen := ast.IsGenerated(f)
429-
func isGenerated(file *ast.File) bool {
430-
_, ok := generator(file)
431-
return ok
432-
}
433-
434-
func generator(file *ast.File) (string, bool) {
435-
for _, group := range file.Comments {
436-
for _, comment := range group.List {
437-
if comment.Pos() > file.Package {
438-
break // after package declaration
439-
}
440-
// opt: check Contains first to avoid unnecessary array allocation in Split.
441-
const prefix = "// Code generated "
442-
if strings.Contains(comment.Text, prefix) {
443-
for _, line := range strings.Split(comment.Text, "\n") {
444-
if rest, ok := strings.CutPrefix(line, prefix); ok {
445-
if gen, ok := strings.CutSuffix(rest, " DO NOT EDIT."); ok {
446-
return gen, true
447-
}
448-
}
449-
}
450-
}
451-
}
452-
}
453-
return "", false
454-
}
455-
456417
// pathSearch returns the shortest path from one of the roots to one
457418
// of the targets (along with the root itself), or zero if no path was found.
458419
func pathSearch(roots []*ssa.Function, res *rta.Result, targets map[*ssa.Function]bool) (*callgraph.Node, []*callgraph.Edge) {

cmd/deadcode/gotypesalias.go

-12
This file was deleted.

cmd/eg/gotypesalias.go

-12
This file was deleted.

cmd/fiximports/main_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// No testdata on Android.
66

77
//go:build !android
8-
// +build !android
98

109
package main
1110

cmd/godex/gotypesalias.go

-12
This file was deleted.

cmd/godex/isAlias18.go

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build !go1.9
6-
// +build !go1.9
76

87
package main
98

cmd/godex/isAlias19.go

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build go1.9
6-
// +build go1.9
76

87
package main
98

cmd/godoc/gotypesalias.go

-12
This file was deleted.

cmd/goimports/goimports_gc.go

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build gc
6-
// +build gc
76

87
package main
98

cmd/goimports/goimports_not_gc.go

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build !gc
6-
// +build !gc
76

87
package main
98

cmd/goimports/gotypesalias.go

-12
This file was deleted.

cmd/gomvpkg/gotypesalias.go

-12
This file was deleted.

cmd/gotype/gotypesalias.go

-12
This file was deleted.

cmd/gotype/sizesFor18.go

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build !go1.9
6-
// +build !go1.9
76

87
// This file contains a copy of the implementation of types.SizesFor
98
// since this function is not available in go/types before Go 1.9.

cmd/gotype/sizesFor19.go

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build go1.9
6-
// +build go1.9
76

87
package main
98

cmd/signature-fuzzer/internal/fuzz-generator/wraprand.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ package generator
66

77
import (
88
"fmt"
9-
"math/rand"
9+
"math/rand/v2"
1010
"os"
1111
"runtime"
1212
"strings"
@@ -20,8 +20,7 @@ const (
2020
)
2121

2222
func NewWrapRand(seed int64, ctl int) *wraprand {
23-
rand.Seed(seed)
24-
return &wraprand{seed: seed, ctl: ctl}
23+
return &wraprand{seed: seed, ctl: ctl, rand: rand.New(rand.NewPCG(0, uint64(seed)))}
2524
}
2625

2726
type wraprand struct {
@@ -32,6 +31,7 @@ type wraprand struct {
3231
tag string
3332
calls []string
3433
ctl int
34+
rand *rand.Rand
3535
}
3636

3737
func (w *wraprand) captureCall(tag string, val string) {
@@ -59,7 +59,7 @@ func (w *wraprand) captureCall(tag string, val string) {
5959

6060
func (w *wraprand) Intn(n int64) int64 {
6161
w.intncalls++
62-
rv := rand.Int63n(n)
62+
rv := w.rand.Int64N(n)
6363
if w.ctl&RandCtlCapture != 0 {
6464
w.captureCall("Intn", fmt.Sprintf("%d", rv))
6565
}
@@ -68,7 +68,7 @@ func (w *wraprand) Intn(n int64) int64 {
6868

6969
func (w *wraprand) Float32() float32 {
7070
w.f32calls++
71-
rv := rand.Float32()
71+
rv := w.rand.Float32()
7272
if w.ctl&RandCtlCapture != 0 {
7373
w.captureCall("Float32", fmt.Sprintf("%f", rv))
7474
}
@@ -77,15 +77,15 @@ func (w *wraprand) Float32() float32 {
7777

7878
func (w *wraprand) NormFloat64() float64 {
7979
w.f64calls++
80-
rv := rand.NormFloat64()
80+
rv := w.rand.NormFloat64()
8181
if w.ctl&RandCtlCapture != 0 {
8282
w.captureCall("NormFloat64", fmt.Sprintf("%f", rv))
8383
}
8484
return rv
8585
}
8686

8787
func (w *wraprand) emitCalls(fn string) {
88-
outf, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
88+
outf, err := os.OpenFile(fn, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o666)
8989
if err != nil {
9090
panic(err)
9191
}

cmd/splitdwarf/splitdwarf.go

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd
6-
// +build aix darwin dragonfly freebsd linux netbsd openbsd
76

87
/*
98
Splitdwarf uncompresses and copies the DWARF segment of a Mach-O

cmd/ssadump/gotypesalias.go

-12
This file was deleted.

cmd/stress/stress.go

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// license that can be found in the LICENSE file.
44

55
//go:build unix || aix || darwin || dragonfly || freebsd || linux || netbsd || openbsd || solaris || windows
6-
// +build unix aix darwin dragonfly freebsd linux netbsd openbsd solaris windows
76

87
// The stress utility is intended for catching sporadic failures.
98
// It runs a given process in parallel in a loop and collects any failures.

cmd/stringer/gotypesalias.go

-12
This file was deleted.

container/intsets/sparse.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ func (s *Sparse) init() {
267267
// loop. Fail fast before this occurs.
268268
// We don't want to call panic here because it prevents the
269269
// inlining of this function.
270-
_ = (interface{}(nil)).(to_copy_a_sparse_you_must_call_its_Copy_method)
270+
_ = (any(nil)).(to_copy_a_sparse_you_must_call_its_Copy_method)
271271
}
272272
}
273273

copyright/copyright.go

+1-22
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func checkFile(toolsDir, filename string) (bool, error) {
7575
return false, err
7676
}
7777
// Don't require headers on generated files.
78-
if isGenerated(fset, parsed) {
78+
if ast.IsGenerated(parsed) {
7979
return false, nil
8080
}
8181
shouldAddCopyright := true
@@ -91,24 +91,3 @@ func checkFile(toolsDir, filename string) (bool, error) {
9191
}
9292
return shouldAddCopyright, nil
9393
}
94-
95-
// Copied from golang.org/x/tools/gopls/internal/golang/util.go.
96-
// Matches cgo generated comment as well as the proposed standard:
97-
//
98-
// https://golang.org/s/generatedcode
99-
var generatedRx = regexp.MustCompile(`// .*DO NOT EDIT\.?`)
100-
101-
func isGenerated(fset *token.FileSet, file *ast.File) bool {
102-
for _, commentGroup := range file.Comments {
103-
for _, comment := range commentGroup.List {
104-
if matched := generatedRx.MatchString(comment.Text); !matched {
105-
continue
106-
}
107-
// Check if comment is at the beginning of the line in source.
108-
if pos := fset.Position(comment.Slash); pos.Column == 1 {
109-
return true
110-
}
111-
}
112-
}
113-
return false
114-
}

0 commit comments

Comments
 (0)