diff --git a/src/archive/tar/fuzz_test.go b/src/archive/tar/fuzz_test.go index 004e52451b51d..8c34d2d8af446 100644 --- a/src/archive/tar/fuzz_test.go +++ b/src/archive/tar/fuzz_test.go @@ -31,7 +31,7 @@ func FuzzReader(f *testing.F) { } f.Add(b.Bytes()) - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> r := NewReader(bytes.NewReader(b)) type file struct { header *Header diff --git a/src/archive/tar/reader_test.go b/src/archive/tar/reader_test.go index 012c86945de48..fe89137f7b3d7 100644 --- a/src/archive/tar/reader_test.go +++ b/src/archive/tar/reader_test.go @@ -622,7 +622,7 @@ func TestReader(t *testing.T) { }} for _, v := range vectors { - t.Run(path.Base(v.file), func { t | + t.Run(path.Base(v.file), func { t -> f, err := os.Open(v.file) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -718,7 +718,7 @@ func TestPartialRead(t *testing.T) { }} for _, v := range vectors { - t.Run(path.Base(v.file), func { t | + t.Run(path.Base(v.file), func { t -> f, err := os.Open(v.file) if err != nil { t.Fatalf("Open() error: %v", err) diff --git a/src/archive/tar/tar_test.go b/src/archive/tar/tar_test.go index b618793e2f433..00859776d48d9 100644 --- a/src/archive/tar/tar_test.go +++ b/src/archive/tar/tar_test.go @@ -794,9 +794,9 @@ func Benchmark(b *testing.B) { }}, }} - b.Run("Writer", func { b | + b.Run("Writer", func { b -> for _, v := range vectors { - b.Run(v.label, func { b | + b.Run(v.label, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { // Writing to io.Discard because we want to @@ -818,7 +818,7 @@ func Benchmark(b *testing.B) { } }) - b.Run("Reader", func { b | + b.Run("Reader", func { b -> for _, v := range vectors { var buf bytes.Buffer var r bytes.Reader @@ -830,7 +830,7 @@ func Benchmark(b *testing.B) { tw.Write(file.body) } tw.Close() - b.Run(v.label, func { b | + b.Run(v.label, func { b -> b.ReportAllocs() // Read from the byte buffer. for i := 0; i < b.N; i++ { diff --git a/src/archive/tar/writer.go b/src/archive/tar/writer.go index 967e0154fb8bd..50768621e340f 100644 --- a/src/archive/tar/writer.go +++ b/src/archive/tar/writer.go @@ -409,7 +409,7 @@ func (tw *Writer) writeRawHeader(blk *block, size int64, flag byte) error { // It walks the directory tree starting at the root of the filesystem // adding each file to the tar archive while maintaining the directory structure. func (tw *Writer) AddFS(fsys fs.FS) error { - return fs.WalkDir(fsys, ".", func { name, d, err | + return fs.WalkDir(fsys, ".", func { name, d, err -> if err != nil { return err } diff --git a/src/archive/tar/writer_test.go b/src/archive/tar/writer_test.go index 301b087ec8bcf..68b2ce2e63749 100644 --- a/src/archive/tar/writer_test.go +++ b/src/archive/tar/writer_test.go @@ -482,7 +482,7 @@ func TestWriter(t *testing.T) { return x == y } for _, v := range vectors { - t.Run(path.Base(v.file), func { t | + t.Run(path.Base(v.file), func { t -> const maxSize = 10 << 10 // 10KiB buf := new(bytes.Buffer) tw := NewWriter(iotest.TruncateWriter(buf, maxSize)) @@ -837,7 +837,7 @@ func (w *failOnceWriter) Write(b []byte) (int, error) { } func TestWriterErrors(t *testing.T) { - t.Run("HeaderOnly", func { t | + t.Run("HeaderOnly", func { t -> tw := NewWriter(new(bytes.Buffer)) hdr := &Header{Name: "dir/", Typeflag: TypeDir} if err := tw.WriteHeader(hdr); err != nil { @@ -848,7 +848,7 @@ func TestWriterErrors(t *testing.T) { } }) - t.Run("NegativeSize", func { t | + t.Run("NegativeSize", func { t -> tw := NewWriter(new(bytes.Buffer)) hdr := &Header{Name: "small.txt", Size: -1} if err := tw.WriteHeader(hdr); err == nil { @@ -856,14 +856,14 @@ func TestWriterErrors(t *testing.T) { } }) - t.Run("BeforeHeader", func { t | + t.Run("BeforeHeader", func { t -> tw := NewWriter(new(bytes.Buffer)) if _, err := tw.Write([]byte("Kilts")); err != ErrWriteTooLong { t.Fatalf("Write() = %v, want %v", err, ErrWriteTooLong) } }) - t.Run("AfterClose", func { t | + t.Run("AfterClose", func { t -> tw := NewWriter(new(bytes.Buffer)) hdr := &Header{Name: "small.txt"} if err := tw.WriteHeader(hdr); err != nil { @@ -883,7 +883,7 @@ func TestWriterErrors(t *testing.T) { } }) - t.Run("PrematureFlush", func { t | + t.Run("PrematureFlush", func { t -> tw := NewWriter(new(bytes.Buffer)) hdr := &Header{Name: "small.txt", Size: 5} if err := tw.WriteHeader(hdr); err != nil { @@ -894,7 +894,7 @@ func TestWriterErrors(t *testing.T) { } }) - t.Run("PrematureClose", func { t | + t.Run("PrematureClose", func { t -> tw := NewWriter(new(bytes.Buffer)) hdr := &Header{Name: "small.txt", Size: 5} if err := tw.WriteHeader(hdr); err != nil { @@ -905,7 +905,7 @@ func TestWriterErrors(t *testing.T) { } }) - t.Run("Persistence", func { t | + t.Run("Persistence", func { t -> tw := NewWriter(new(failOnceWriter)) if err := tw.WriteHeader(&Header{}); err != io.ErrShortWrite { t.Fatalf("WriteHeader() = %v, want %v", err, io.ErrShortWrite) diff --git a/src/archive/zip/example_test.go b/src/archive/zip/example_test.go index 4f2954fc2d8e3..76c502c052728 100644 --- a/src/archive/zip/example_test.go +++ b/src/archive/zip/example_test.go @@ -85,7 +85,7 @@ func ExampleWriter_RegisterCompressor() { w := zip.NewWriter(buf) // Register a custom Deflate compressor. - w.RegisterCompressor(zip.Deflate, func { out | return flate.NewWriter(out, flate.BestCompression) }) + w.RegisterCompressor(zip.Deflate, func { out -> return flate.NewWriter(out, flate.BestCompression) }) // Proceed to add files to w. } diff --git a/src/archive/zip/fuzz_test.go b/src/archive/zip/fuzz_test.go index a1db69940a9d8..d515ac376bb75 100644 --- a/src/archive/zip/fuzz_test.go +++ b/src/archive/zip/fuzz_test.go @@ -28,7 +28,7 @@ func FuzzReader(f *testing.F) { f.Add(b) } - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> r, err := NewReader(bytes.NewReader(b), int64(len(b))) if err != nil { return diff --git a/src/archive/zip/reader.go b/src/archive/zip/reader.go index 7a881eb21aba0..debfa006bd785 100644 --- a/src/archive/zip/reader.go +++ b/src/archive/zip/reader.go @@ -862,7 +862,7 @@ func (r *Reader) initFileList() { } } - slices.SortFunc(r.fileList, func { a, b | return fileEntryCompare(a.name, b.name) }) + slices.SortFunc(r.fileList, func { a, b -> return fileEntryCompare(a.name, b.name) }) }) } @@ -941,7 +941,7 @@ func (r *Reader) openLookup(name string) *fileListEntry { func (r *Reader) openReadDir(dir string) []fileListEntry { files := r.fileList - i, _ := slices.BinarySearchFunc(files, dir, func { a, dir | + i, _ := slices.BinarySearchFunc(files, dir, func { a, dir -> idir, _, _ := split(a.name) if dir != idir { return strings.Compare(idir, dir) @@ -949,7 +949,7 @@ func (r *Reader) openReadDir(dir string) []fileListEntry { // find the first entry with dir return +1 }) - j, _ := slices.BinarySearchFunc(files, dir, func { a, dir | + j, _ := slices.BinarySearchFunc(files, dir, func { a, dir -> jdir, _, _ := split(a.name) if dir != jdir { return strings.Compare(jdir, dir) diff --git a/src/archive/zip/reader_test.go b/src/archive/zip/reader_test.go index c327cef8c5933..601891d24f377 100644 --- a/src/archive/zip/reader_test.go +++ b/src/archive/zip/reader_test.go @@ -582,7 +582,7 @@ var tests = []ZipTest{ func TestReader(t *testing.T) { for _, zt := range tests { - t.Run(zt.Name, func { t | readTestZip(t, zt) }) + t.Run(zt.Name, func { t -> readTestZip(t, zt) }) } } @@ -820,13 +820,13 @@ func messWith(fileName string, corrupter func(b []byte)) (r io.ReaderAt, size in } func returnCorruptCRC32Zip() (r io.ReaderAt, size int64) { - return messWith("go-with-datadesc-sig.zip", func { b | + return messWith("go-with-datadesc-sig.zip", func { b -> // Corrupt one of the CRC32s in the data descriptor: b[0x2d]++ }) } func returnCorruptNotStreamedZip() (r io.ReaderAt, size int64) { - return messWith("crc32-not-streamed.zip", func { b | + return messWith("crc32-not-streamed.zip", func { b -> // Corrupt foo.txt's final crc32 byte, in both // the file header and TOC. (0x7e -> 0x7f) b[0x11]++ @@ -1210,7 +1210,7 @@ func TestFS(t *testing.T) { }, } { test := test - t.Run(test.file, func { t | + t.Run(test.file, func { t -> t.Parallel() z, err := OpenReader(test.file) if err != nil { @@ -1244,7 +1244,7 @@ func TestFSWalk(t *testing.T) { }, } { test := test - t.Run(test.file, func { t | + t.Run(test.file, func { t -> t.Parallel() z, err := OpenReader(test.file) if err != nil { @@ -1252,7 +1252,7 @@ func TestFSWalk(t *testing.T) { } var files []string sawErr := false - err = fs.WalkDir(z, ".", func { path, d, err | + err = fs.WalkDir(z, ".", func { path, d, err -> if err != nil { if !test.wantErr { t.Errorf("%s: %v", path, err) @@ -1619,7 +1619,7 @@ func TestUnderSize(t *testing.T) { } for _, f := range z.File { - t.Run(f.Name, func { t | + t.Run(f.Name, func { t -> rd, err := f.Open() if err != nil { t.Fatal(err) @@ -1646,7 +1646,7 @@ func TestIssue54801(t *testing.T) { // Make file a directory f.Name += "/" - t.Run(f.Name, func { t | + t.Run(f.Name, func { t -> t.Logf("CompressedSize64: %d, Flags: %#x", f.CompressedSize64, f.Flags) rd, err := f.Open() diff --git a/src/archive/zip/register.go b/src/archive/zip/register.go index 766fa93e0f112..12b2b701d519a 100644 --- a/src/archive/zip/register.go +++ b/src/archive/zip/register.go @@ -107,8 +107,8 @@ var ( ) func init() { - compressors.Store(Store, Compressor(func { w | return &nopCloser{w}, nil })) - compressors.Store(Deflate, Compressor(func { w | return newFlateWriter(w), nil })) + compressors.Store(Store, Compressor(func { w -> return &nopCloser{w}, nil })) + compressors.Store(Deflate, Compressor(func { w -> return newFlateWriter(w), nil })) decompressors.Store(Store, Decompressor(io.NopCloser)) decompressors.Store(Deflate, Decompressor(newFlateReader)) diff --git a/src/archive/zip/writer.go b/src/archive/zip/writer.go index b3b291c11e062..c3c2ce02be730 100644 --- a/src/archive/zip/writer.go +++ b/src/archive/zip/writer.go @@ -501,7 +501,7 @@ func (w *Writer) RegisterCompressor(method uint16, comp Compressor) { // It walks the directory tree starting at the root of the filesystem // adding each file to the zip using deflate while maintaining the directory structure. func (w *Writer) AddFS(fsys fs.FS) error { - return fs.WalkDir(fsys, ".", func { name, d, err | + return fs.WalkDir(fsys, ".", func { name, d, err -> if err != nil { return err } diff --git a/src/archive/zip/writer_test.go b/src/archive/zip/writer_test.go index 8ee8fb2b4ec36..4d71971b232a4 100644 --- a/src/archive/zip/writer_test.go +++ b/src/archive/zip/writer_test.go @@ -596,7 +596,7 @@ func BenchmarkCompressedZipGarbage(b *testing.B) { runOnce(&bytes.Buffer{}) b.ResetTimer() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var buf bytes.Buffer for pb.Next() { runOnce(&buf) diff --git a/src/archive/zip/zip_test.go b/src/archive/zip/zip_test.go index 11c524b8a2875..6eba00ca1882c 100644 --- a/src/archive/zip/zip_test.go +++ b/src/archive/zip/zip_test.go @@ -215,7 +215,7 @@ func (r *rleBuffer) ReadAt(p []byte, off int64) (n int, err error) { if len(p) == 0 { return } - skipParts, _ := slices.BinarySearchFunc(r.buf, off, func { rb, off | return cmp.Compare(rb.off+rb.n, off) }) + skipParts, _ := slices.BinarySearchFunc(r.buf, off, func { rb, off -> return cmp.Compare(rb.off+rb.n, off) }) parts := r.buf[skipParts:] if len(parts) > 0 { skipBytes := off - parts[0].off @@ -305,7 +305,7 @@ func TestZip64DirectoryOffset(t *testing.T) { const filename = "huge.txt" gen := func(wantOff uint64) func(*Writer) { return func(w *Writer) { - w.testHookCloseSizeOffset = func { size, off | + w.testHookCloseSizeOffset = func { size, off -> if off != wantOff { t.Errorf("central directory offset = %d (%x); want %d", off, off, wantOff) } @@ -327,13 +327,13 @@ func TestZip64DirectoryOffset(t *testing.T) { } } } - t.Run("uint32max-2_NoZip64", func { t | + t.Run("uint32max-2_NoZip64", func { t -> t.Parallel() if generatesZip64(t, gen(0xfffffffe)) { t.Error("unexpected zip64") } }) - t.Run("uint32max-1_Zip64", func { t | + t.Run("uint32max-1_Zip64", func { t -> t.Parallel() if !generatesZip64(t, gen(0xffffffff)) { t.Error("expected zip64") @@ -364,14 +364,14 @@ func TestZip64ManyRecords(t *testing.T) { } } // 16k-1 records shouldn't make a zip64: - t.Run("uint16max-1_NoZip64", func { t | + t.Run("uint16max-1_NoZip64", func { t -> t.Parallel() if generatesZip64(t, gen(0xfffe)) { t.Error("unexpected zip64") } }) // 16k records should make a zip64: - t.Run("uint16max_Zip64", func { t | + t.Run("uint16max_Zip64", func { t -> t.Parallel() if !generatesZip64(t, gen(0xffff)) { t.Error("expected zip64") @@ -503,7 +503,7 @@ func TestZip64LargeDirectory(t *testing.T) { // of central directory. gen := func(wantLen int64) func(*Writer) { return func(w *Writer) { - w.testHookCloseSizeOffset = func { size, off | + w.testHookCloseSizeOffset = func { size, off -> if size != uint64(wantLen) { t.Errorf("Close central directory size = %d; want %d", size, wantLen) } @@ -534,13 +534,13 @@ func TestZip64LargeDirectory(t *testing.T) { } } } - t.Run("uint32max-1_NoZip64", func { t | + t.Run("uint32max-1_NoZip64", func { t -> t.Parallel() if generatesZip64(t, gen(uint32max-1)) { t.Error("unexpected zip64") } }) - t.Run("uint32max_HasZip64", func { t | + t.Run("uint32max_HasZip64", func { t -> t.Parallel() if !generatesZip64(t, gen(uint32max)) { t.Error("expected zip64") @@ -764,7 +764,7 @@ func BenchmarkZip64Test(b *testing.B) { func BenchmarkZip64TestSizes(b *testing.B) { for _, size := range []int64{1 << 12, 1 << 20, 1 << 26} { - b.Run(fmt.Sprint(size), func { b | b.RunParallel(func { pb | for pb.Next() { + b.Run(fmt.Sprint(size), func { b -> b.RunParallel(func { pb -> for pb.Next() { testZip64(b, size) } }) }) } diff --git a/src/bufio/bufio_test.go b/src/bufio/bufio_test.go index e932726049b2f..dc3c1f23380e1 100644 --- a/src/bufio/bufio_test.go +++ b/src/bufio/bufio_test.go @@ -1462,7 +1462,7 @@ func TestWriterReadFromWithBufferedData(t *testing.T) { func TestReadZero(t *testing.T) { for _, size := range []int{100, 2} { - t.Run(fmt.Sprintf("bufsize=%d", size), func { t | + t.Run(fmt.Sprintf("bufsize=%d", size), func { t -> r := io.MultiReader(strings.NewReader("abc"), &emptyThenNonEmptyReader{r: strings.NewReader("def"), n: 1}) br := NewReaderSize(r, size) want := func(s string, wantErr error) { diff --git a/src/bytes/buffer_test.go b/src/bytes/buffer_test.go index f6584bf8fa6f1..29ecdbef70acc 100644 --- a/src/bytes/buffer_test.go +++ b/src/bytes/buffer_test.go @@ -721,7 +721,7 @@ func BenchmarkBufferFullSmallReads(b *testing.B) { func BenchmarkBufferWriteBlock(b *testing.B) { block := make([]byte, 1024) for _, n := range []int{1 << 12, 1 << 16, 1 << 20} { - b.Run(fmt.Sprintf("N%d", n), func { b | + b.Run(fmt.Sprintf("N%d", n), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { var bb Buffer diff --git a/src/bytes/bytes.go b/src/bytes/bytes.go index f8d74fcc3ce3e..736dd0b931f5e 100644 --- a/src/bytes/bytes.go +++ b/src/bytes/bytes.go @@ -780,7 +780,7 @@ func Title(s []byte) []byte { // the closure once per rune. prev := ' ' return Map( - func { r | + func { r -> if isSeparator(prev) { prev = r return unicode.ToTitle(r) diff --git a/src/bytes/bytes_test.go b/src/bytes/bytes_test.go index 5ecee17e9e42a..e67ba6f73aaf0 100644 --- a/src/bytes/bytes_test.go +++ b/src/bytes/bytes_test.go @@ -541,7 +541,7 @@ func benchBytes(b *testing.B, sizes []int, f func(b *testing.B, n int)) { if isRaceBuilder && n > 4<<10 { continue } - b.Run(valName(n), func { b | + b.Run(valName(n), func { b -> if len(bmbuf) < n { bmbuf = make([]byte, n) } @@ -616,7 +616,7 @@ func bmIndexRune(index func([]byte, rune) int) func(b *testing.B, n int) { } func BenchmarkEqual(b *testing.B) { - b.Run("0", func { b | + b.Run("0", func { b -> var buf [4]byte buf1 := buf[0:0] buf2 := buf[1:1] @@ -630,7 +630,7 @@ func BenchmarkEqual(b *testing.B) { sizes := []int{1, 6, 9, 15, 16, 20, 32, 4 << 10, 4 << 20, 64 << 20} - b.Run("same", func { b | benchBytes(b, sizes, bmEqual(func { a, b | return Equal(a, a) })) }) + b.Run("same", func { b -> benchBytes(b, sizes, bmEqual(func { a, b -> return Equal(a, a) })) }) benchBytes(b, sizes, bmEqual(Equal)) } @@ -672,7 +672,7 @@ func BenchmarkEqualBothUnaligned(b *testing.B) { buf2 := bmbuf[buf2Start : buf2Start+n] buf1[n-1] = 'x' buf2[n-1] = 'x' - b.Run(fmt.Sprint(n, off), func { b | + b.Run(fmt.Sprint(n, off), func { b -> b.SetBytes(int64(n)) for i := 0; i < b.N; i++ { eq := Equal(buf1, buf2) @@ -688,7 +688,7 @@ func BenchmarkEqualBothUnaligned(b *testing.B) { } func BenchmarkIndex(b *testing.B) { - benchBytes(b, indexSizes, func { b, n | + benchBytes(b, indexSizes, func { b, n -> buf := bmbuf[0:n] buf[n-1] = 'x' for i := 0; i < b.N; i++ { @@ -702,7 +702,7 @@ func BenchmarkIndex(b *testing.B) { } func BenchmarkIndexEasy(b *testing.B) { - benchBytes(b, indexSizes, func { b, n | + benchBytes(b, indexSizes, func { b, n -> buf := bmbuf[0:n] buf[n-1] = 'x' buf[n-7] = 'x' @@ -718,7 +718,7 @@ func BenchmarkIndexEasy(b *testing.B) { } func BenchmarkCount(b *testing.B) { - benchBytes(b, indexSizes, func { b, n | + benchBytes(b, indexSizes, func { b, n -> buf := bmbuf[0:n] buf[n-1] = 'x' for i := 0; i < b.N; i++ { @@ -732,7 +732,7 @@ func BenchmarkCount(b *testing.B) { } func BenchmarkCountEasy(b *testing.B) { - benchBytes(b, indexSizes, func { b, n | + benchBytes(b, indexSizes, func { b, n -> buf := bmbuf[0:n] buf[n-1] = 'x' buf[n-7] = 'x' @@ -748,7 +748,7 @@ func BenchmarkCountEasy(b *testing.B) { } func BenchmarkCountSingle(b *testing.B) { - benchBytes(b, indexSizes, func { b, n | + benchBytes(b, indexSizes, func { b, n -> buf := bmbuf[0:n] step := 8 for i := 0; i < len(buf); i += step { @@ -1132,7 +1132,7 @@ func TestToLower(t *testing.T) { runStringTests(t, ToLower, "ToLower", lowerTest func BenchmarkToUpper(b *testing.B) { for _, tc := range upperTests { tin := []byte(tc.in) - b.Run(tc.in, func { b | + b.Run(tc.in, func { b -> for i := 0; i < b.N; i++ { actual := ToUpper(tin) if !Equal(actual, tc.out) { @@ -1146,7 +1146,7 @@ func BenchmarkToUpper(b *testing.B) { func BenchmarkToLower(b *testing.B) { for _, tc := range lowerTests { tin := []byte(tc.in) - b.Run(tc.in, func { b | + b.Run(tc.in, func { b -> for i := 0; i < b.N; i++ { actual := ToLower(tin) if !Equal(actual, tc.out) { @@ -1899,7 +1899,7 @@ func TestContainsRune(t *testing.T) { func TestContainsFunc(t *testing.T) { for _, ct := range ContainsRuneTests { - if ContainsFunc(ct.b, func { r | return ct.r == r }) != ct.expected { + if ContainsFunc(ct.b, func { r -> return ct.r == r }) != ct.expected { t.Errorf("ContainsFunc(%q, func(%q)) = %v, want %v", ct.b, ct.r, !ct.expected, ct.expected) } @@ -1949,9 +1949,9 @@ var bytesdata = []struct { func BenchmarkFields(b *testing.B) { for _, sd := range bytesdata { - b.Run(sd.name, func { b | + b.Run(sd.name, func { b -> for j := 1 << 4; j <= 1<<20; j <<= 4 { - b.Run(fmt.Sprintf("%d", j), func { b | + b.Run(fmt.Sprintf("%d", j), func { b -> b.ReportAllocs() b.SetBytes(int64(j)) data := sd.data[:j] @@ -1966,9 +1966,9 @@ func BenchmarkFields(b *testing.B) { func BenchmarkFieldsFunc(b *testing.B) { for _, sd := range bytesdata { - b.Run(sd.name, func { b | + b.Run(sd.name, func { b -> for j := 1 << 4; j <= 1<<20; j <<= 4 { - b.Run(fmt.Sprintf("%d", j), func { b | + b.Run(fmt.Sprintf("%d", j), func { b -> b.ReportAllocs() b.SetBytes(int64(j)) data := sd.data[:j] @@ -1992,7 +1992,7 @@ func BenchmarkTrimSpace(b *testing.B) { {"JustNonASCII", []byte("\u2000\u2000\u2000☺☺☺☺\u3000\u3000\u3000")}, } for _, test := range tests { - b.Run(test.name, func { b | for i := 0; i < b.N; i++ { + b.Run(test.name, func { b -> for i := 0; i < b.N; i++ { TrimSpace(test.input) } }) } @@ -2010,7 +2010,7 @@ func BenchmarkToValidUTF8(b *testing.B) { replacement := []byte("\uFFFD") b.ResetTimer() for _, test := range tests { - b.Run(test.name, func { b | for i := 0; i < b.N; i++ { + b.Run(test.name, func { b -> for i := 0; i < b.N; i++ { ToValidUTF8(test.input, replacement) } }) } @@ -2117,7 +2117,7 @@ func BenchmarkRepeatLarge(b *testing.B) { if n == 0 { continue } - b.Run(fmt.Sprintf("%d/%d", 1< for i := 0; i < b.N; i++ { Repeat(s, n) } @@ -2129,7 +2129,7 @@ func BenchmarkRepeatLarge(b *testing.B) { func BenchmarkBytesCompare(b *testing.B) { for n := 1; n <= 2048; n <<= 1 { - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> var x = make([]byte, n) var y = make([]byte, n) @@ -2154,7 +2154,7 @@ func BenchmarkIndexAnyASCII(b *testing.B) { cs := "0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz" for k := 1; k <= 2048; k <<= 4 { for j := 1; j <= 64; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> for i := 0; i < b.N; i++ { IndexAny(x[:k], cs[:j]) } }) } @@ -2166,7 +2166,7 @@ func BenchmarkIndexAnyUTF8(b *testing.B) { cs := "你好世界, hello world. 你好世界, hello world. 你好世界, hello world." for k := 1; k <= 2048; k <<= 4 { for j := 1; j <= 64; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> for i := 0; i < b.N; i++ { IndexAny(x[:k], cs[:j]) } }) } @@ -2178,7 +2178,7 @@ func BenchmarkLastIndexAnyASCII(b *testing.B) { cs := "0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz" for k := 1; k <= 2048; k <<= 4 { for j := 1; j <= 64; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> for i := 0; i < b.N; i++ { LastIndexAny(x[:k], cs[:j]) } }) } @@ -2190,7 +2190,7 @@ func BenchmarkLastIndexAnyUTF8(b *testing.B) { cs := "你好世界, hello world. 你好世界, hello world. 你好世界, hello world." for k := 1; k <= 2048; k <<= 4 { for j := 1; j <= 64; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> for i := 0; i < b.N; i++ { LastIndexAny(x[:k], cs[:j]) } }) } @@ -2201,7 +2201,7 @@ func BenchmarkTrimASCII(b *testing.B) { cs := "0123456789abcdef" for k := 1; k <= 4096; k <<= 4 { for j := 1; j <= 16; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> x := Repeat([]byte(cs[:j]), k) // Always matches set for i := 0; i < b.N; i++ { Trim(x[:k], cs[:j]) @@ -2221,7 +2221,7 @@ func BenchmarkTrimByte(b *testing.B) { func BenchmarkIndexPeriodic(b *testing.B) { key := []byte{1, 1} for _, skip := range [...]int{2, 4, 8, 16, 32, 64} { - b.Run(fmt.Sprintf("IndexPeriodic%d", skip), func { b | + b.Run(fmt.Sprintf("IndexPeriodic%d", skip), func { b -> buf := make([]byte, 1<<16) for i := 0; i < len(buf); i += skip { buf[i] = 1 diff --git a/src/bytes/compare_test.go b/src/bytes/compare_test.go index fe62c30a90767..593378eb4bb00 100644 --- a/src/bytes/compare_test.go +++ b/src/bytes/compare_test.go @@ -231,7 +231,7 @@ func benchmarkCompareBytesBigUnaligned(b *testing.B, offset int) { func BenchmarkCompareBytesBigUnaligned(b *testing.B) { for i := 1; i < 8; i++ { - b.Run(fmt.Sprintf("offset=%d", i), func { b | benchmarkCompareBytesBigUnaligned(b, i) }) + b.Run(fmt.Sprintf("offset=%d", i), func { b -> benchmarkCompareBytesBigUnaligned(b, i) }) } } @@ -255,7 +255,7 @@ func benchmarkCompareBytesBigBothUnaligned(b *testing.B, offset int) { func BenchmarkCompareBytesBigBothUnaligned(b *testing.B) { for i := 0; i < 8; i++ { - b.Run(fmt.Sprintf("offset=%d", i), func { b | benchmarkCompareBytesBigBothUnaligned(b, i) }) + b.Run(fmt.Sprintf("offset=%d", i), func { b -> benchmarkCompareBytesBigBothUnaligned(b, i) }) } } diff --git a/src/cmd/api/main_test.go b/src/cmd/api/main_test.go index adcfe9ebb2c3f..8519a322be462 100644 --- a/src/cmd/api/main_test.go +++ b/src/cmd/api/main_test.go @@ -1171,7 +1171,7 @@ func (w *Walker) collectDeprecated() { } } for _, file := range w.current.Files { - ast.Inspect(file, func { n | + ast.Inspect(file, func { n -> switch n := n.(type) { case *ast.File: if isDeprecated(n.Doc) { diff --git a/src/cmd/asm/internal/asm/endtoend_test.go b/src/cmd/asm/internal/asm/endtoend_test.go index dd3a68511593a..ce3c8dbfe3bce 100644 --- a/src/cmd/asm/internal/asm/endtoend_test.go +++ b/src/cmd/asm/internal/asm/endtoend_test.go @@ -38,7 +38,7 @@ func testEndToEnd(t *testing.T, goarch, file string) { ctxt.IsAsm = true defer ctxt.Bso.Flush() failed := false - ctxt.DiagFunc = func { format, args | + ctxt.DiagFunc = func { format, args -> failed = true t.Errorf(format, args...) } @@ -193,7 +193,7 @@ Diff: top := pList.Firstpc var text *obj.LSym ok = true - ctxt.DiagFunc = func { format, args | + ctxt.DiagFunc = func { format, args -> t.Errorf(format, args...) ok = false } @@ -294,7 +294,7 @@ func testErrors(t *testing.T, goarch, file string, flags ...string) { failed := false var errBuf bytes.Buffer parser.errorWriter = &errBuf - ctxt.DiagFunc = func { format, args | + ctxt.DiagFunc = func { format, args -> failed = true s := fmt.Sprintf(format, args...) if !strings.HasSuffix(s, "\n") { diff --git a/src/cmd/asm/internal/asm/operand_test.go b/src/cmd/asm/internal/asm/operand_test.go index f9e2b7c44c746..0a30ff9ffe4ec 100644 --- a/src/cmd/asm/internal/asm/operand_test.go +++ b/src/cmd/asm/internal/asm/operand_test.go @@ -153,7 +153,7 @@ func TestFuncAddress(t *testing.T) { {"loong64", loong64OperandTests}, {"s390x", s390xOperandTests}, } { - t.Run(sub.arch, func { t | + t.Run(sub.arch, func { t -> parser := newParser(sub.arch) for _, test := range sub.tests { parser.start(lex.Tokenize(test.input)) diff --git a/src/cmd/asm/main.go b/src/cmd/asm/main.go index 5fb82e65f1100..e484327f7177b 100644 --- a/src/cmd/asm/main.go +++ b/src/cmd/asm/main.go @@ -92,7 +92,7 @@ func main() { for _, f := range flag.Args() { lexer := lex.NewLexer(f) parser := asm.NewParser(ctxt, architecture, lexer) - ctxt.DiagFunc = func { format, args | + ctxt.DiagFunc = func { format, args -> diag = true log.Printf(format, args...) } diff --git a/src/cmd/cgo/gcc.go b/src/cmd/cgo/gcc.go index 5faae3d3aad26..5ed56252f4285 100644 --- a/src/cmd/cgo/gcc.go +++ b/src/cmd/cgo/gcc.go @@ -1131,7 +1131,7 @@ func (p *Package) hasPointer(f *File, t ast.Expr, top bool) bool { // If addPosition is true, add position info to the idents of C names in arg. func (p *Package) mangle(f *File, arg *ast.Expr, addPosition bool) (ast.Expr, bool) { needsUnsafe := false - f.walk(arg, ctxExpr, func { f, arg, context | + f.walk(arg, ctxExpr, func { f, arg, context -> px, ok := arg.(*ast.Expr) if !ok { return @@ -1574,7 +1574,7 @@ func (p *Package) rewriteRef(f *File) { func (p *Package) rewriteName(f *File, r *Ref, addPosition bool) ast.Expr { getNewIdent := ast.NewIdent if addPosition { - getNewIdent = func { newName | + getNewIdent = func { newName -> mangledIdent := ast.NewIdent(newName) if len(newName) == len(r.Name.Go) { return mangledIdent @@ -1959,7 +1959,7 @@ func (p *Package) gccDebug(stdin []byte, nnames int) (d *dwarf.Data, ints []int6 // tag. Remove it so that // we can find the associated // data. - removeTag = func { v | return v &^ (0xff << (64 - 8)) } + removeTag = func { v -> return v &^ (0xff << (64 - 8)) } break } } diff --git a/src/cmd/cgo/internal/cgotest/overlaydir.go b/src/cmd/cgo/internal/cgotest/overlaydir.go index 7e261aeb4a917..00da8362bf497 100644 --- a/src/cmd/cgo/internal/cgotest/overlaydir.go +++ b/src/cmd/cgo/internal/cgotest/overlaydir.go @@ -23,7 +23,7 @@ func OverlayDir(dstRoot, srcRoot string) error { return err } - return filepath.Walk(srcRoot, func { srcPath, info, err | + return filepath.Walk(srcRoot, func { srcPath, info, err -> if err != nil || srcPath == srcRoot { return err } diff --git a/src/cmd/cgo/internal/swig/swig_test.go b/src/cmd/cgo/internal/swig/swig_test.go index 515d7e3a35133..f9d56bf8e7d08 100644 --- a/src/cmd/cgo/internal/swig/swig_test.go +++ b/src/cmd/cgo/internal/swig/swig_test.go @@ -28,7 +28,7 @@ func TestCall(t *testing.T) { mustHaveSwig(t) mustHaveCxx(t) run(t, "testdata/callback", false, "Call") - t.Run("lto", func { t | run(t, "testdata/callback", true, "Call") }) + t.Run("lto", func { t -> run(t, "testdata/callback", true, "Call") }) } func TestCallback(t *testing.T) { @@ -36,7 +36,7 @@ func TestCallback(t *testing.T) { mustHaveSwig(t) mustHaveCxx(t) run(t, "testdata/callback", false, "Callback") - t.Run("lto", func { t | run(t, "testdata/callback", true, "Callback") }) + t.Run("lto", func { t -> run(t, "testdata/callback", true, "Callback") }) } func run(t *testing.T, dir string, lto bool, args ...string) { diff --git a/src/cmd/cgo/internal/test/callback.go b/src/cmd/cgo/internal/test/callback.go index d43f74fc6f823..b71c20bd9863c 100644 --- a/src/cmd/cgo/internal/test/callback.go +++ b/src/cmd/cgo/internal/test/callback.go @@ -266,7 +266,7 @@ func testReturnAfterGrowFromGo(t *testing.T) { func goReturnVal() (r C.int) { // Force a stack copy. var f func(int) int - f = func { i | + f = func { i -> var buf [256]byte use(buf[:]) if i == 0 { diff --git a/src/cmd/cgo/internal/test/test.go b/src/cmd/cgo/internal/test/test.go index 2a75327aa265e..9d4e9763aa40b 100644 --- a/src/cmd/cgo/internal/test/test.go +++ b/src/cmd/cgo/internal/test/test.go @@ -1119,7 +1119,7 @@ type Context struct { } func benchCgoCall(b *testing.B) { - b.Run("add-int", func { b | + b.Run("add-int", func { b -> const x = C.int(2) const y = C.int(3) @@ -1128,43 +1128,43 @@ func benchCgoCall(b *testing.B) { } }) - b.Run("one-pointer", func { b | + b.Run("one-pointer", func { b -> var a0 C.VkDeviceCreateInfo for i := 0; i < b.N; i++ { C.handleComplexPointer(&a0) } }) - b.Run("string-pointer-escape", func { b | + b.Run("string-pointer-escape", func { b -> for i := 0; i < b.N; i++ { var s string C.handleGoStringPointerEscape(unsafe.Pointer(&s)) } }) - b.Run("string-pointer-noescape", func { b | + b.Run("string-pointer-noescape", func { b -> for i := 0; i < b.N; i++ { var s string C.handleGoStringPointerNoescape(unsafe.Pointer(&s)) } }) - b.Run("eight-pointers", func { b | + b.Run("eight-pointers", func { b -> var a0, a1, a2, a3, a4, a5, a6, a7 C.VkDeviceCreateInfo for i := 0; i < b.N; i++ { C.handleComplexPointer8(&a0, &a1, &a2, &a3, &a4, &a5, &a6, &a7) } }) - b.Run("eight-pointers-nil", func { b | + b.Run("eight-pointers-nil", func { b -> var a0, a1, a2, a3, a4, a5, a6, a7 *C.VkDeviceCreateInfo for i := 0; i < b.N; i++ { C.handleComplexPointer8(a0, a1, a2, a3, a4, a5, a6, a7) } }) - b.Run("eight-pointers-array", func { b | + b.Run("eight-pointers-array", func { b -> var a [8]C.VkDeviceCreateInfo for i := 0; i < b.N; i++ { C.handleComplexPointer8(&a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7]) } }) - b.Run("eight-pointers-slice", func { b | + b.Run("eight-pointers-slice", func { b -> a := make([]C.VkDeviceCreateInfo, 8) for i := 0; i < b.N; i++ { C.handleComplexPointer8(&a[0], &a[1], &a[2], &a[3], &a[4], &a[5], &a[6], &a[7]) diff --git a/src/cmd/cgo/internal/testcarchive/carchive_test.go b/src/cmd/cgo/internal/testcarchive/carchive_test.go index c91eef227b975..e1e3bf7db4690 100644 --- a/src/cmd/cgo/internal/testcarchive/carchive_test.go +++ b/src/cmd/cgo/internal/testcarchive/carchive_test.go @@ -59,12 +59,12 @@ func TestMain(m *testing.M) { func testMain(m *testing.M) int { if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" { - globalSkip = func { t | t.Skip("short mode and $GO_BUILDER_NAME not set") } + globalSkip = func { t -> t.Skip("short mode and $GO_BUILDER_NAME not set") } return m.Run() } if runtime.GOOS == "linux" { if _, err := os.Stat("/etc/alpine-release"); err == nil { - globalSkip = func { t | t.Skip("skipping failing test on alpine - go.dev/issue/19938") } + globalSkip = func { t -> t.Skip("skipping failing test on alpine - go.dev/issue/19938") } return m.Run() } } diff --git a/src/cmd/cgo/internal/testcshared/cshared_test.go b/src/cmd/cgo/internal/testcshared/cshared_test.go index f435c271b57ee..b869bea6993ec 100644 --- a/src/cmd/cgo/internal/testcshared/cshared_test.go +++ b/src/cmd/cgo/internal/testcshared/cshared_test.go @@ -45,18 +45,18 @@ func testMain(m *testing.M) int { log.SetFlags(log.Lshortfile) flag.Parse() if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" { - globalSkip = func { t | t.Skip("short mode and $GO_BUILDER_NAME not set") } + globalSkip = func { t -> t.Skip("short mode and $GO_BUILDER_NAME not set") } return m.Run() } if runtime.GOOS == "linux" { if _, err := os.Stat("/etc/alpine-release"); err == nil { - globalSkip = func { t | t.Skip("skipping failing test on alpine - go.dev/issue/19938") } + globalSkip = func { t -> t.Skip("skipping failing test on alpine - go.dev/issue/19938") } return m.Run() } } if !testenv.HasGoBuild() { // Checking for "go build" is a proxy for whether or not we can run "go env". - globalSkip = func { t | t.Skip("no go build") } + globalSkip = func { t -> t.Skip("no go build") } return m.Run() } @@ -467,8 +467,8 @@ func TestNumberOfExportedFunctions(t *testing.T) { t.Parallel() - t.Run("OnlyExported", func { t | checkNumberOfExportedFunctionsWindows(t, false) }) - t.Run("All", func { t | checkNumberOfExportedFunctionsWindows(t, true) }) + t.Run("OnlyExported", func { t -> checkNumberOfExportedFunctionsWindows(t, false) }) + t.Run("All", func { t -> checkNumberOfExportedFunctionsWindows(t, true) }) } // test1: shared library can be dynamically loaded and exported symbols are accessible. diff --git a/src/cmd/cgo/internal/testerrors/errors_test.go b/src/cmd/cgo/internal/testerrors/errors_test.go index bdea45e90dcd6..f5330c712af78 100644 --- a/src/cmd/cgo/internal/testerrors/errors_test.go +++ b/src/cmd/cgo/internal/testerrors/errors_test.go @@ -22,7 +22,7 @@ func path(file string) string { } func check(t *testing.T, file string) { - t.Run(file, func { t | + t.Run(file, func { t -> testenv.MustHaveGoBuild(t) testenv.MustHaveCGO(t) t.Parallel() @@ -148,7 +148,7 @@ func TestToleratesOptimizationFlag(t *testing.T) { "-O", } { cflags := cflags - t.Run(cflags, func { t | + t.Run(cflags, func { t -> testenv.MustHaveGoBuild(t) testenv.MustHaveCGO(t) t.Parallel() diff --git a/src/cmd/cgo/internal/testerrors/ptr_test.go b/src/cmd/cgo/internal/testerrors/ptr_test.go index b112395b6dead..7133ef70f646b 100644 --- a/src/cmd/cgo/internal/testerrors/ptr_test.go +++ b/src/cmd/cgo/internal/testerrors/ptr_test.go @@ -503,7 +503,7 @@ func TestPointerChecks(t *testing.T) { var pending int32 for _, pt := range ptrTests { pt := pt - t.Run(pt.name, func { t | + t.Run(pt.name, func { t -> atomic.AddInt32(&pending, +1) defer func() { if atomic.AddInt32(&pending, -1) == 0 { diff --git a/src/cmd/cgo/internal/testplugin/plugin_test.go b/src/cmd/cgo/internal/testplugin/plugin_test.go index 568e88cbccfb8..3f9da5a3e4c97 100644 --- a/src/cmd/cgo/internal/testplugin/plugin_test.go +++ b/src/cmd/cgo/internal/testplugin/plugin_test.go @@ -47,15 +47,15 @@ func prettyPrintf(format string, args ...interface{}) { func testMain(m *testing.M) int { if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" { - globalSkip = func { t | t.Skip("short mode and $GO_BUILDER_NAME not set") } + globalSkip = func { t -> t.Skip("short mode and $GO_BUILDER_NAME not set") } return m.Run() } if !platform.BuildModeSupported(runtime.Compiler, "plugin", runtime.GOOS, runtime.GOARCH) { - globalSkip = func { t | t.Skip("plugin build mode not supported") } + globalSkip = func { t -> t.Skip("plugin build mode not supported") } return m.Run() } if !testenv.HasCGO() { - globalSkip = func { t | t.Skip("cgo not supported") } + globalSkip = func { t -> t.Skip("cgo not supported") } return m.Run() } @@ -304,7 +304,7 @@ func TestIssue25756(t *testing.T) { goCmd(t, "build", "-o", "issue25756.exe", "./issue25756/main.go") // Fails intermittently, but 20 runs should cause the failure for n := 20; n > 0; n-- { - t.Run(fmt.Sprint(n), func { t | + t.Run(fmt.Sprint(n), func { t -> t.Parallel() run(t, "./issue25756.exe") }) diff --git a/src/cmd/cgo/internal/testsanitizers/asan_test.go b/src/cmd/cgo/internal/testsanitizers/asan_test.go index e7fb88a08d9f1..9b21e610c774a 100644 --- a/src/cmd/cgo/internal/testsanitizers/asan_test.go +++ b/src/cmd/cgo/internal/testsanitizers/asan_test.go @@ -70,7 +70,7 @@ func TestASAN(t *testing.T) { for _, tc := range cases { tc := tc name := strings.TrimSuffix(tc.src, ".go") - t.Run(name, func { t | + t.Run(name, func { t -> t.Parallel() dir := newTempDir(t) diff --git a/src/cmd/cgo/internal/testsanitizers/cshared_test.go b/src/cmd/cgo/internal/testsanitizers/cshared_test.go index 877aa6ff7c4c6..d0bbee1ea15a9 100644 --- a/src/cmd/cgo/internal/testsanitizers/cshared_test.go +++ b/src/cmd/cgo/internal/testsanitizers/cshared_test.go @@ -65,7 +65,7 @@ func TestShared(t *testing.T) { continue } - t.Run(name, func { t | + t.Run(name, func { t -> t.Parallel() config := configure(tc.sanitizer) config.skipIfCSanitizerBroken(t) diff --git a/src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go b/src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go index a5ee4c2ff09ec..1111bd3e014ac 100644 --- a/src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go +++ b/src/cmd/cgo/internal/testsanitizers/libfuzzer_test.go @@ -45,7 +45,7 @@ func TestLibFuzzer(t *testing.T) { for _, tc := range cases { tc := tc name := strings.TrimSuffix(tc.goSrc, ".go") - t.Run(name, func { t | + t.Run(name, func { t -> t.Parallel() dir := newTempDir(t) diff --git a/src/cmd/cgo/internal/testsanitizers/msan_test.go b/src/cmd/cgo/internal/testsanitizers/msan_test.go index e1b1b9650bd11..2fd0f2e4bb23f 100644 --- a/src/cmd/cgo/internal/testsanitizers/msan_test.go +++ b/src/cmd/cgo/internal/testsanitizers/msan_test.go @@ -64,7 +64,7 @@ func TestMSAN(t *testing.T) { for _, tc := range cases { tc := tc name := strings.TrimSuffix(tc.src, ".go") - t.Run(name, func { t | + t.Run(name, func { t -> t.Parallel() dir := newTempDir(t) diff --git a/src/cmd/cgo/internal/testsanitizers/tsan_test.go b/src/cmd/cgo/internal/testsanitizers/tsan_test.go index afed31f348c7a..69d6b4450edb5 100644 --- a/src/cmd/cgo/internal/testsanitizers/tsan_test.go +++ b/src/cmd/cgo/internal/testsanitizers/tsan_test.go @@ -59,7 +59,7 @@ func TestTSAN(t *testing.T) { for _, tc := range cases { tc := tc name := strings.TrimSuffix(tc.src, ".go") - t.Run(name, func { t | + t.Run(name, func { t -> t.Parallel() dir := newTempDir(t) diff --git a/src/cmd/cgo/internal/testshared/shared_test.go b/src/cmd/cgo/internal/testshared/shared_test.go index 68020518b4b32..57ba09ba2cd0f 100644 --- a/src/cmd/cgo/internal/testshared/shared_test.go +++ b/src/cmd/cgo/internal/testshared/shared_test.go @@ -97,11 +97,11 @@ func goCmd(t *testing.T, args ...string) string { // TestMain calls testMain so that the latter can use defer (TestMain exits with os.Exit). func testMain(m *testing.M) (int, error) { if testing.Short() && os.Getenv("GO_BUILDER_NAME") == "" { - globalSkip = func { t | t.Skip("short mode and $GO_BUILDER_NAME not set") } + globalSkip = func { t -> t.Skip("short mode and $GO_BUILDER_NAME not set") } return m.Run(), nil } if !platform.BuildModeSupported(runtime.Compiler, "shared", runtime.GOOS, runtime.GOARCH) { - globalSkip = func { t | t.Skip("shared build mode not supported") } + globalSkip = func { t -> t.Skip("shared build mode not supported") } return m.Run(), nil } if !testenv.HasCGO() { @@ -956,7 +956,7 @@ func TestRebuilding(t *testing.T) { shlib := info[1] // If the source is newer than both the .a file and the .so, both are rebuilt. - t.Run("newsource", func { t | + t.Run("newsource", func { t -> resetFileStamps() cleanup := touch(t, "./depBase/dep.go") defer func() { @@ -969,7 +969,7 @@ func TestRebuilding(t *testing.T) { }) // If the .a file is newer than the .so, the .so is rebuilt (but not the .a) - t.Run("newarchive", func { t | + t.Run("newarchive", func { t -> resetFileStamps() AssertNotRebuilt(t, "new .a file before build", target) goCmd(t, "list", "-linkshared", "-f={{.ImportPath}} {{.Stale}} {{.StaleReason}} {{.Target}}", "./depBase") diff --git a/src/cmd/cgo/internal/teststdio/stdio_test.go b/src/cmd/cgo/internal/teststdio/stdio_test.go index 6508c88e4d275..5090847c3c2d3 100644 --- a/src/cmd/cgo/internal/teststdio/stdio_test.go +++ b/src/cmd/cgo/internal/teststdio/stdio_test.go @@ -58,7 +58,7 @@ func TestTestRun(t *testing.T) { } { file := file wantFile := strings.Replace(file, ".go", ".out", 1) - t.Run(file, func { t | + t.Run(file, func { t -> cmd := exec.Command("go", "run", file) got, err := cmd.CombinedOutput() if err != nil { diff --git a/src/cmd/cgo/out.go b/src/cmd/cgo/out.go index 7c924454c4e11..b311f88607916 100644 --- a/src/cmd/cgo/out.go +++ b/src/cmd/cgo/out.go @@ -963,9 +963,9 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { } fntype := fn.Type forFieldList(fntype.Params, - func { i, aname, atype | argField(atype, "p%d", i) }) + func { i, aname, atype -> argField(atype, "p%d", i) }) forFieldList(fntype.Results, - func { i, aname, atype | argField(atype, "r%d", i) }) + func { i, aname, atype -> argField(atype, "r%d", i) }) if ctype == "struct {\n" { ctype += "\t\tchar unused;\n" // avoid empty struct } @@ -983,7 +983,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { fmt.Fprintf(fgcch, "\n/* Return type for %s */\n", exp.ExpName) fmt.Fprintf(fgcch, "struct %s_return {\n", exp.ExpName) forFieldList(fntype.Results, - func { i, aname, atype | + func { i, aname, atype -> fmt.Fprintf(fgcch, "\t%s r%d;", p.cgoType(atype).C, i) if len(aname) > 0 { fmt.Fprintf(fgcch, " /* %s */", aname) @@ -1005,7 +1005,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { s += " recv" } forFieldList(fntype.Params, - func { i, aname, atype | + func { i, aname, atype -> if i > 0 || fn.Recv != nil { s += ", " } @@ -1045,7 +1045,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { fmt.Fprintf(fgcc, "\t_cgo_a.recv = recv;\n") } forFieldList(fntype.Params, - func { i, aname, atype | fmt.Fprintf(fgcc, "\t_cgo_a.p%d = %s;\n", i, exportParamName(aname, i)) }) + func { i, aname, atype -> fmt.Fprintf(fgcc, "\t_cgo_a.p%d = %s;\n", i, exportParamName(aname, i)) }) fmt.Fprintf(fgcc, "\t_cgo_tsan_release();\n") fmt.Fprintf(fgcc, "\tcrosscall2(_cgoexp%s_%s, &_cgo_a, %d, _cgo_ctxt);\n", cPrefix, exp.ExpName, off) fmt.Fprintf(fgcc, "\t_cgo_tsan_acquire();\n") @@ -1055,7 +1055,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { fmt.Fprintf(fgcc, "\treturn _cgo_a.r0;\n") } else { forFieldList(fntype.Results, - func { i, aname, atype | fmt.Fprintf(fgcc, "\tr.r%d = _cgo_a.r%d;\n", i, i) }) + func { i, aname, atype -> fmt.Fprintf(fgcc, "\tr.r%d = _cgo_a.r%d;\n", i, i) }) fmt.Fprintf(fgcc, "\treturn r;\n") } } @@ -1089,7 +1089,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { if gccResult != "void" { // Write results back to frame. forFieldList(fntype.Results, - func { i, aname, atype | + func { i, aname, atype -> if i > 0 { fmt.Fprintf(fgo2, ", ") } @@ -1102,7 +1102,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { } fmt.Fprintf(fgo2, "%s(", exp.Func.Name) forFieldList(fntype.Params, - func { i, aname, atype | + func { i, aname, atype -> if i > 0 { fmt.Fprint(fgo2, ", ") } @@ -1113,7 +1113,7 @@ func (p *Package) writeExports(fgo2, fm, fgcc, fgcch io.Writer) { // Verify that any results don't contain any // Go pointers. forFieldList(fntype.Results, - func { i, aname, atype | + func { i, aname, atype -> if !p.hasPointer(nil, atype, false) { return } @@ -1146,13 +1146,13 @@ func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) { cdeclBuf := new(strings.Builder) resultCount := 0 forFieldList(fntype.Results, - func { i, aname, atype | resultCount++ }) + func { i, aname, atype -> resultCount++ }) switch resultCount { case 0: fmt.Fprintf(cdeclBuf, "void") case 1: forFieldList(fntype.Results, - func { i, aname, atype | + func { i, aname, atype -> t := p.cgoType(atype) fmt.Fprintf(cdeclBuf, "%s", t.C) }) @@ -1161,7 +1161,7 @@ func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) { fmt.Fprintf(fgcch, "\n/* Return type for %s */\n", exp.ExpName) fmt.Fprintf(fgcch, "struct %s_return {\n", exp.ExpName) forFieldList(fntype.Results, - func { i, aname, atype | + func { i, aname, atype -> t := p.cgoType(atype) fmt.Fprintf(fgcch, "\t%s r%d;", t.C, i) if len(aname) > 0 { @@ -1182,7 +1182,7 @@ func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) { } // Function parameters. forFieldList(fntype.Params, - func { i, aname, atype | + func { i, aname, atype -> if i > 0 || fn.Recv != nil { fmt.Fprintf(cdeclBuf, ", ") } @@ -1223,7 +1223,7 @@ func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) { fmt.Fprint(fgcc, "recv") } forFieldList(fntype.Params, - func { i, aname, atype | + func { i, aname, atype -> if i > 0 || fn.Recv != nil { fmt.Fprintf(fgcc, ", ") } @@ -1253,7 +1253,7 @@ func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) { printer.Fprint(fgo2, fset, fn.Recv.List[0].Type) } forFieldList(fntype.Params, - func { i, aname, atype | + func { i, aname, atype -> if i > 0 || fn.Recv != nil { fmt.Fprintf(fgo2, ", ") } @@ -1264,7 +1264,7 @@ func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) { if resultCount > 0 { fmt.Fprintf(fgo2, " (") forFieldList(fntype.Results, - func { i, aname, atype | + func { i, aname, atype -> if i > 0 { fmt.Fprint(fgo2, ", ") } @@ -1284,7 +1284,7 @@ func (p *Package) writeGccgoExports(fgo2, fm, fgcc, fgcch io.Writer) { } fmt.Fprintf(fgo2, "%s(", exp.Func.Name) forFieldList(fntype.Params, - func { i, aname, atype | + func { i, aname, atype -> if i > 0 { fmt.Fprint(fgo2, ", ") } diff --git a/src/cmd/compile/internal/arm/galign.go b/src/cmd/compile/internal/arm/galign.go index 9ba172fc9f539..25f641c51708d 100644 --- a/src/cmd/compile/internal/arm/galign.go +++ b/src/cmd/compile/internal/arm/galign.go @@ -19,7 +19,7 @@ func Init(arch *ssagen.ArchInfo) { arch.ZeroRange = zerorange arch.Ginsnop = ginsnop - arch.SSAMarkMoves = func { s, b | } + arch.SSAMarkMoves = func { s, b -> } arch.SSAGenValue = ssaGenValue arch.SSAGenBlock = ssaGenBlock } diff --git a/src/cmd/compile/internal/arm64/galign.go b/src/cmd/compile/internal/arm64/galign.go index 072945a0d1432..31950d45c9fc6 100644 --- a/src/cmd/compile/internal/arm64/galign.go +++ b/src/cmd/compile/internal/arm64/galign.go @@ -19,7 +19,7 @@ func Init(arch *ssagen.ArchInfo) { arch.ZeroRange = zerorange arch.Ginsnop = ginsnop - arch.SSAMarkMoves = func { s, b | } + arch.SSAMarkMoves = func { s, b -> } arch.SSAGenValue = ssaGenValue arch.SSAGenBlock = ssaGenBlock arch.LoadRegResult = loadRegResult diff --git a/src/cmd/compile/internal/base/base.go b/src/cmd/compile/internal/base/base.go index 320a14610b663..c80fa26d80f04 100644 --- a/src/cmd/compile/internal/base/base.go +++ b/src/cmd/compile/internal/base/base.go @@ -35,7 +35,7 @@ func forEachGC(fn func() bool) { type T [32]byte // large enough to avoid runtime's tiny object allocator var finalizer func(*T) - finalizer = func { p | if fn() { + finalizer = func { p -> if fn() { runtime.SetFinalizer(p, finalizer) } } diff --git a/src/cmd/compile/internal/base/hashdebug.go b/src/cmd/compile/internal/base/hashdebug.go index 495282b614d92..a8187bf901620 100644 --- a/src/cmd/compile/internal/base/hashdebug.go +++ b/src/cmd/compile/internal/base/hashdebug.go @@ -365,7 +365,7 @@ func (d *HashDebug) hashPos(ctxt *obj.Link, pos src.XPos) uint64 { return bisect.Hash(d.short(p.Filename()), p.Line(), p.Col()) } h := bisect.Hash() - ctxt.AllPos(pos, func { p | h = bisect.Hash(h, d.short(p.Filename()), p.Line(), p.Col()) }) + ctxt.AllPos(pos, func { p -> h = bisect.Hash(h, d.short(p.Filename()), p.Line(), p.Col()) }) return h } @@ -379,7 +379,7 @@ func (d *HashDebug) fmtPos(ctxt *obj.Link, pos src.XPos) string { return format(ctxt.InnermostPos(pos)) } var stk []string - ctxt.AllPos(pos, func { p | stk = append(stk, format(p)) }) + ctxt.AllPos(pos, func { p -> stk = append(stk, format(p)) }) return strings.Join(stk, "; ") } diff --git a/src/cmd/compile/internal/base/link.go b/src/cmd/compile/internal/base/link.go index 4cbfce01c2870..b308718a7f1c1 100644 --- a/src/cmd/compile/internal/base/link.go +++ b/src/cmd/compile/internal/base/link.go @@ -49,5 +49,5 @@ func Linkname(name string, abi obj.ABI) *obj.LSym { // linksym is an internal helper function for implementing the above // exported APIs. func linksym(pkg, name string, abi obj.ABI) *obj.LSym { - return Ctxt.LookupABIInit(name, abi, func { r | r.Pkg = pkg }) + return Ctxt.LookupABIInit(name, abi, func { r -> r.Pkg = pkg }) } diff --git a/src/cmd/compile/internal/compare/compare.go b/src/cmd/compile/internal/compare/compare.go index 95167d5bc5175..6e43555f993b1 100644 --- a/src/cmd/compile/internal/compare/compare.go +++ b/src/cmd/compile/internal/compare/compare.go @@ -236,7 +236,7 @@ func EqStruct(t *types.Type, np, nq ir.Node) ([]ir.Node, bool) { isCall := func(n ir.Node) bool { return n.Op() == ir.OCALL || n.Op() == ir.OCALLFUNC } - sort.SliceStable(c, func { i, j | return !isCall(c[i]) && isCall(c[j]) }) + sort.SliceStable(c, func { i, j -> return !isCall(c[i]) && isCall(c[j]) }) flatConds = append(flatConds, c...) } return flatConds, len(conds) > 1 diff --git a/src/cmd/compile/internal/compare/compare_test.go b/src/cmd/compile/internal/compare/compare_test.go index 2bde16b0cbfcc..726aabbbc85a4 100644 --- a/src/cmd/compile/internal/compare/compare_test.go +++ b/src/cmd/compile/internal/compare/compare_test.go @@ -75,7 +75,7 @@ func TestEqStructCost(t *testing.T) { } for _, tc := range tt { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> fields := make([]*types.Field, len(tc.fieldTypes)) for i, ftyp := range tc.fieldTypes { fields[i] = types.NewField(src.NoXPos, typecheck.LookupNum("f", i), ftyp) diff --git a/src/cmd/compile/internal/devirtualize/pgo.go b/src/cmd/compile/internal/devirtualize/pgo.go index 820d07741d08b..6bb11b5118714 100644 --- a/src/cmd/compile/internal/devirtualize/pgo.go +++ b/src/cmd/compile/internal/devirtualize/pgo.go @@ -113,7 +113,7 @@ func ProfileGuided(fn *ir.Func, p *pgoir.Profile) { } var edit func(n ir.Node) ir.Node - edit = func { n | + edit = func { n -> if n == nil { return n } @@ -758,7 +758,7 @@ func findHotConcreteCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr, func findHotConcreteInterfaceCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr) (*ir.Func, int64) { inter, method := interfaceCallRecvTypeAndMethod(call) - return findHotConcreteCallee(p, caller, call, func { callerName, callOffset, e | + return findHotConcreteCallee(p, caller, call, func { callerName, callOffset, e -> ctyp := methodRecvType(e.Dst.AST) if ctyp == nil { // Not a method. @@ -806,7 +806,7 @@ func findHotConcreteInterfaceCallee(p *pgoir.Profile, caller *ir.Func, call *ir. func findHotConcreteFunctionCallee(p *pgoir.Profile, caller *ir.Func, call *ir.CallExpr) (*ir.Func, int64) { typ := call.Fun.Type().Underlying() - return findHotConcreteCallee(p, caller, call, func { callerName, callOffset, e | + return findHotConcreteCallee(p, caller, call, func { callerName, callOffset, e -> ctyp := e.Dst.AST.Type().Underlying() // If ctyp doesn't match typ it is most likely from a different diff --git a/src/cmd/compile/internal/dwarfgen/dwarf.go b/src/cmd/compile/internal/dwarfgen/dwarf.go index 865bb8c6e3b48..f1847078bc7e0 100644 --- a/src/cmd/compile/internal/dwarfgen/dwarf.go +++ b/src/cmd/compile/internal/dwarfgen/dwarf.go @@ -541,7 +541,7 @@ func createComplexVar(fnsym *obj.LSym, fn *ir.Func, varID ssa.VarID, closureVars } list := debug.LocationLists[varID] if len(list) != 0 { - dvar.PutLocationList = func { listSym, startPC | debug.PutLocationList(list, base.Ctxt, listSym.(*obj.LSym), startPC.(*obj.LSym)) } + dvar.PutLocationList = func { listSym, startPC -> debug.PutLocationList(list, base.Ctxt, listSym.(*obj.LSym), startPC.(*obj.LSym)) } } return dvar } diff --git a/src/cmd/compile/internal/dwarfgen/scope.go b/src/cmd/compile/internal/dwarfgen/scope.go index 96624c62e1080..79bc7de55d316 100644 --- a/src/cmd/compile/internal/dwarfgen/scope.go +++ b/src/cmd/compile/internal/dwarfgen/scope.go @@ -20,7 +20,7 @@ func xposBefore(p, q src.XPos) bool { } func findScope(marks []ir.Mark, pos src.XPos) ir.ScopeID { - i := sort.Search(len(marks), func { i | return xposBefore(pos, marks[i].Pos) }) + i := sort.Search(len(marks), func { i -> return xposBefore(pos, marks[i].Pos) }) if i == 0 { return 0 } diff --git a/src/cmd/compile/internal/dwarfgen/scope_test.go b/src/cmd/compile/internal/dwarfgen/scope_test.go index e4f48aee4182c..479683509c76a 100644 --- a/src/cmd/compile/internal/dwarfgen/scope_test.go +++ b/src/cmd/compile/internal/dwarfgen/scope_test.go @@ -400,7 +400,7 @@ func readScope(ctxt *scopexplainContext, scope *lexblock, entry *dwarf.Entry) { } switch e.Tag { case 0: - sort.Slice(scope.vars, func { i, j | return scope.vars[i].expr < scope.vars[j].expr }) + sort.Slice(scope.vars, func { i, j -> return scope.vars[i].expr < scope.vars[j].expr }) return case dwarf.TagFormalParameter: typ, err := ctxt.dwarfData.Type(e.Val(dwarf.AttrType).(dwarf.Offset)) diff --git a/src/cmd/compile/internal/escape/escape.go b/src/cmd/compile/internal/escape/escape.go index 907ff34723a24..f51e954cdbd78 100644 --- a/src/cmd/compile/internal/escape/escape.go +++ b/src/cmd/compile/internal/escape/escape.go @@ -205,7 +205,7 @@ func (b *batch) walkFunc(fn *ir.Func) { fn.SetEsc(escFuncStarted) // Identify labels that mark the head of an unstructured loop. - ir.Visit(fn, func { n | + ir.Visit(fn, func { n -> switch n.Op() { case ir.OLABEL: n := n.(*ir.LabelStmt) diff --git a/src/cmd/compile/internal/gc/compile.go b/src/cmd/compile/internal/gc/compile.go index 975f9069ee623..aada6bef17b6d 100644 --- a/src/cmd/compile/internal/gc/compile.go +++ b/src/cmd/compile/internal/gc/compile.go @@ -131,7 +131,7 @@ func compileFunctions(profile *pgoir.Profile) { // Compile the longest functions first, // since they're most likely to be the slowest. // This helps avoid stragglers. - sort.Slice(compilequeue, func { i, j | return len(compilequeue[i].Body) > len(compilequeue[j].Body) }) + sort.Slice(compilequeue, func { i, j -> return len(compilequeue[i].Body) > len(compilequeue[j].Body) }) } // By default, we perform work right away on the current goroutine @@ -171,16 +171,16 @@ func compileFunctions(profile *pgoir.Profile) { } } }() - queue = func { work | workq <- work } + queue = func { work -> workq <- work } } var wg sync.WaitGroup var compile func([]*ir.Func) - compile = func { fns | + compile = func { fns -> wg.Add(len(fns)) for _, fn := range fns { fn := fn - queue(func { worker | + queue(func { worker -> ssagen.Compile(fn, worker, profile) compile(fn.Closures) wg.Done() diff --git a/src/cmd/compile/internal/importer/gcimporter_test.go b/src/cmd/compile/internal/importer/gcimporter_test.go index 5966966b15a28..32faf304be4ed 100644 --- a/src/cmd/compile/internal/importer/gcimporter_test.go +++ b/src/cmd/compile/internal/importer/gcimporter_test.go @@ -242,7 +242,7 @@ func TestImportStdLib(t *testing.T) { var nimports int for _, pkg := range pkgs { - t.Run(pkg, func { t | + t.Run(pkg, func { t -> if testPath(t, pkg, filepath.Join(testenv.GOROOT(t), "src", path.Dir(pkg))) != nil { nimports++ } diff --git a/src/cmd/compile/internal/inline/inl.go b/src/cmd/compile/internal/inline/inl.go index b2c11884ad7c3..ef832f6609b05 100644 --- a/src/cmd/compile/internal/inline/inl.go +++ b/src/cmd/compile/internal/inline/inl.go @@ -165,7 +165,7 @@ func CanInlineFuncs(funcs []*ir.Func, profile *pgoir.Profile) { return } - ir.VisitFuncsBottomUp(funcs, func { funcs, recursive | + ir.VisitFuncsBottomUp(funcs, func { funcs, recursive -> numfns := numNonClosures(funcs) for _, fn := range funcs { @@ -196,12 +196,12 @@ func GarbageCollectUnreferencedHiddenClosures() { liveFuncs := make(map[*ir.Func]bool) var markLiveFuncs func(fn *ir.Func) - markLiveFuncs = func { fn | + markLiveFuncs = func { fn -> if liveFuncs[fn] { return } liveFuncs[fn] = true - ir.Visit(fn, func { n | if clo, ok := n.(*ir.ClosureExpr); ok { + ir.Visit(fn, func { n -> if clo, ok := n.(*ir.ClosureExpr); ok { markLiveFuncs(clo.Func) } }) } @@ -430,7 +430,7 @@ func canDelayResults(fn *ir.Func) bool { // (3) the result parameters aren't named. nreturns := 0 - ir.VisitList(fn.Body, func { n | + ir.VisitList(fn.Body, func { n -> if n, ok := n.(*ir.ReturnStmt); ok { nreturns++ if len(n.Results) == 0 { @@ -786,7 +786,7 @@ opSwitch: // Note: The criteria for "big" is heuristic and subject to change. func IsBigFunc(fn *ir.Func) bool { budget := inlineBigFunctionNodes - return ir.Any(fn, func { n | + return ir.Any(fn, func { n -> // See logic in hairyVisitor.doNode, explaining unified IR's // handling of "a, b = f()" assignments. if n, ok := n.(*ir.AssignListStmt); ok && n.Op() == ir.OAS2 && len(n.Rhs) > 0 { diff --git a/src/cmd/compile/internal/inline/inlheur/analyze.go b/src/cmd/compile/internal/inline/inlheur/analyze.go index 17752f0f48ee8..652e63c12679b 100644 --- a/src/cmd/compile/internal/inline/inlheur/analyze.go +++ b/src/cmd/compile/internal/inline/inlheur/analyze.go @@ -85,7 +85,7 @@ func AnalyzeFunc(fn *ir.Func, canInline func(*ir.Func), budgetForFunc func(*ir.F // the way, test to see whether each closure is inlinable in case // we might be returning it. funcs := []*ir.Func{fn} - ir.VisitFuncAndClosures(fn, func { n | if clo, ok := n.(*ir.ClosureExpr); ok { + ir.VisitFuncAndClosures(fn, func { n -> if clo, ok := n.(*ir.ClosureExpr); ok { funcs = append(funcs, clo.Func) } }) @@ -182,7 +182,7 @@ func computeFuncProps(fn *ir.Func, inlineMaxBudget int, nf *nameFinder) (*FuncPr func runAnalyzersOnFunction(fn *ir.Func, analyzers []propAnalyzer) { var doNode func(ir.Node) bool - doNode = func { n | + doNode = func { n -> for _, a := range analyzers { a.nodeVisitPre(n) } @@ -232,7 +232,7 @@ func DumpFuncProps(fn *ir.Func, dumpfile string) { return } captureFuncDumpEntry(fn) - ir.VisitFuncAndClosures(fn, func { n | if clo, ok := n.(*ir.ClosureExpr); ok { + ir.VisitFuncAndClosures(fn, func { n -> if clo, ok := n.(*ir.ClosureExpr); ok { captureFuncDumpEntry(clo.Func) } }) } else { @@ -345,7 +345,7 @@ func dumpFnPreamble(w io.Writer, funcInlHeur *fnInlHeur, ecst encodedCallSiteTab // sortFnInlHeurSlice sorts a slice of fnInlHeur based on // the starting line of the function definition, then by name. func sortFnInlHeurSlice(sl []fnInlHeur) []fnInlHeur { - sort.SliceStable(sl, func { i, j | + sort.SliceStable(sl, func { i, j -> if sl[i].line != sl[j].line { return sl[i].line < sl[j].line } diff --git a/src/cmd/compile/internal/inline/inlheur/analyze_func_callsites.go b/src/cmd/compile/internal/inline/inlheur/analyze_func_callsites.go index ed52612500162..24bf1565169c3 100644 --- a/src/cmd/compile/internal/inline/inlheur/analyze_func_callsites.go +++ b/src/cmd/compile/internal/inline/inlheur/analyze_func_callsites.go @@ -56,7 +56,7 @@ func makeCallSiteTableBuilder(fn *ir.Func, cstab CallSiteTab, ptab map[ir.Node]p func computeCallSiteTable(fn *ir.Func, region ir.Nodes, cstab CallSiteTab, ptab map[ir.Node]pstate, loopNestingLevel int, nf *nameFinder) CallSiteTab { cstb := makeCallSiteTableBuilder(fn, cstab, ptab, loopNestingLevel, nf) var doNode func(ir.Node) bool - doNode = func { n | + doNode = func { n -> cstb.nodeVisitPre(n) ir.DoChildren(n, doNode) cstb.nodeVisitPost(n) diff --git a/src/cmd/compile/internal/inline/inlheur/analyze_func_params.go b/src/cmd/compile/internal/inline/inlheur/analyze_func_params.go index 44bf394888a84..06d8fcef48da5 100644 --- a/src/cmd/compile/internal/inline/inlheur/analyze_func_params.go +++ b/src/cmd/compile/internal/inline/inlheur/analyze_func_params.go @@ -150,7 +150,7 @@ func (pa *paramsAnalyzer) checkParams(x ir.Node, flag ParamPropBits, mayflag Par // specific parameter had a constant value. func (pa *paramsAnalyzer) foldCheckParams(x ir.Node) { pa.checkParams(x, ParamFeedsIfOrSwitch, ParamMayFeedIfOrSwitch, - func { x, p, idx | return ShouldFoldIfNameConstant(x, []*ir.Name{p}), false }) + func { x, p, idx -> return ShouldFoldIfNameConstant(x, []*ir.Name{p}), false }) } // callCheckParams examines the target of call expression 'ce' to see @@ -172,7 +172,7 @@ func (pa *paramsAnalyzer) callCheckParams(ce *ir.CallExpr) { } pa.checkParams(r, ParamFeedsInterfaceMethodCall, ParamMayFeedInterfaceMethodCall, - func { x, p, idx | + func { x, p, idx -> name := x.(*ir.Name) return name == p, false }) @@ -188,7 +188,7 @@ func (pa *paramsAnalyzer) callCheckParams(ce *ir.CallExpr) { if name.Class == ir.PPARAM { pa.checkParams(called, ParamFeedsIndirectCall, ParamMayFeedIndirectCall, - func { x, p, idx | + func { x, p, idx -> name := x.(*ir.Name) return name == p, false }) diff --git a/src/cmd/compile/internal/inline/inlheur/callsite.go b/src/cmd/compile/internal/inline/inlheur/callsite.go index 7e5bca241abe5..a40cd3d5f0ec2 100644 --- a/src/cmd/compile/internal/inline/inlheur/callsite.go +++ b/src/cmd/compile/internal/inline/inlheur/callsite.go @@ -99,7 +99,7 @@ func (cst CallSiteTab) merge(other CallSiteTab) error { func fmtFullPos(p src.XPos) string { var sb strings.Builder sep := "" - base.Ctxt.AllPos(p, func { pos | + base.Ctxt.AllPos(p, func { pos -> fmt.Fprintf(&sb, sep) sep = "|" file := filepath.Base(pos.Filename()) diff --git a/src/cmd/compile/internal/inline/inlheur/eclassify.go b/src/cmd/compile/internal/inline/inlheur/eclassify.go index 7571abbaff038..39f2f4cb4df5b 100644 --- a/src/cmd/compile/internal/inline/inlheur/eclassify.go +++ b/src/cmd/compile/internal/inline/inlheur/eclassify.go @@ -46,7 +46,7 @@ import ( func ShouldFoldIfNameConstant(n ir.Node, names []*ir.Name) bool { cl := makeExprClassifier(names) var doNode func(ir.Node) bool - doNode = func { n | + doNode = func { n -> ir.DoChildren(n, doNode) cl.Visit(n) return false diff --git a/src/cmd/compile/internal/inline/inlheur/score_callresult_uses.go b/src/cmd/compile/internal/inline/inlheur/score_callresult_uses.go index 1b35f2f93b311..c684e591906c5 100644 --- a/src/cmd/compile/internal/inline/inlheur/score_callresult_uses.go +++ b/src/cmd/compile/internal/inline/inlheur/score_callresult_uses.go @@ -55,7 +55,7 @@ func (csa *callSiteAnalyzer) rescoreBasedOnCallResultUses(fn *ir.Func, resultNam condLevelTracker: new(condLevelTracker), } var doNode func(ir.Node) bool - doNode = func { n | + doNode = func { n -> rua.nodeVisitPre(n) ir.DoChildren(n, doNode) rua.nodeVisitPost(n) @@ -350,7 +350,7 @@ func (rua *resultUseAnalyzer) foldCheckResults(cond ir.Node) { func collectNamesUsed(expr ir.Node) []*ir.Name { res := []*ir.Name{} - ir.Visit(expr, func { n | + ir.Visit(expr, func { n -> if n.Op() != ir.ONAME { return } diff --git a/src/cmd/compile/internal/inline/inlheur/scoring.go b/src/cmd/compile/internal/inline/inlheur/scoring.go index cc2d4fec68739..5cf539caa486f 100644 --- a/src/cmd/compile/internal/inline/inlheur/scoring.go +++ b/src/cmd/compile/internal/inline/inlheur/scoring.go @@ -504,7 +504,7 @@ func (csa *callSiteAnalyzer) scoreCallsRegion(fn *ir.Func, region ir.Nodes, csta csl = append(csl, cs) } scoreCallsCache.csl = csl[:0] - sort.Slice(csl, func { i, j | return csl[i].ID < csl[j].ID }) + sort.Slice(csl, func { i, j -> return csl[i].ID < csl[j].ID }) // Score each call site. var resultNameTab map[*ir.Name]resultPropAndCS @@ -639,7 +639,7 @@ var allCallSites CallSiteTab func DumpInlCallSiteScores(profile *pgoir.Profile, budgetCallback func(fn *ir.Func, profile *pgoir.Profile) (int32, bool)) { var indirectlyDueToPromotion func(cs *CallSite) bool - indirectlyDueToPromotion = func { cs | + indirectlyDueToPromotion = func { cs -> bud, _ := budgetCallback(cs.Callee, profile) hairyval := cs.Callee.Inl.Cost score := int32(cs.Score) @@ -700,7 +700,7 @@ func DumpInlCallSiteScores(profile *pgoir.Profile, budgetCallback func(fn *ir.Fu for _, cs := range allCallSites { sl = append(sl, cs) } - sort.Slice(sl, func { i, j | + sort.Slice(sl, func { i, j -> if sl[i].Score != sl[j].Score { return sl[i].Score < sl[j].Score } diff --git a/src/cmd/compile/internal/inline/interleaved/interleaved.go b/src/cmd/compile/internal/inline/interleaved/interleaved.go index 1a643f8b33d6d..8aa884028572b 100644 --- a/src/cmd/compile/internal/inline/interleaved/interleaved.go +++ b/src/cmd/compile/internal/inline/interleaved/interleaved.go @@ -22,7 +22,7 @@ import ( func DevirtualizeAndInlinePackage(pkg *ir.Package, profile *pgoir.Profile) { if profile != nil && base.Debug.PGODevirtualize > 0 { // TODO(mdempsky): Integrate into DevirtualizeAndInlineFunc below. - ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func { list, recursive | for _, fn := range list { + ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func { list, recursive -> for _, fn := range list { devirtualize.ProfileGuided(fn, profile) } }) ir.CurFunc = nil @@ -131,7 +131,7 @@ func fixpoint(fn *ir.Func, match func(ir.Node) bool, edit func(ir.Node) ir.Node) var parens []*ir.ParenExpr var mark func(ir.Node) ir.Node - mark = func { n | + mark = func { n -> if _, ok := n.(*ir.ParenExpr); ok { return n // already visited n.X before wrapping } @@ -177,7 +177,7 @@ func fixpoint(fn *ir.Func, match func(ir.Node) bool, edit func(ir.Node) ir.Node) return // short circuit } var unparen func(ir.Node) ir.Node - unparen = func { n | + unparen = func { n -> if paren, ok := n.(*ir.ParenExpr); ok { n = paren.X } diff --git a/src/cmd/compile/internal/ir/copy.go b/src/cmd/compile/internal/ir/copy.go index 61fbbc6223177..8ff8ad25bc364 100644 --- a/src/cmd/compile/internal/ir/copy.go +++ b/src/cmd/compile/internal/ir/copy.go @@ -18,7 +18,7 @@ func Copy(n Node) Node { // If pos.IsKnown(), it sets the source position of newly allocated Nodes to pos. func DeepCopy(pos src.XPos, n Node) Node { var edit func(Node) Node - edit = func { x | + edit = func { x -> switch x.Op() { case ONAME, ONONAME, OLITERAL, ONIL, OTYPE: return x diff --git a/src/cmd/compile/internal/ir/expr.go b/src/cmd/compile/internal/ir/expr.go index b019c71cd8d5c..b8b667fdbd658 100644 --- a/src/cmd/compile/internal/ir/expr.go +++ b/src/cmd/compile/internal/ir/expr.go @@ -958,7 +958,7 @@ func Reassigned(name *Name) bool { } var do func(n Node) bool - do = func { n | + do = func { n -> switch n.Op() { case OAS: n := n.(*AssignStmt) diff --git a/src/cmd/compile/internal/ir/fmt.go b/src/cmd/compile/internal/ir/fmt.go index 76ecb243c3efe..390d61df8d5e0 100644 --- a/src/cmd/compile/internal/ir/fmt.go +++ b/src/cmd/compile/internal/ir/fmt.go @@ -1037,7 +1037,7 @@ func dumpNodeHeader(w io.Writer, n Node) { fmt.Fprint(w, "+") } sep := "" - base.Ctxt.AllPos(n.Pos(), func { pos | + base.Ctxt.AllPos(n.Pos(), func { pos -> fmt.Fprint(w, sep) sep = " " // TODO(mdempsky): Print line pragma details too. diff --git a/src/cmd/compile/internal/ir/func.go b/src/cmd/compile/internal/ir/func.go index 997a31714154d..06ba8341ace28 100644 --- a/src/cmd/compile/internal/ir/func.go +++ b/src/cmd/compile/internal/ir/func.go @@ -465,7 +465,7 @@ func closureName(outerfn *Func, pos src.XPos, why Op) *types.Sym { // too (#60324). if inlIndex := base.Ctxt.InnermostPos(pos).Base().InliningIndex(); inlIndex >= 0 { names := []string{outer} - base.Ctxt.InlTree.AllParents(inlIndex, func { call | names = append(names, call.Name) }) + base.Ctxt.InlTree.AllParents(inlIndex, func { call -> names = append(names, call.Name) }) outer = strings.Join(names, ".") } diff --git a/src/cmd/compile/internal/ir/func_test.go b/src/cmd/compile/internal/ir/func_test.go index fbc41670a5027..b0cd3f858d05a 100644 --- a/src/cmd/compile/internal/ir/func_test.go +++ b/src/cmd/compile/internal/ir/func_test.go @@ -69,7 +69,7 @@ func TestSplitPkg(t *testing.T) { } for _, tc := range tests { - t.Run(tc.in, func { t | + t.Run(tc.in, func { t -> pkg, sym := splitPkg(tc.in) if pkg != tc.pkg { t.Errorf("splitPkg(%q) got pkg %q want %q", tc.in, pkg, tc.pkg) diff --git a/src/cmd/compile/internal/ir/mknode.go b/src/cmd/compile/internal/ir/mknode.go index 5b7352c5fbc56..2d385363dc517 100644 --- a/src/cmd/compile/internal/ir/mknode.go +++ b/src/cmd/compile/internal/ir/mknode.go @@ -143,7 +143,7 @@ func main() { } } // Sort for deterministic output. - sort.Slice(concreteNodes, func { i, j | return concreteNodes[i].Name.Name < concreteNodes[j].Name.Name }) + sort.Slice(concreteNodes, func { i, j -> return concreteNodes[i].Name.Name < concreteNodes[j].Name.Name }) // Generate code for each concrete type. for _, t := range concreteNodes { processType(t) diff --git a/src/cmd/compile/internal/ir/node.go b/src/cmd/compile/internal/ir/node.go index bd35d21d1dfe2..c9d3be2007064 100644 --- a/src/cmd/compile/internal/ir/node.go +++ b/src/cmd/compile/internal/ir/node.go @@ -434,7 +434,7 @@ func (s NameSet) Sorted(less func(*Name, *Name) bool) []*Name { for n := range s { res = append(res, n) } - sort.Slice(res, func { i, j | return less(res[i], res[j]) }) + sort.Slice(res, func { i, j -> return less(res[i], res[j]) }) return res } diff --git a/src/cmd/compile/internal/ir/reassign_consistency_check.go b/src/cmd/compile/internal/ir/reassign_consistency_check.go index 849b460f3225b..ac4a4907c9ab6 100644 --- a/src/cmd/compile/internal/ir/reassign_consistency_check.go +++ b/src/cmd/compile/internal/ir/reassign_consistency_check.go @@ -36,7 +36,7 @@ func checkReassignedResult(n *Name, newres bool) { func fmtFullPos(p src.XPos) string { var sb strings.Builder sep := "" - base.Ctxt.AllPos(p, func { pos | + base.Ctxt.AllPos(p, func { pos -> fmt.Fprintf(&sb, sep) sep = "|" file := filepath.Base(pos.Filename()) diff --git a/src/cmd/compile/internal/ir/reassignment.go b/src/cmd/compile/internal/ir/reassignment.go index 16e443805d715..5daf93f20f542 100644 --- a/src/cmd/compile/internal/ir/reassignment.go +++ b/src/cmd/compile/internal/ir/reassignment.go @@ -46,7 +46,7 @@ func (ro *ReassignOracle) Init(fn *Func) { // Walk the function body to discover any locals assigned // via ":=" syntax (e.g. "a := "). var findLocals func(n Node) bool - findLocals = func { n | + findLocals = func { n -> if nn, ok := n.(*Name); ok { if nn.Defn != nil && !nn.Addrtaken() && nn.Class == PAUTO { ro.singleDef[nn] = nn.Defn @@ -98,7 +98,7 @@ func (ro *ReassignOracle) Init(fn *Func) { // similar code in ir.Reassigned; any changes there should be made // here as well. var do func(n Node) bool - do = func { n | + do = func { n -> switch n.Op() { case OAS: asn := n.(*AssignStmt) diff --git a/src/cmd/compile/internal/ir/scc.go b/src/cmd/compile/internal/ir/scc.go index 1de46102a952c..4272bec78906c 100644 --- a/src/cmd/compile/internal/ir/scc.go +++ b/src/cmd/compile/internal/ir/scc.go @@ -81,7 +81,7 @@ func (v *bottomUpVisitor) visit(n *Func) uint32 { } } - Visit(n, func { n | + Visit(n, func { n -> switch n.Op() { case ONAME: if n := n.(*Name); n.Class == PFUNC { diff --git a/src/cmd/compile/internal/ir/visit.go b/src/cmd/compile/internal/ir/visit.go index 5429634a88ad5..52924969258ca 100644 --- a/src/cmd/compile/internal/ir/visit.go +++ b/src/cmd/compile/internal/ir/visit.go @@ -101,7 +101,7 @@ func Visit(n Node, visit func(Node)) { return } var do func(Node) bool - do = func { x | + do = func { x -> visit(x) return DoChildren(x, do) } @@ -118,7 +118,7 @@ func VisitList(list Nodes, visit func(Node)) { // VisitFuncAndClosures calls visit on each non-nil node in fn.Body, // including any nested closure bodies. func VisitFuncAndClosures(fn *Func, visit func(n Node)) { - VisitList(fn.Body, func { n | + VisitList(fn.Body, func { n -> visit(n) if n, ok := n.(*ClosureExpr); ok && n.Op() == OCLOSURE { VisitFuncAndClosures(n.Func, visit) @@ -137,7 +137,7 @@ func Any(n Node, cond func(Node) bool) bool { return false } var do func(Node) bool - do = func { x | return cond(x) || DoChildren(x, do) } + do = func { x -> return cond(x) || DoChildren(x, do) } return do(n) } diff --git a/src/cmd/compile/internal/liveness/mergelocals.go b/src/cmd/compile/internal/liveness/mergelocals.go index f1a6694167c20..0709111eb010e 100644 --- a/src/cmd/compile/internal/liveness/mergelocals.go +++ b/src/cmd/compile/internal/liveness/mergelocals.go @@ -160,7 +160,7 @@ func (mls *MergeLocalsState) Followers(n *ir.Name, tmp []*ir.Name) []*ir.Name { for _, k := range sl[1:] { tmp = append(tmp, mls.vars[k]) } - sort.SliceStable(tmp, func { i, j | return tmp[i].Sym().Name < tmp[j].Sym().Name }) + sort.SliceStable(tmp, func { i, j -> return tmp[i].Sym().Name < tmp[j].Sym().Name }) return tmp } @@ -266,7 +266,7 @@ func (mls *MergeLocalsState) String() string { leaders = append(leaders, n) } } - sort.Slice(leaders, func { i, j | return leaders[i].Sym().Name < leaders[j].Sym().Name }) + sort.Slice(leaders, func { i, j -> return leaders[i].Sym().Name < leaders[j].Sym().Name }) var sb strings.Builder for _, n := range leaders { sb.WriteString(n.Sym().Name + ":") @@ -308,7 +308,7 @@ func (cs *cstate) collectMergeCandidates() { } // Sort by pointerness, size, and then name. - sort.SliceStable(cands, func { i, j | return nameLess(cands[i], cands[j]) }) + sort.SliceStable(cands, func { i, j -> return nameLess(cands[i], cands[j]) }) if cs.trace > 1 { fmt.Fprintf(os.Stderr, "=-= raw cand list for func %v:\n", cs.fn) @@ -574,7 +574,7 @@ func (cs *cstate) populateIndirectUseTable(cands []*ir.Name) ([]*ir.Name, []cand for k := range indirectUE { ids = append(ids, k) } - sort.Slice(ids, func { i, j | return ids[i] < ids[j] }) + sort.Slice(ids, func { i, j -> return ids[i] < ids[j] }) for _, id := range ids { fmt.Fprintf(os.Stderr, " v%d:", id) for _, n := range indirectUE[id] { @@ -588,7 +588,7 @@ func (cs *cstate) populateIndirectUseTable(cands []*ir.Name) ([]*ir.Name, []cand for k := range rawcands { pruned = append(pruned, k) } - sort.Slice(pruned, func { i, j | return nameLess(pruned[i], pruned[j]) }) + sort.Slice(pruned, func { i, j -> return nameLess(pruned[i], pruned[j]) }) var regions []candRegion pruned, regions = cs.genRegions(pruned) if len(pruned) < 2 { @@ -1002,7 +1002,7 @@ func (cs *cstate) computeIntervals() { func fmtFullPos(p src.XPos) string { var sb strings.Builder sep := "" - base.Ctxt.AllPos(p, func { pos | + base.Ctxt.AllPos(p, func { pos -> fmt.Fprintf(&sb, sep) sep = "|" file := filepath.Base(pos.Filename()) diff --git a/src/cmd/compile/internal/liveness/plive.go b/src/cmd/compile/internal/liveness/plive.go index 585dc076ece3b..781aa489321b3 100644 --- a/src/cmd/compile/internal/liveness/plive.go +++ b/src/cmd/compile/internal/liveness/plive.go @@ -1451,7 +1451,7 @@ func (lv *liveness) emitStackObjects() *obj.LSym { } // Sort variables from lowest to highest address. - sort.Slice(vars, func { i, j | return vars[i].FrameOffset() < vars[j].FrameOffset() }) + sort.Slice(vars, func { i, j -> return vars[i].FrameOffset() < vars[j].FrameOffset() }) // Populate the stack object data. // Format must match runtime/stack.go:stackObjectRecord. diff --git a/src/cmd/compile/internal/logopt/log_opts.go b/src/cmd/compile/internal/logopt/log_opts.go index 57c1a559d266a..b27452ca01081 100644 --- a/src/cmd/compile/internal/logopt/log_opts.go +++ b/src/cmd/compile/internal/logopt/log_opts.go @@ -533,6 +533,6 @@ func appendInlinedPos(posTmp, lastTmp []src.Pos, diagnostic *Diagnostic) { // It returns the slice, and the outermost. func parsePos(ctxt *obj.Link, pos src.XPos, posTmp []src.Pos) ([]src.Pos, src.Pos) { posTmp = posTmp[:0] - ctxt.AllPos(pos, func { p | posTmp = append(posTmp, p) }) + ctxt.AllPos(pos, func { p -> posTmp = append(posTmp, p) }) return posTmp, posTmp[0] } diff --git a/src/cmd/compile/internal/logopt/logopt_test.go b/src/cmd/compile/internal/logopt/logopt_test.go index 818176cfad2e4..88aa80ca75803 100644 --- a/src/cmd/compile/internal/logopt/logopt_test.go +++ b/src/cmd/compile/internal/logopt/logopt_test.go @@ -94,7 +94,7 @@ func TestLogOpt(t *testing.T) { outfile := filepath.Join(dir, "file.o") - t.Run("JSON_fails", func { t | + t.Run("JSON_fails", func { t -> // Test malformed flag out, err := testLogOpt(t, "-json=foo", src, outfile) if err == nil { @@ -121,7 +121,7 @@ func TestLogOpt(t *testing.T) { // Ensure that <128 byte copies are not reported and that 128-byte copies are. // Check at both 1 and 8-byte alignments. - t.Run("Copy", func { t | + t.Run("Copy", func { t -> const copyCode = `package x func s128a1(x *[128]int8) [128]int8 { return *x @@ -151,7 +151,7 @@ func s15a8(x *[15]int64) [15]int64 { } for _, arch := range arches { - t.Run(arch, func { t | + t.Run(arch, func { t -> goos := goos0 if arch == "wasm" { goos = "js" @@ -179,7 +179,7 @@ func s15a8(x *[15]int64) [15]int64 { return } - t.Run("Success", func { t | + t.Run("Success", func { t -> // This test is supposed to succeed // Note 'file://' is the I-Know-What-I-Am-Doing way of specifying a file, also to deal with corner cases for Windows. diff --git a/src/cmd/compile/internal/loong64/galign.go b/src/cmd/compile/internal/loong64/galign.go index 43c7528777585..2295949a26db9 100644 --- a/src/cmd/compile/internal/loong64/galign.go +++ b/src/cmd/compile/internal/loong64/galign.go @@ -17,7 +17,7 @@ func Init(arch *ssagen.ArchInfo) { arch.ZeroRange = zerorange arch.Ginsnop = ginsnop - arch.SSAMarkMoves = func { s, b | } + arch.SSAMarkMoves = func { s, b -> } arch.SSAGenValue = ssaGenValue arch.SSAGenBlock = ssaGenBlock arch.LoadRegResult = loadRegResult diff --git a/src/cmd/compile/internal/loopvar/loopvar.go b/src/cmd/compile/internal/loopvar/loopvar.go index fc0ba771c2d96..d0101bd8b55f9 100644 --- a/src/cmd/compile/internal/loopvar/loopvar.go +++ b/src/cmd/compile/internal/loopvar/loopvar.go @@ -127,7 +127,7 @@ func ForCapture(fn *ir.Func) []VarAndLoop { // This is all much simpler for range loops; 3-clause loops can have an arbitrary number // of iteration variables and the transformation is more involved, range loops have at most 2. var scanChildrenThenTransform func(x ir.Node) bool - scanChildrenThenTransform = func { n | + scanChildrenThenTransform = func { n -> if loopDepth > 0 { updateLastPos(n.Pos()) @@ -207,7 +207,7 @@ func ForCapture(fn *ir.Func) []VarAndLoop { loopDepth-- var leaked []*ir.Name // Collect the leaking variables for the much-more-complex transformation. - forAllDefInInit(x, func { z | + forAllDefInInit(x, func { z -> if n, ok := z.(*ir.Name); ok && possiblyLeaked[n] { desc := func { return describe(n) } // Hash on n.Pos() for most precise failure location. @@ -319,7 +319,7 @@ func ForCapture(fn *ir.Func) []VarAndLoop { loopLabel := x.Label loopDepth := 0 var editContinues func(x ir.Node) bool - editContinues = func { x | + editContinues = func { x -> switch c := x.(type) { case *ir.BranchStmt: @@ -343,7 +343,7 @@ func ForCapture(fn *ir.Func) []VarAndLoop { bodyContinue := x.Body // (4) rewrite init - forAllDefInInitUpdate(x, func { z, pz | + forAllDefInInitUpdate(x, func { z, pz -> // note tempFor[n] can be nil if hash searching. if n, ok := z.(*ir.Name); ok && possiblyLeaked[n] && zPrimeForZ[n] != nil { *pz = zPrimeForZ[n] @@ -469,13 +469,13 @@ func forAllDefInInitUpdate(x *ir.ForStmt, do func(z ir.Node, update *ir.Node)) { // forAllDefInInit is forAllDefInInitUpdate without the update option. func forAllDefInInit(x *ir.ForStmt, do func(z ir.Node)) { - forAllDefInInitUpdate(x, func { z, _ | do(z) }) + forAllDefInInitUpdate(x, func { z, _ -> do(z) }) } // rewriteNodes applies editNodes to all statement lists in fn. func rewriteNodes(fn *ir.Func, editNodes func(c ir.Nodes) ir.Nodes) { var forNodes func(x ir.Node) bool - forNodes = func { n | + forNodes = func { n -> if stmt, ok := n.(ir.InitNode); ok { // process init list stmt.SetInit(editNodes(stmt.Init())) diff --git a/src/cmd/compile/internal/mips/galign.go b/src/cmd/compile/internal/mips/galign.go index 693e59ccdb49f..71c17afce7ae1 100644 --- a/src/cmd/compile/internal/mips/galign.go +++ b/src/cmd/compile/internal/mips/galign.go @@ -21,7 +21,7 @@ func Init(arch *ssagen.ArchInfo) { arch.SoftFloat = (buildcfg.GOMIPS == "softfloat") arch.ZeroRange = zerorange arch.Ginsnop = ginsnop - arch.SSAMarkMoves = func { s, b | } + arch.SSAMarkMoves = func { s, b -> } arch.SSAGenValue = ssaGenValue arch.SSAGenBlock = ssaGenBlock } diff --git a/src/cmd/compile/internal/mips64/galign.go b/src/cmd/compile/internal/mips64/galign.go index cab9ed37d04e0..e7412b15d2855 100644 --- a/src/cmd/compile/internal/mips64/galign.go +++ b/src/cmd/compile/internal/mips64/galign.go @@ -22,7 +22,7 @@ func Init(arch *ssagen.ArchInfo) { arch.ZeroRange = zerorange arch.Ginsnop = ginsnop - arch.SSAMarkMoves = func { s, b | } + arch.SSAMarkMoves = func { s, b -> } arch.SSAGenValue = ssaGenValue arch.SSAGenBlock = ssaGenBlock } diff --git a/src/cmd/compile/internal/noder/irgen.go b/src/cmd/compile/internal/noder/irgen.go index 08ec1b43aad8b..4a428fb1e42fd 100644 --- a/src/cmd/compile/internal/noder/irgen.go +++ b/src/cmd/compile/internal/noder/irgen.go @@ -72,7 +72,7 @@ func checkFiles(m posMap, noders []*noder) (*types2.Package, *types2.Info, map[* FileVersions: make(map[*syntax.PosBase]string), // expand as needed } - conf.Error = func { err | + conf.Error = func { err -> terr := err.(types2.Error) msg := terr.Msg if versionErrorRx.MatchString(msg) { @@ -102,7 +102,7 @@ func checkFiles(m posMap, noders []*noder) (*types2.Package, *types2.Info, map[* // TODO(gri) move this code into the type checkers (types2 and go/types) var f cycleFinder for _, file := range files { - syntax.Inspect(file, func { n | + syntax.Inspect(file, func { n -> if n, ok := n.(*syntax.InterfaceType); ok { if f.hasCycle(types2.Unalias(n.GetTypeInfo().Type).(*types2.Interface)) { base.ErrorfAt(m.makeXPos(n.Pos()), errors.InvalidTypeCycle, "invalid recursive type: anonymous interface refers to itself (see https://go.dev/issue/56103)") @@ -134,7 +134,7 @@ func checkFiles(m posMap, noders []*noder) (*types2.Package, *types2.Info, map[* } } } - sort.Slice(nihTargs, func { i, j | + sort.Slice(nihTargs, func { i, j -> ti, tj := nihTargs[i], nihTargs[j] return ti.pos.Before(tj.pos) }) diff --git a/src/cmd/compile/internal/noder/reader.go b/src/cmd/compile/internal/noder/reader.go index 1acca4572b200..5fca349c5e677 100644 --- a/src/cmd/compile/internal/noder/reader.go +++ b/src/cmd/compile/internal/noder/reader.go @@ -3527,7 +3527,7 @@ func unifiedInlineCall(callerfn *ir.Func, call *ir.CallExpr, fn *ir.Func, inlInd // Replace any "return" statements within the function body. var edit func(ir.Node) ir.Node - edit = func { n | + edit = func { n -> if ret, ok := n.(*ir.ReturnStmt); ok { n = typecheck.Stmt(r.inlReturn(ret, retvars)) } @@ -3635,7 +3635,7 @@ func expandInline(fn *ir.Func, pri pkgReaderIndex) { // usedLocals returns a set of local variables that are used within body. func usedLocals(body []ir.Node) ir.NameSet { var used ir.NameSet - ir.VisitList(body, func { n | if n, ok := n.(*ir.Name); ok && n.Op() == ir.ONAME && n.Class == ir.PAUTO { + ir.VisitList(body, func { n -> if n, ok := n.(*ir.Name); ok && n.Op() == ir.ONAME && n.Class == ir.PAUTO { used.Add(n) } }) return used @@ -3915,7 +3915,7 @@ func finishWrapperFunc(fn *ir.Func, target *ir.Package) { // Further, after CL 492017, function that construct closures is allowed to be inlined, // even though the closure itself can't be inline. So we also need to visit body of any // closure that we see when visiting body of the wrapper function. - ir.VisitFuncAndClosures(fn, func { n | + ir.VisitFuncAndClosures(fn, func { n -> if n, ok := n.(*ir.SelectorExpr); ok && n.Op() == ir.OMETHVALUE { wrapMethodValue(n.X.Type(), n.Selection, target, true) } diff --git a/src/cmd/compile/internal/noder/unified.go b/src/cmd/compile/internal/noder/unified.go index 62c3a6096f8c1..c876a2b035556 100644 --- a/src/cmd/compile/internal/noder/unified.go +++ b/src/cmd/compile/internal/noder/unified.go @@ -501,7 +501,7 @@ func writeUnifiedExport(out io.Writer) { for _, idx := range l.decls { idxs = append(idxs, idx) } - sort.Slice(idxs, func { i, j | return idxs[i] < idxs[j] }) + sort.Slice(idxs, func { i, j -> return idxs[i] < idxs[j] }) w := publicRootWriter @@ -530,7 +530,7 @@ func writeUnifiedExport(out io.Writer) { for sym, idx := range l.bodies { bodies = append(bodies, symIdx{sym, idx}) } - sort.Slice(bodies, func { i, j | return bodies[i].idx < bodies[j].idx }) + sort.Slice(bodies, func { i, j -> return bodies[i].idx < bodies[j].idx }) w := privateRootWriter diff --git a/src/cmd/compile/internal/pgoir/irgraph.go b/src/cmd/compile/internal/pgoir/irgraph.go index 8afe4e23bd372..982c9794110d0 100644 --- a/src/cmd/compile/internal/pgoir/irgraph.go +++ b/src/cmd/compile/internal/pgoir/irgraph.go @@ -165,7 +165,7 @@ func createIRGraph(namedEdgeMap pgo.NamedEdgeMap) *IRGraph { } // Bottomup walk over the function to create IRGraph. - ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func { list, recursive | for _, fn := range list { + ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func { list, recursive -> for _, fn := range list { visitIR(fn, namedEdgeMap, g) } }) @@ -204,7 +204,7 @@ func visitIR(fn *ir.Func, namedEdgeMap pgo.NamedEdgeMap, g *IRGraph) { // between the callernode which points to the ir.Func and the nodes in the // body. func createIRGraphEdge(fn *ir.Func, callernode *IRNode, name string, namedEdgeMap pgo.NamedEdgeMap, g *IRGraph) { - ir.VisitList(fn.Body, func { n | + ir.VisitList(fn.Body, func { n -> switch n.Op() { case ir.OCALLFUNC: call := n.(*ir.CallExpr) @@ -404,7 +404,7 @@ func (p *Profile) PrintWeightedCallGraphDOT(edgeThreshold float64) { // List of functions in this package. funcs := make(map[string]struct{}) - ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func { list, recursive | for _, f := range list { + ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func { list, recursive -> for _, f := range list { name := ir.LinkFuncName(f) funcs[name] = struct{}{} } }) @@ -446,7 +446,7 @@ func (p *Profile) PrintWeightedCallGraphDOT(edgeThreshold float64) { } } // Print edges. - ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func { list, recursive | + ir.VisitFuncsBottomUp(typecheck.Target.Funcs, func { list, recursive -> for _, f := range list { name := ir.LinkFuncName(f) if n, ok := p.WeightedCG.IRNodes[name]; ok { diff --git a/src/cmd/compile/internal/rangefunc/rangefunc_test.go b/src/cmd/compile/internal/rangefunc/rangefunc_test.go index 190813cf607d8..93aed2bb2112e 100644 --- a/src/cmd/compile/internal/rangefunc/rangefunc_test.go +++ b/src/cmd/compile/internal/rangefunc/rangefunc_test.go @@ -184,7 +184,7 @@ const MISSING_PANIC = 4 // overload "READY" for panic call func Check2[U, V any](forall Seq2[U, V]) Seq2[U, V] { return func(body func(U, V) bool) { state := READY - forall(func { u, v | + forall(func { u, v -> if state != READY { panic(fail[state]) } @@ -207,7 +207,7 @@ func Check2[U, V any](forall Seq2[U, V]) Seq2[U, V] { func Check[U any](forall Seq[U]) Seq[U] { return func(body func(U) bool) { state := READY - forall(func { u | + forall(func { u -> if state != READY { panic(fail[state]) } @@ -1878,7 +1878,7 @@ func once[T any](x T) Seq[T] { // continue, or return). func terrify[T any](s string, forall Seq[T]) Seq[T] { return func(yield func(T) bool) { - forall(func { v | + forall(func { v -> if !yield(v) { panic(s) } diff --git a/src/cmd/compile/internal/rangefunc/rewrite.go b/src/cmd/compile/internal/rangefunc/rewrite.go index 602e1d28f7cea..ceb55f1092509 100644 --- a/src/cmd/compile/internal/rangefunc/rewrite.go +++ b/src/cmd/compile/internal/rangefunc/rewrite.go @@ -602,7 +602,7 @@ type State int func Rewrite(pkg *types2.Package, info *types2.Info, files []*syntax.File) map[*syntax.FuncLit]bool { ri := make(map[*syntax.FuncLit]bool) for _, file := range files { - syntax.Inspect(file, func { n | + syntax.Inspect(file, func { n -> switch n := n.(type) { case *syntax.FuncDecl: sig, _ := info.Defs[n.Name].Type().(*types2.Signature) @@ -983,7 +983,7 @@ func (r *rewriter) computeBranchNext() { var stack []syntax.Node var forStack []*syntax.ForStmt forStack = append(forStack, nil) - syntax.Inspect(r.body, func { n | + syntax.Inspect(r.body, func { n -> if n != nil { stack = append(stack, n) if nfor, ok := forRangeFunc(n); ok { @@ -1500,7 +1500,7 @@ func setPos(x syntax.Node, pos syntax.Pos) { if x == nil { return } - syntax.Inspect(x, func { n | + syntax.Inspect(x, func { n -> if n == nil || n.Pos() != nopos { return false } diff --git a/src/cmd/compile/internal/reflectdata/alg.go b/src/cmd/compile/internal/reflectdata/alg.go index 2b92a8180ec06..3325dcbe393f7 100644 --- a/src/cmd/compile/internal/reflectdata/alg.go +++ b/src/cmd/compile/internal/reflectdata/alg.go @@ -501,18 +501,18 @@ func eqFunc(t *types.Type) *ir.Func { case types.TSTRING: // Do two loops. First, check that all the lengths match (cheap). // Second, check that all the contents match (expensive). - checkAll(3, false, func { pi, qi | + checkAll(3, false, func { pi, qi -> // Compare lengths. eqlen, _ := compare.EqString(pi, qi) return eqlen }) - checkAll(1, true, func { pi, qi | + checkAll(1, true, func { pi, qi -> // Compare contents. _, eqmem := compare.EqString(pi, qi) return eqmem }) case types.TFLOAT32, types.TFLOAT64: - checkAll(2, true, func { pi, qi | + checkAll(2, true, func { pi, qi -> // p[i] == q[i] return ir.NewBinaryExpr(base.Pos, ir.OEQ, pi, qi) }) case types.TSTRUCT: @@ -546,11 +546,11 @@ func eqFunc(t *types.Type) *ir.Func { } } if !hasCallExprs || allCallExprs || canPanic { - checkAll(1, true, func { pi, qi | + checkAll(1, true, func { pi, qi -> // p[i] == q[i] return ir.NewBinaryExpr(base.Pos, ir.OEQ, pi, qi) }) } else { - checkAll(4, false, func { pi, qi | + checkAll(4, false, func { pi, qi -> expr = nil flatConds, _ := compare.EqStruct(t.Elem(), pi, qi) if len(flatConds) == 0 { @@ -563,7 +563,7 @@ func eqFunc(t *types.Type) *ir.Func { } return expr }) - checkAll(2, true, func { pi, qi | + checkAll(2, true, func { pi, qi -> expr = nil flatConds, _ := compare.EqStruct(t.Elem(), pi, qi) for _, c := range flatConds { @@ -575,7 +575,7 @@ func eqFunc(t *types.Type) *ir.Func { }) } default: - checkAll(1, true, func { pi, qi | + checkAll(1, true, func { pi, qi -> // p[i] == q[i] return ir.NewBinaryExpr(base.Pos, ir.OEQ, pi, qi) }) } @@ -652,7 +652,7 @@ func EqFor(t *types.Type) (ir.Node, bool) { } func anyCall(fn *ir.Func) bool { - return ir.Any(fn, func { n | + return ir.Any(fn, func { n -> // TODO(rsc): No methods? op := n.Op() return op == ir.OCALL || op == ir.OCALLFUNC diff --git a/src/cmd/compile/internal/reflectdata/reflect.go b/src/cmd/compile/internal/reflectdata/reflect.go index 89a02bf287a8a..116b310aad3df 100644 --- a/src/cmd/compile/internal/reflectdata/reflect.go +++ b/src/cmd/compile/internal/reflectdata/reflect.go @@ -573,7 +573,7 @@ func dextratype(lsym *obj.LSym, off int64, t *types.Type, dataAdd int) { if mcount != int(uint16(mcount)) { base.Fatalf("too many methods on %v: %d", t, mcount) } - xcount := sort.Search(mcount, func { i | return !types.IsExported(m[i].name.Name) }) + xcount := sort.Search(mcount, func { i -> return !types.IsExported(m[i].name.Name) }) if dataAdd != int(uint32(dataAdd)) { base.Fatalf("methods are too far away on %v: %d", t, dataAdd) } diff --git a/src/cmd/compile/internal/ssa/_gen/rulegen.go b/src/cmd/compile/internal/ssa/_gen/rulegen.go index 0fe75b675c2d4..e1ae4bfa4d4e8 100644 --- a/src/cmd/compile/internal/ssa/_gen/rulegen.go +++ b/src/cmd/compile/internal/ssa/_gen/rulegen.go @@ -1586,7 +1586,7 @@ func varCount(rr *RuleRewrite) map[string]int { if err != nil { log.Fatalf("%s: failed to parse cond %q: %v", rr.Loc, rr.Cond, err) } - ast.Inspect(expr, func { n | + ast.Inspect(expr, func { n -> if id, ok := n.(*ast.Ident); ok { cnt[id.Name]++ } diff --git a/src/cmd/compile/internal/ssa/branchelim_test.go b/src/cmd/compile/internal/ssa/branchelim_test.go index 42c959f420594..e7524b464fef5 100644 --- a/src/cmd/compile/internal/ssa/branchelim_test.go +++ b/src/cmd/compile/internal/ssa/branchelim_test.go @@ -22,7 +22,7 @@ func TestBranchElimIf(t *testing.T) { } for _, data := range testData { - t.Run(data.arch+"/"+data.intType, func { t | + t.Run(data.arch+"/"+data.intType, func { t -> c := testConfigArch(t, data.arch) boolType := c.config.Types.Bool var intType *types.Type @@ -82,7 +82,7 @@ func TestBranchElimIf(t *testing.T) { // Test that a trivial if/else is eliminated func TestBranchElimIfElse(t *testing.T) { for _, arch := range []string{"arm64", "amd64"} { - t.Run(arch, func { t | + t.Run(arch, func { t -> c := testConfigArch(t, arch) boolType := c.config.Types.Bool intType := c.config.Types.Int32 @@ -130,7 +130,7 @@ func TestBranchElimIfElse(t *testing.T) { // into itself does *not* get eliminated. func TestNoBranchElimLoop(t *testing.T) { for _, arch := range []string{"arm64", "amd64"} { - t.Run(arch, func { t | + t.Run(arch, func { t -> c := testConfigArch(t, arch) boolType := c.config.Types.Bool intType := c.config.Types.Int32 diff --git a/src/cmd/compile/internal/ssa/cache.go b/src/cmd/compile/internal/ssa/cache.go index efbfcae4eae67..4c73bace756eb 100644 --- a/src/cmd/compile/internal/ssa/cache.go +++ b/src/cmd/compile/internal/ssa/cache.go @@ -38,17 +38,17 @@ type Cache struct { } func (c *Cache) Reset() { - nv := sort.Search(len(c.values), func { i | return c.values[i].ID == 0 }) + nv := sort.Search(len(c.values), func { i -> return c.values[i].ID == 0 }) xv := c.values[:nv] for i := range xv { xv[i] = Value{} } - nb := sort.Search(len(c.blocks), func { i | return c.blocks[i].ID == 0 }) + nb := sort.Search(len(c.blocks), func { i -> return c.blocks[i].ID == 0 }) xb := c.blocks[:nb] for i := range xb { xb[i] = Block{} } - nl := sort.Search(len(c.locs), func { i | return c.locs[i] == nil }) + nl := sort.Search(len(c.locs), func { i -> return c.locs[i] == nil }) xl := c.locs[:nl] for i := range xl { xl[i] = nil diff --git a/src/cmd/compile/internal/ssa/deadcode.go b/src/cmd/compile/internal/ssa/deadcode.go index cc2f270c19dca..4a27a5a789291 100644 --- a/src/cmd/compile/internal/ssa/deadcode.go +++ b/src/cmd/compile/internal/ssa/deadcode.go @@ -267,7 +267,7 @@ func deadcode(f *Func) { } // Any boundary that failed to match a live value can move to a block end - pendingLines.foreachEntry(func { j, l, bi | + pendingLines.foreachEntry(func { j, l, bi -> b := f.Blocks[bi] if b.Pos.Line() == l && b.Pos.FileIndex() == j { b.Pos = b.Pos.WithIsStmt() diff --git a/src/cmd/compile/internal/ssa/deadcode_test.go b/src/cmd/compile/internal/ssa/deadcode_test.go index 18c208f406442..e85a6c458fef3 100644 --- a/src/cmd/compile/internal/ssa/deadcode_test.go +++ b/src/cmd/compile/internal/ssa/deadcode_test.go @@ -140,7 +140,7 @@ func TestNestedDeadBlocks(t *testing.T) { func BenchmarkDeadCode(b *testing.B) { for _, n := range [...]int{1, 10, 100, 1000, 10000, 100000, 200000} { - b.Run(strconv.Itoa(n), func { b | + b.Run(strconv.Itoa(n), func { b -> c := testConfig(b) blocks := make([]bloc, 0, n+2) blocks = append(blocks, diff --git a/src/cmd/compile/internal/ssa/debug_lines_test.go b/src/cmd/compile/internal/ssa/debug_lines_test.go index 113890ddbe040..96b595875e01b 100644 --- a/src/cmd/compile/internal/ssa/debug_lines_test.go +++ b/src/cmd/compile/internal/ssa/debug_lines_test.go @@ -175,7 +175,7 @@ func compileAndDump(t *testing.T, file, function, moreGCFlags string) []byte { } func sortInlineStacks(x [][]int) { - sort.Slice(x, func { i, j | + sort.Slice(x, func { i, j -> if len(x[i]) != len(x[j]) { return len(x[i]) < len(x[j]) } diff --git a/src/cmd/compile/internal/ssa/debug_test.go b/src/cmd/compile/internal/ssa/debug_test.go index e6671e648664e..a7f14525ae1be 100644 --- a/src/cmd/compile/internal/ssa/debug_test.go +++ b/src/cmd/compile/internal/ssa/debug_test.go @@ -178,7 +178,7 @@ func TestNexting(t *testing.T) { // subTest creates a subtest that compiles basename.go with the specified gcflags and additional compiler arguments, // then runs the debugger on the resulting binary, with any comment-specified actions matching tag triggered. func subTest(t *testing.T, tag string, basename string, gcflags string, moreargs ...string) { - t.Run(tag+"-"+basename, func { t | + t.Run(tag+"-"+basename, func { t -> if t.Name() == "TestNexting/gdb-dbg-i22558" { testenv.SkipFlaky(t, 31263) } @@ -188,7 +188,7 @@ func subTest(t *testing.T, tag string, basename string, gcflags string, moreargs // skipSubTest is the same as subTest except that it skips the test if execution is not forced (-f) func skipSubTest(t *testing.T, tag string, basename string, gcflags string, count int, moreargs ...string) { - t.Run(tag+"-"+basename, func { t | + t.Run(tag+"-"+basename, func { t -> if *force { testNexting(t, basename, tag, gcflags, count, moreargs...) } else { @@ -202,7 +202,7 @@ func skipSubTest(t *testing.T, tag string, basename string, gcflags string, coun func optSubTest(t *testing.T, tag string, basename string, gcflags string, count int, moreargs ...string) { // If optimized test is run with unoptimized libraries (compiled with -N -l), it is very likely to fail. // This occurs in the noopt builders (for example). - t.Run(tag+"-"+basename, func { t | + t.Run(tag+"-"+basename, func { t -> if *force || optimizedLibs { testNexting(t, basename, tag, gcflags, count, moreargs...) } else { @@ -668,7 +668,7 @@ func (s *gdbState) stepnext(ss string) bool { // Look for //gdb-=(v1,v2,v3) and print v1, v2, v3 vars := varsToPrint(excerpt, "//"+s.tag()+"=(") for _, v := range vars { - response := printVariableAndNormalize(v, func { v | return s.ioState.writeReadExpect("p "+v+"\n", "[(]gdb[)] ").String() }) + response := printVariableAndNormalize(v, func { v -> return s.ioState.writeReadExpect("p "+v+"\n", "[(]gdb[)] ").String() }) s.ioState.history.addVar(response) } return true diff --git a/src/cmd/compile/internal/ssa/decompose.go b/src/cmd/compile/internal/ssa/decompose.go index bd036e620cb5e..177f38266e18b 100644 --- a/src/cmd/compile/internal/ssa/decompose.go +++ b/src/cmd/compile/internal/ssa/decompose.go @@ -433,7 +433,7 @@ type namedVal struct { // removes all values with OpInvalid, and re-sorts the list of Names. func deleteNamedVals(f *Func, toDelete []namedVal) { // Arrange to delete from larger indices to smaller, to ensure swap-with-end deletion does not invalidate pending indices. - sort.Slice(toDelete, func { i, j | + sort.Slice(toDelete, func { i, j -> if toDelete[i].locIndex != toDelete[j].locIndex { return toDelete[i].locIndex > toDelete[j].locIndex } diff --git a/src/cmd/compile/internal/ssa/func_test.go b/src/cmd/compile/internal/ssa/func_test.go index bcd53cc704e08..5f63dc25981f8 100644 --- a/src/cmd/compile/internal/ssa/func_test.go +++ b/src/cmd/compile/internal/ssa/func_test.go @@ -54,7 +54,7 @@ import ( func Equiv(f, g *Func) bool { valcor := make(map[*Value]*Value) var checkVal func(fv, gv *Value) bool - checkVal = func { fv, gv | + checkVal = func { fv, gv -> if fv == nil && gv == nil { return true } @@ -87,7 +87,7 @@ func Equiv(f, g *Func) bool { } blkcor := make(map[*Block]*Block) var checkBlk func(fb, gb *Block) bool - checkBlk = func { fb, gb | + checkBlk = func { fb, gb -> if blkcor[fb] == nil && blkcor[gb] == nil { blkcor[fb] = gb blkcor[gb] = fb diff --git a/src/cmd/compile/internal/ssa/fuse_test.go b/src/cmd/compile/internal/ssa/fuse_test.go index c9bf8dee4a9cf..30f17531d86e1 100644 --- a/src/cmd/compile/internal/ssa/fuse_test.go +++ b/src/cmd/compile/internal/ssa/fuse_test.go @@ -269,7 +269,7 @@ func TestFuseSideEffects(t *testing.T) { func BenchmarkFuse(b *testing.B) { for _, n := range [...]int{1, 10, 100, 1000, 10000} { - b.Run(strconv.Itoa(n), func { b | + b.Run(strconv.Itoa(n), func { b -> c := testConfig(b) blocks := make([]bloc, 0, 2*n+3) diff --git a/src/cmd/compile/internal/ssa/memcombine.go b/src/cmd/compile/internal/ssa/memcombine.go index 8870c70a22a2b..9c27df04c80fa 100644 --- a/src/cmd/compile/internal/ssa/memcombine.go +++ b/src/cmd/compile/internal/ssa/memcombine.go @@ -232,7 +232,7 @@ func combineLoads(root *Value, n int64) bool { } // Sort in memory address order. - sort.Slice(r, func { i, j | return r[i].offset < r[j].offset }) + sort.Slice(r, func { i, j -> return r[i].offset < r[j].offset }) // Check that we have contiguous offsets. for i := int64(0); i < n; i++ { @@ -514,7 +514,7 @@ func combineStores(root *Value, n int64) bool { pos := a[n-1].store.Pos // Sort stores in increasing address order. - sort.Slice(a, func { i, j | return a[i].offset < a[j].offset }) + sort.Slice(a, func { i, j -> return a[i].offset < a[j].offset }) // Check that everything is written to sequential locations. for i := int64(0); i < n; i++ { diff --git a/src/cmd/compile/internal/ssa/poset.go b/src/cmd/compile/internal/ssa/poset.go index 42a0cbd425c45..b0f546dbe4b04 100644 --- a/src/cmd/compile/internal/ssa/poset.go +++ b/src/cmd/compile/internal/ssa/poset.go @@ -591,7 +591,7 @@ func (po *poset) dfs(r uint32, strict bool, f func(i uint32) bool) bool { // If strict == false: if the function returns true, then i1 <= i2. // If the function returns false, no relation is known. func (po *poset) reaches(i1, i2 uint32, strict bool) bool { - return po.dfs(i1, strict, func { n | return n == i2 }) + return po.dfs(i1, strict, func { n -> return n == i2 }) } // findroot finds i's root, that is which DAG contains i. @@ -750,7 +750,7 @@ func (po *poset) CheckIntegrity() { panic("empty root") } - po.dfs(r, false, func { i | + po.dfs(r, false, func { i -> if seen.Test(i) { panic("duplicate node") } @@ -846,7 +846,7 @@ func (po *poset) DotDump(fn string, title string) error { fmt.Fprintf(f, "\tedge [ fontsize=10 ]\n") for ridx, r := range po.roots { fmt.Fprintf(f, "\tsubgraph root%d {\n", ridx) - po.dfs(r, false, func { i | + po.dfs(r, false, func { i -> if val, ok := consts[i]; ok { // Constant var vals string diff --git a/src/cmd/compile/internal/ssa/schedule.go b/src/cmd/compile/internal/ssa/schedule.go index f9e3154acb39b..c815d4ae8e107 100644 --- a/src/cmd/compile/internal/ssa/schedule.go +++ b/src/cmd/compile/internal/ssa/schedule.go @@ -260,7 +260,7 @@ func schedule(f *Func) { } // Sort all the edges by source Value ID. - sort.Slice(edges, func { i, j | return edges[i].x.ID < edges[j].x.ID }) + sort.Slice(edges, func { i, j -> return edges[i].x.ID < edges[j].x.ID }) // Compute inEdges for values in this block. for _, e := range edges { inEdges[e.y.ID]++ @@ -285,8 +285,8 @@ func schedule(f *Func) { b.Values = append(b.Values, v) // Find all the scheduling edges out from this value. - i := sort.Search(len(edges), func { i | return edges[i].x.ID >= v.ID }) - j := sort.Search(len(edges), func { i | return edges[i].x.ID > v.ID }) + i := sort.Search(len(edges), func { i -> return edges[i].x.ID >= v.ID }) + j := sort.Search(len(edges), func { i -> return edges[i].x.ID > v.ID }) // Decrement inEdges for each target of edges from v. for _, e := range edges[i:j] { inEdges[e.y.ID]-- diff --git a/src/cmd/compile/internal/ssa/stmtlines_test.go b/src/cmd/compile/internal/ssa/stmtlines_test.go index 62fbf55763f08..41c2370be1aa7 100644 --- a/src/cmd/compile/internal/ssa/stmtlines_test.go +++ b/src/cmd/compile/internal/ssa/stmtlines_test.go @@ -144,7 +144,7 @@ func TestStmtLines(t *testing.T) { } t.Logf("Saw %d out of %d lines without statement marks", len(nonStmtLines), len(lines)) if testing.Verbose() { - sort.Slice(nonStmtLines, func { i, j | + sort.Slice(nonStmtLines, func { i, j -> if nonStmtLines[i].File != nonStmtLines[j].File { return nonStmtLines[i].File < nonStmtLines[j].File } diff --git a/src/cmd/compile/internal/ssagen/pgen.go b/src/cmd/compile/internal/ssagen/pgen.go index 8a9d538d95fcd..c8d3ff77768b5 100644 --- a/src/cmd/compile/internal/ssagen/pgen.go +++ b/src/cmd/compile/internal/ssagen/pgen.go @@ -181,7 +181,7 @@ func (s *ssafn) AllocFrame(f *ssa.Func) { // Use sort.SliceStable instead of sort.Slice so stack layout (and thus // compiler output) is less sensitive to frontend changes that // introduce or remove unused variables. - sort.SliceStable(fn.Dcl, func { i, j | return cmpstackvarlt(fn.Dcl[i], fn.Dcl[j], mls) }) + sort.SliceStable(fn.Dcl, func { i, j -> return cmpstackvarlt(fn.Dcl[i], fn.Dcl[j], mls) }) if mls != nil { // Rewrite fn.Dcl to reposition followers (subsumed vars) to @@ -412,7 +412,7 @@ func fieldtrack(fnsym *obj.LSym, tracked map[*obj.LSym]struct{}) { for sym := range tracked { trackSyms = append(trackSyms, sym) } - sort.Slice(trackSyms, func { i, j | return trackSyms[i].Name < trackSyms[j].Name }) + sort.Slice(trackSyms, func { i, j -> return trackSyms[i].Name < trackSyms[j].Name }) for _, sym := range trackSyms { r := obj.Addrel(fnsym) r.Sym = sym @@ -435,7 +435,7 @@ var ( func CheckLargeStacks() { // Check whether any of the functions we have compiled have gigantic stack frames. - sort.Slice(largeStackFrames, func { i, j | return largeStackFrames[i].pos.Before(largeStackFrames[j].pos) }) + sort.Slice(largeStackFrames, func { i, j -> return largeStackFrames[i].pos.Before(largeStackFrames[j].pos) }) for _, large := range largeStackFrames { if large.callee != 0 { base.ErrorfAt(large.pos, 0, "stack frame too large (>1GB): %d MB locals + %d MB args + %d MB callee", large.locals>>20, large.args>>20, large.callee>>20) diff --git a/src/cmd/compile/internal/ssagen/ssa.go b/src/cmd/compile/internal/ssagen/ssa.go index 39a9da59f7ed5..04aaeb6935778 100644 --- a/src/cmd/compile/internal/ssagen/ssa.go +++ b/src/cmd/compile/internal/ssagen/ssa.go @@ -3739,7 +3739,7 @@ func (s *state) minMax(n *ir.CallExpr) *ssa.Value { case typ.Kind() == types.TFLOAT32 && n.Op() == ir.OMAX: op = ssa.OpMax32F } - return fold(func { x, a | return s.newValue2(op, typ, x, a) }) + return fold(func { x, a -> return s.newValue2(op, typ, x, a) }) } } var name string @@ -3768,12 +3768,12 @@ func (s *state) minMax(n *ir.CallExpr) *ssa.Value { } fn := typecheck.LookupRuntimeFunc(name) - return fold(func { x, a | return s.rtcall(fn, true, []*types.Type{typ}, x, a)[0] }) + return fold(func { x, a -> return s.rtcall(fn, true, []*types.Type{typ}, x, a)[0] }) } lt := s.ssaOp(ir.OLT, typ) - return fold(func { x, a | + return fold(func { x, a -> switch n.Op() { case ir.OMIN: // a < x ? a : x @@ -4229,7 +4229,7 @@ func InitTables() { /******** runtime ********/ if !base.Flag.Cfg.Instrumenting { add("runtime", "slicebytetostringtmp", - func { s, n, args | + func { s, n, args -> // Compiler frontend optimizations emit OBYTES2STRTMP nodes // for the backend instead of slicebytetostringtmp calls // when not instrumenting. @@ -4237,7 +4237,7 @@ func InitTables() { all...) } addF("runtime/internal/math", "MulUintptr", - func { s, n, args | + func { s, n, args -> if s.config.PtrSize == 4 { return s.newValue2(ssa.OpMul32uover, types.NewTuple(types.Types[types.TUINT], types.Types[types.TUINT]), args[0], args[1]) } @@ -4245,26 +4245,26 @@ func InitTables() { }, sys.AMD64, sys.I386, sys.Loong64, sys.MIPS64, sys.RISCV64, sys.ARM64) add("runtime", "KeepAlive", - func { s, n, args | + func { s, n, args -> data := s.newValue1(ssa.OpIData, s.f.Config.Types.BytePtr, args[0]) s.vars[memVar] = s.newValue2(ssa.OpKeepAlive, types.TypeMem, data, s.mem()) return nil }, all...) add("runtime", "getclosureptr", - func { s, n, args | return s.newValue0(ssa.OpGetClosurePtr, s.f.Config.Types.Uintptr) }, + func { s, n, args -> return s.newValue0(ssa.OpGetClosurePtr, s.f.Config.Types.Uintptr) }, all...) add("runtime", "getcallerpc", - func { s, n, args | return s.newValue0(ssa.OpGetCallerPC, s.f.Config.Types.Uintptr) }, + func { s, n, args -> return s.newValue0(ssa.OpGetCallerPC, s.f.Config.Types.Uintptr) }, all...) add("runtime", "getcallersp", - func { s, n, args | return s.newValue1(ssa.OpGetCallerSP, s.f.Config.Types.Uintptr, s.mem()) }, + func { s, n, args -> return s.newValue1(ssa.OpGetCallerSP, s.f.Config.Types.Uintptr, s.mem()) }, all...) addF("runtime", "publicationBarrier", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue1(ssa.OpPubBarrier, types.TypeMem, s.mem()) return nil }, @@ -4278,10 +4278,10 @@ func InitTables() { } /******** runtime/internal/sys ********/ addF("runtime/internal/sys", "Bswap32", - func { s, n, args | return s.newValue1(ssa.OpBswap32, types.Types[types.TUINT32], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBswap32, types.Types[types.TUINT32], args[0]) }, brev_arch...) addF("runtime/internal/sys", "Bswap64", - func { s, n, args | return s.newValue1(ssa.OpBswap64, types.Types[types.TUINT64], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBswap64, types.Types[types.TUINT64], args[0]) }, brev_arch...) /****** Prefetch ******/ @@ -4301,42 +4301,42 @@ func InitTables() { /******** internal/runtime/atomic ********/ addF("internal/runtime/atomic", "Load", - func { s, n, args | + func { s, n, args -> v := s.newValue2(ssa.OpAtomicLoad32, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT32], v) }, sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Load8", - func { s, n, args | + func { s, n, args -> v := s.newValue2(ssa.OpAtomicLoad8, types.NewTuple(types.Types[types.TUINT8], types.TypeMem), args[0], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT8], v) }, sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Load64", - func { s, n, args | + func { s, n, args -> v := s.newValue2(ssa.OpAtomicLoad64, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT64], v) }, sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "LoadAcq", - func { s, n, args | + func { s, n, args -> v := s.newValue2(ssa.OpAtomicLoadAcq32, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT32], v) }, sys.PPC64, sys.S390X) addF("internal/runtime/atomic", "LoadAcq64", - func { s, n, args | + func { s, n, args -> v := s.newValue2(ssa.OpAtomicLoadAcq64, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT64], v) }, sys.PPC64) addF("internal/runtime/atomic", "Loadp", - func { s, n, args | + func { s, n, args -> v := s.newValue2(ssa.OpAtomicLoadPtr, types.NewTuple(s.f.Config.Types.BytePtr, types.TypeMem), args[0], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, s.f.Config.Types.BytePtr, v) @@ -4344,51 +4344,51 @@ func InitTables() { sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Store", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicStore32, types.TypeMem, args[0], args[1], s.mem()) return nil }, sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Store8", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicStore8, types.TypeMem, args[0], args[1], s.mem()) return nil }, sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Store64", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicStore64, types.TypeMem, args[0], args[1], s.mem()) return nil }, sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "StorepNoWB", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicStorePtrNoWB, types.TypeMem, args[0], args[1], s.mem()) return nil }, sys.AMD64, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "StoreRel", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicStoreRel32, types.TypeMem, args[0], args[1], s.mem()) return nil }, sys.PPC64, sys.S390X) addF("internal/runtime/atomic", "StoreRel64", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicStoreRel64, types.TypeMem, args[0], args[1], s.mem()) return nil }, sys.PPC64) addF("internal/runtime/atomic", "Xchg", - func { s, n, args | + func { s, n, args -> v := s.newValue3(ssa.OpAtomicExchange32, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], args[1], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT32], v) }, sys.AMD64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Xchg64", - func { s, n, args | + func { s, n, args -> v := s.newValue3(ssa.OpAtomicExchange64, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], args[1], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT64], v) @@ -4450,14 +4450,14 @@ func InitTables() { sys.ARM64) addF("internal/runtime/atomic", "Xadd", - func { s, n, args | + func { s, n, args -> v := s.newValue3(ssa.OpAtomicAdd32, types.NewTuple(types.Types[types.TUINT32], types.TypeMem), args[0], args[1], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT32], v) }, sys.AMD64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Xadd64", - func { s, n, args | + func { s, n, args -> v := s.newValue3(ssa.OpAtomicAdd64, types.NewTuple(types.Types[types.TUINT64], types.TypeMem), args[0], args[1], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TUINT64], v) @@ -4472,21 +4472,21 @@ func InitTables() { sys.ARM64) addF("internal/runtime/atomic", "Cas", - func { s, n, args | + func { s, n, args -> v := s.newValue4(ssa.OpAtomicCompareAndSwap32, types.NewTuple(types.Types[types.TBOOL], types.TypeMem), args[0], args[1], args[2], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TBOOL], v) }, sys.AMD64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Cas64", - func { s, n, args | + func { s, n, args -> v := s.newValue4(ssa.OpAtomicCompareAndSwap64, types.NewTuple(types.Types[types.TBOOL], types.TypeMem), args[0], args[1], args[2], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TBOOL], v) }, sys.AMD64, sys.Loong64, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "CasRel", - func { s, n, args | + func { s, n, args -> v := s.newValue4(ssa.OpAtomicCompareAndSwap32, types.NewTuple(types.Types[types.TBOOL], types.TypeMem), args[0], args[1], args[2], s.mem()) s.vars[memVar] = s.newValue1(ssa.OpSelect1, types.TypeMem, v) return s.newValue1(ssa.OpSelect0, types.Types[types.TBOOL], v) @@ -4507,25 +4507,25 @@ func InitTables() { sys.ARM64) addF("internal/runtime/atomic", "And8", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicAnd8, types.TypeMem, args[0], args[1], s.mem()) return nil }, sys.AMD64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "And", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicAnd32, types.TypeMem, args[0], args[1], s.mem()) return nil }, sys.AMD64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Or8", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicOr8, types.TypeMem, args[0], args[1], s.mem()) return nil }, sys.AMD64, sys.ARM64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X) addF("internal/runtime/atomic", "Or", - func { s, n, args | + func { s, n, args -> s.vars[memVar] = s.newValue3(ssa.OpAtomicOr32, types.TypeMem, args[0], args[1], s.mem()) return nil }, @@ -4609,34 +4609,34 @@ func InitTables() { /******** math ********/ addF("math", "sqrt", - func { s, n, args | return s.newValue1(ssa.OpSqrt, types.Types[types.TFLOAT64], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpSqrt, types.Types[types.TFLOAT64], args[0]) }, sys.I386, sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.MIPS, sys.MIPS64, sys.PPC64, sys.RISCV64, sys.S390X, sys.Wasm) addF("math", "Trunc", - func { s, n, args | return s.newValue1(ssa.OpTrunc, types.Types[types.TFLOAT64], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpTrunc, types.Types[types.TFLOAT64], args[0]) }, sys.ARM64, sys.PPC64, sys.S390X, sys.Wasm) addF("math", "Ceil", - func { s, n, args | return s.newValue1(ssa.OpCeil, types.Types[types.TFLOAT64], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpCeil, types.Types[types.TFLOAT64], args[0]) }, sys.ARM64, sys.PPC64, sys.S390X, sys.Wasm) addF("math", "Floor", - func { s, n, args | return s.newValue1(ssa.OpFloor, types.Types[types.TFLOAT64], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpFloor, types.Types[types.TFLOAT64], args[0]) }, sys.ARM64, sys.PPC64, sys.S390X, sys.Wasm) addF("math", "Round", - func { s, n, args | return s.newValue1(ssa.OpRound, types.Types[types.TFLOAT64], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpRound, types.Types[types.TFLOAT64], args[0]) }, sys.ARM64, sys.PPC64, sys.S390X) addF("math", "RoundToEven", - func { s, n, args | return s.newValue1(ssa.OpRoundToEven, types.Types[types.TFLOAT64], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpRoundToEven, types.Types[types.TFLOAT64], args[0]) }, sys.ARM64, sys.S390X, sys.Wasm) addF("math", "Abs", - func { s, n, args | return s.newValue1(ssa.OpAbs, types.Types[types.TFLOAT64], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpAbs, types.Types[types.TFLOAT64], args[0]) }, sys.ARM64, sys.ARM, sys.PPC64, sys.RISCV64, sys.Wasm, sys.MIPS, sys.MIPS64) addF("math", "Copysign", - func { s, n, args | return s.newValue2(ssa.OpCopysign, types.Types[types.TFLOAT64], args[0], args[1]) }, + func { s, n, args -> return s.newValue2(ssa.OpCopysign, types.Types[types.TFLOAT64], args[0], args[1]) }, sys.PPC64, sys.RISCV64, sys.Wasm) addF("math", "FMA", - func { s, n, args | return s.newValue3(ssa.OpFMA, types.Types[types.TFLOAT64], args[0], args[1], args[2]) }, + func { s, n, args -> return s.newValue3(ssa.OpFMA, types.Types[types.TFLOAT64], args[0], args[1], args[2]) }, sys.ARM64, sys.PPC64, sys.RISCV64, sys.S390X) addF("math", "FMA", - func { s, n, args | + func { s, n, args -> if !s.config.UseFMA { s.vars[n] = s.callResult(n, callNormal) // types.Types[TFLOAT64] return s.variable(n, types.Types[types.TFLOAT64]) @@ -4673,7 +4673,7 @@ func InitTables() { }, sys.AMD64) addF("math", "FMA", - func { s, n, args | + func { s, n, args -> if !s.config.UseFMA { s.vars[n] = s.callResult(n, callNormal) // types.Types[TFLOAT64] return s.variable(n, types.Types[types.TFLOAT64]) @@ -4753,13 +4753,13 @@ func InitTables() { /******** math/bits ********/ addF("math/bits", "TrailingZeros64", - func { s, n, args | return s.newValue1(ssa.OpCtz64, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpCtz64, types.Types[types.TINT], args[0]) }, sys.AMD64, sys.I386, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS, sys.PPC64, sys.Wasm) addF("math/bits", "TrailingZeros32", - func { s, n, args | return s.newValue1(ssa.OpCtz32, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpCtz32, types.Types[types.TINT], args[0]) }, sys.AMD64, sys.I386, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS, sys.PPC64, sys.Wasm) addF("math/bits", "TrailingZeros16", - func { s, n, args | + func { s, n, args -> x := s.newValue1(ssa.OpZeroExt16to32, types.Types[types.TUINT32], args[0]) c := s.constInt32(types.Types[types.TUINT32], 1<<16) y := s.newValue2(ssa.OpOr32, types.Types[types.TUINT32], x, c) @@ -4767,10 +4767,10 @@ func InitTables() { }, sys.MIPS) addF("math/bits", "TrailingZeros16", - func { s, n, args | return s.newValue1(ssa.OpCtz16, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpCtz16, types.Types[types.TINT], args[0]) }, sys.AMD64, sys.I386, sys.ARM, sys.ARM64, sys.Wasm) addF("math/bits", "TrailingZeros16", - func { s, n, args | + func { s, n, args -> x := s.newValue1(ssa.OpZeroExt16to64, types.Types[types.TUINT64], args[0]) c := s.constInt64(types.Types[types.TUINT64], 1<<16) y := s.newValue2(ssa.OpOr64, types.Types[types.TUINT64], x, c) @@ -4778,7 +4778,7 @@ func InitTables() { }, sys.S390X, sys.PPC64) addF("math/bits", "TrailingZeros8", - func { s, n, args | + func { s, n, args -> x := s.newValue1(ssa.OpZeroExt8to32, types.Types[types.TUINT32], args[0]) c := s.constInt32(types.Types[types.TUINT32], 1<<8) y := s.newValue2(ssa.OpOr32, types.Types[types.TUINT32], x, c) @@ -4786,10 +4786,10 @@ func InitTables() { }, sys.MIPS) addF("math/bits", "TrailingZeros8", - func { s, n, args | return s.newValue1(ssa.OpCtz8, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpCtz8, types.Types[types.TINT], args[0]) }, sys.AMD64, sys.I386, sys.ARM, sys.ARM64, sys.Wasm) addF("math/bits", "TrailingZeros8", - func { s, n, args | + func { s, n, args -> x := s.newValue1(ssa.OpZeroExt8to64, types.Types[types.TUINT64], args[0]) c := s.constInt64(types.Types[types.TUINT64], 1<<8) y := s.newValue2(ssa.OpOr64, types.Types[types.TUINT64], x, c) @@ -4803,18 +4803,18 @@ func InitTables() { // On Power10, 16-bit rotate is not available so use BRH instruction if buildcfg.GOPPC64 >= 10 { addF("math/bits", "ReverseBytes16", - func { s, n, args | return s.newValue1(ssa.OpBswap16, types.Types[types.TUINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBswap16, types.Types[types.TUINT], args[0]) }, sys.PPC64) } addF("math/bits", "Len64", - func { s, n, args | return s.newValue1(ssa.OpBitLen64, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBitLen64, types.Types[types.TINT], args[0]) }, sys.AMD64, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS, sys.PPC64, sys.Wasm) addF("math/bits", "Len32", - func { s, n, args | return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], args[0]) }, sys.AMD64, sys.ARM64, sys.PPC64) addF("math/bits", "Len32", - func { s, n, args | + func { s, n, args -> if s.config.PtrSize == 4 { return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], args[0]) } @@ -4823,7 +4823,7 @@ func InitTables() { }, sys.ARM, sys.S390X, sys.MIPS, sys.Wasm) addF("math/bits", "Len16", - func { s, n, args | + func { s, n, args -> if s.config.PtrSize == 4 { x := s.newValue1(ssa.OpZeroExt16to32, types.Types[types.TUINT32], args[0]) return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], x) @@ -4833,10 +4833,10 @@ func InitTables() { }, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS, sys.PPC64, sys.Wasm) addF("math/bits", "Len16", - func { s, n, args | return s.newValue1(ssa.OpBitLen16, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBitLen16, types.Types[types.TINT], args[0]) }, sys.AMD64) addF("math/bits", "Len8", - func { s, n, args | + func { s, n, args -> if s.config.PtrSize == 4 { x := s.newValue1(ssa.OpZeroExt8to32, types.Types[types.TUINT32], args[0]) return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], x) @@ -4846,10 +4846,10 @@ func InitTables() { }, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS, sys.PPC64, sys.Wasm) addF("math/bits", "Len8", - func { s, n, args | return s.newValue1(ssa.OpBitLen8, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBitLen8, types.Types[types.TINT], args[0]) }, sys.AMD64) addF("math/bits", "Len", - func { s, n, args | + func { s, n, args -> if s.config.PtrSize == 4 { return s.newValue1(ssa.OpBitLen32, types.Types[types.TINT], args[0]) } @@ -4858,31 +4858,31 @@ func InitTables() { sys.AMD64, sys.ARM64, sys.ARM, sys.S390X, sys.MIPS, sys.PPC64, sys.Wasm) // LeadingZeros is handled because it trivially calls Len. addF("math/bits", "Reverse64", - func { s, n, args | return s.newValue1(ssa.OpBitRev64, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBitRev64, types.Types[types.TINT], args[0]) }, sys.ARM64) addF("math/bits", "Reverse32", - func { s, n, args | return s.newValue1(ssa.OpBitRev32, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBitRev32, types.Types[types.TINT], args[0]) }, sys.ARM64) addF("math/bits", "Reverse16", - func { s, n, args | return s.newValue1(ssa.OpBitRev16, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBitRev16, types.Types[types.TINT], args[0]) }, sys.ARM64) addF("math/bits", "Reverse8", - func { s, n, args | return s.newValue1(ssa.OpBitRev8, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBitRev8, types.Types[types.TINT], args[0]) }, sys.ARM64) addF("math/bits", "Reverse", - func { s, n, args | return s.newValue1(ssa.OpBitRev64, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpBitRev64, types.Types[types.TINT], args[0]) }, sys.ARM64) addF("math/bits", "RotateLeft8", - func { s, n, args | return s.newValue2(ssa.OpRotateLeft8, types.Types[types.TUINT8], args[0], args[1]) }, + func { s, n, args -> return s.newValue2(ssa.OpRotateLeft8, types.Types[types.TUINT8], args[0], args[1]) }, sys.AMD64, sys.RISCV64) addF("math/bits", "RotateLeft16", - func { s, n, args | return s.newValue2(ssa.OpRotateLeft16, types.Types[types.TUINT16], args[0], args[1]) }, + func { s, n, args -> return s.newValue2(ssa.OpRotateLeft16, types.Types[types.TUINT16], args[0], args[1]) }, sys.AMD64, sys.RISCV64) addF("math/bits", "RotateLeft32", - func { s, n, args | return s.newValue2(ssa.OpRotateLeft32, types.Types[types.TUINT32], args[0], args[1]) }, + func { s, n, args -> return s.newValue2(ssa.OpRotateLeft32, types.Types[types.TUINT32], args[0], args[1]) }, sys.AMD64, sys.ARM, sys.ARM64, sys.Loong64, sys.PPC64, sys.RISCV64, sys.S390X, sys.Wasm) addF("math/bits", "RotateLeft64", - func { s, n, args | return s.newValue2(ssa.OpRotateLeft64, types.Types[types.TUINT64], args[0], args[1]) }, + func { s, n, args -> return s.newValue2(ssa.OpRotateLeft64, types.Types[types.TUINT64], args[0], args[1]) }, sys.AMD64, sys.ARM64, sys.Loong64, sys.PPC64, sys.RISCV64, sys.S390X, sys.Wasm) alias("math/bits", "RotateLeft", "math/bits", "RotateLeft64", p8...) @@ -4922,48 +4922,48 @@ func InitTables() { makeOnesCountAMD64(ssa.OpPopCount64), sys.AMD64) addF("math/bits", "OnesCount64", - func { s, n, args | return s.newValue1(ssa.OpPopCount64, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpPopCount64, types.Types[types.TINT], args[0]) }, sys.PPC64, sys.ARM64, sys.S390X, sys.Wasm) addF("math/bits", "OnesCount32", makeOnesCountAMD64(ssa.OpPopCount32), sys.AMD64) addF("math/bits", "OnesCount32", - func { s, n, args | return s.newValue1(ssa.OpPopCount32, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpPopCount32, types.Types[types.TINT], args[0]) }, sys.PPC64, sys.ARM64, sys.S390X, sys.Wasm) addF("math/bits", "OnesCount16", makeOnesCountAMD64(ssa.OpPopCount16), sys.AMD64) addF("math/bits", "OnesCount16", - func { s, n, args | return s.newValue1(ssa.OpPopCount16, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpPopCount16, types.Types[types.TINT], args[0]) }, sys.ARM64, sys.S390X, sys.PPC64, sys.Wasm) addF("math/bits", "OnesCount8", - func { s, n, args | return s.newValue1(ssa.OpPopCount8, types.Types[types.TINT], args[0]) }, + func { s, n, args -> return s.newValue1(ssa.OpPopCount8, types.Types[types.TINT], args[0]) }, sys.S390X, sys.PPC64, sys.Wasm) addF("math/bits", "OnesCount", makeOnesCountAMD64(ssa.OpPopCount64), sys.AMD64) addF("math/bits", "Mul64", - func { s, n, args | + func { s, n, args -> return s.newValue2(ssa.OpMul64uhilo, types.NewTuple(types.Types[types.TUINT64], types.Types[types.TUINT64]), args[0], args[1]) }, sys.AMD64, sys.ARM64, sys.PPC64, sys.S390X, sys.MIPS64, sys.RISCV64, sys.Loong64) alias("math/bits", "Mul", "math/bits", "Mul64", p8...) alias("runtime/internal/math", "Mul64", "math/bits", "Mul64", p8...) addF("math/bits", "Add64", - func { s, n, args | + func { s, n, args -> return s.newValue3(ssa.OpAdd64carry, types.NewTuple(types.Types[types.TUINT64], types.Types[types.TUINT64]), args[0], args[1], args[2]) }, sys.AMD64, sys.ARM64, sys.PPC64, sys.S390X, sys.RISCV64, sys.Loong64, sys.MIPS64) alias("math/bits", "Add", "math/bits", "Add64", p8...) alias("runtime/internal/math", "Add64", "math/bits", "Add64", all...) addF("math/bits", "Sub64", - func { s, n, args | + func { s, n, args -> return s.newValue3(ssa.OpSub64borrow, types.NewTuple(types.Types[types.TUINT64], types.Types[types.TUINT64]), args[0], args[1], args[2]) }, sys.AMD64, sys.ARM64, sys.PPC64, sys.S390X, sys.RISCV64, sys.Loong64, sys.MIPS64) alias("math/bits", "Sub", "math/bits", "Sub64", p8...) addF("math/bits", "Div64", - func { s, n, args | + func { s, n, args -> // check for divide-by-zero/overflow and panic with appropriate message cmpZero := s.newValue2(s.ssaOp(ir.ONE, types.Types[types.TUINT64]), types.Types[types.TBOOL], args[2], s.zeroVal(types.Types[types.TUINT64])) s.check(cmpZero, ir.Syms.Panicdivide) @@ -7097,7 +7097,7 @@ func EmitArgInfo(f *ir.Func, abiInfo *abi.ABIParamResultInfo) *obj.LSym { // Visit t recursively and write it out. // Returns whether to continue visiting. var visitType func(baseOffset int64, t *types.Type, depth int) bool - visitType = func { baseOffset, t, depth | + visitType = func { baseOffset, t, depth -> if n >= rtabi.TraceArgsLimit { writebyte(rtabi.TraceArgsDotdotdot) return false @@ -7184,7 +7184,7 @@ func emitWrappedFuncInfo(e *ssafn, pp *objw.Progs) { } wsym := wfn.Linksym() - x := base.Ctxt.LookupInit(fmt.Sprintf("%s.wrapinfo", wsym.Name), func { x | + x := base.Ctxt.LookupInit(fmt.Sprintf("%s.wrapinfo", wsym.Name), func { x -> objw.SymPtrOff(x, 0, wsym) x.Set(obj.AttrContentAddressable, true) }) @@ -7567,7 +7567,7 @@ func genssa(f *ssa.Func, pp *objw.Progs) { // Register a callback that will be used later to fill in PCs into location // lists. At the moment, Prog.Pc is a sequence number; it's not a real PC // until after assembly, so the translation needs to be deferred. - debugInfo.GetPC = func { b, v | + debugInfo.GetPC = func { b, v -> switch v { case ssa.BlockStart.ID: if b == f.Entry.ID { @@ -7687,7 +7687,7 @@ func genssa(f *ssa.Func, pp *objw.Progs) { for p := s.pp.Text; p != nil; p = p.Link { if p.Pos.IsKnown() { allPos = allPos[:0] - p.Ctxt.AllPos(p.Pos, func { pos | allPos = append(allPos, pos) }) + p.Ctxt.AllPos(p.Pos, func { pos -> allPos = append(allPos, pos) }) if inliningDiffers(allPos, allPosOld) { for _, pos := range allPos { fmt.Fprintf(fi, "# %s:%d\n", pos.Filename(), pos.Line()) diff --git a/src/cmd/compile/internal/staticdata/data.go b/src/cmd/compile/internal/staticdata/data.go index e62dcabf548e0..a74d47a9fcf9d 100644 --- a/src/cmd/compile/internal/staticdata/data.go +++ b/src/cmd/compile/internal/staticdata/data.go @@ -264,7 +264,7 @@ func GlobalLinksym(n *ir.Name) *obj.LSym { } func WriteFuncSyms() { - sort.Slice(funcsyms, func { i, j | return funcsyms[i].Linksym().Name < funcsyms[j].Linksym().Name }) + sort.Slice(funcsyms, func { i, j -> return funcsyms[i].Linksym().Name < funcsyms[j].Linksym().Name }) for _, nam := range funcsyms { s := nam.Sym() sf := s.Pkg.Lookup(ir.FuncSymName(s)).Linksym() diff --git a/src/cmd/compile/internal/staticdata/embed.go b/src/cmd/compile/internal/staticdata/embed.go index f68efe10a535b..c8adde2545447 100644 --- a/src/cmd/compile/internal/staticdata/embed.go +++ b/src/cmd/compile/internal/staticdata/embed.go @@ -51,7 +51,7 @@ func embedFileList(v *ir.Name, kind int) []string { } } } - sort.Slice(list, func { i, j | return embedFileLess(list[i], list[j]) }) + sort.Slice(list, func { i, j -> return embedFileLess(list[i], list[j]) }) if kind == embedString || kind == embedBytes { if len(list) > 1 { diff --git a/src/cmd/compile/internal/staticinit/sched.go b/src/cmd/compile/internal/staticinit/sched.go index ad63ffb58728d..a3ceab120a292 100644 --- a/src/cmd/compile/internal/staticinit/sched.go +++ b/src/cmd/compile/internal/staticinit/sched.go @@ -675,7 +675,7 @@ func (s *Schedule) staticAssignInlinedCall(l *ir.Name, loff int64, call *ir.Inli } hasNonTrivialClosure := false - ir.Visit(as2body.Rhs[0], func { n | + ir.Visit(as2body.Rhs[0], func { n -> if name, ok := n.(*ir.Name); ok { if c, ok := count[name]; ok { count[name] = c + 1 @@ -905,7 +905,7 @@ func mayModifyPkgVar(n ir.Node) bool { return ok && v.Op() == ir.ONAME && !(v.Class == ir.PEXTERN && v.Sym().Pkg == types.LocalPkg) } - return ir.Any(n, func { n | + return ir.Any(n, func { n -> switch n.Op() { case ir.OCALLFUNC, ir.OCALLINTER: return !ir.IsFuncPCIntrinsic(n.(*ir.CallExpr)) @@ -977,7 +977,7 @@ func isvaluelit(n ir.Node) bool { func subst(n ir.Node, m map[*ir.Name]ir.Node) (ir.Node, bool) { valid := true var edit func(ir.Node) ir.Node - edit = func { x | + edit = func { x -> switch x.Op() { case ir.ONAME: x := x.(*ir.Name) @@ -1110,7 +1110,7 @@ func tryWrapGlobalInit(n ir.Node) *ir.Func { // Determine size of RHS. rsiz := 0 - ir.Any(as.Y, func { n | + ir.Any(as.Y, func { n -> rsiz++ return false }) diff --git a/src/cmd/compile/internal/syntax/dumper_test.go b/src/cmd/compile/internal/syntax/dumper_test.go index cb843342b30f5..5d08b8176aaa5 100644 --- a/src/cmd/compile/internal/syntax/dumper_test.go +++ b/src/cmd/compile/internal/syntax/dumper_test.go @@ -13,7 +13,7 @@ func TestDump(t *testing.T) { t.Skip("skipping test in short mode") } - ast, _ := ParseFile(*src_, func { err | t.Error(err) }, nil, CheckBranches) + ast, _ := ParseFile(*src_, func { err -> t.Error(err) }, nil, CheckBranches) if ast != nil { Fdump(testOut(), ast) diff --git a/src/cmd/compile/internal/syntax/error_test.go b/src/cmd/compile/internal/syntax/error_test.go index 996bc3da35a20..fe5c0b460d564 100644 --- a/src/cmd/compile/internal/syntax/error_test.go +++ b/src/cmd/compile/internal/syntax/error_test.go @@ -60,7 +60,7 @@ func sortedPositions(m map[position]string) []position { list[i] = pos i++ } - sort.Slice(list, func { i, j | + sort.Slice(list, func { i, j -> a, b := list[i], list[j] return a.line < b.line || a.line == b.line && a.col < b.col }) @@ -82,7 +82,7 @@ func declaredErrors(t *testing.T, filename string) map[position]string { var s scanner var pattern string - s.init(f, func { line, col, msg | + s.init(f, func { line, col, msg -> // errors never start with '/' so they are automatically excluded here switch { case strings.HasPrefix(msg, "// ERROR "): @@ -127,7 +127,7 @@ func testSyntaxErrors(t *testing.T, filename string) { } defer f.Close() - ParseFile(filename, func { err | + ParseFile(filename, func { err -> e, ok := err.(Error) if !ok { return diff --git a/src/cmd/compile/internal/syntax/issues_test.go b/src/cmd/compile/internal/syntax/issues_test.go index f9523aee1e5fb..d3cbad4bc3b09 100644 --- a/src/cmd/compile/internal/syntax/issues_test.go +++ b/src/cmd/compile/internal/syntax/issues_test.go @@ -38,7 +38,7 @@ func TestIssue67866(t *testing.T) { } // locate KeyValueExpr - Inspect(f, func { n | + Inspect(f, func { n -> _, ok := n.(*KeyValueExpr) if ok { if got := StartPos(n).Col(); got != want { diff --git a/src/cmd/compile/internal/syntax/nodes_test.go b/src/cmd/compile/internal/syntax/nodes_test.go index 011d263a98e59..abeb296098ee7 100644 --- a/src/cmd/compile/internal/syntax/nodes_test.go +++ b/src/cmd/compile/internal/syntax/nodes_test.go @@ -243,41 +243,41 @@ func TestPos(t *testing.T) { // extract the node for each specific kind of construct. testPos(t, decls, "package p; ", "", - func { f | return f.DeclList[0] }, + func { f -> return f.DeclList[0] }, ) // embed expressions in a composite literal so we can test key:value and naked composite literals testPos(t, exprs, "package p; var _ = T{ ", " }", - func { f | return f.DeclList[0].(*VarDecl).Values.(*CompositeLit).ElemList[0] }, + func { f -> return f.DeclList[0].(*VarDecl).Values.(*CompositeLit).ElemList[0] }, ) // embed types in a function signature so we can test ... types testPos(t, types, "package p; func f(", ")", - func { f | return f.DeclList[0].(*FuncDecl).Type.ParamList[0].Type }, + func { f -> return f.DeclList[0].(*FuncDecl).Type.ParamList[0].Type }, ) testPos(t, fields, "package p; func f(", ")", - func { f | return f.DeclList[0].(*FuncDecl).Type.ParamList[0] }, + func { f -> return f.DeclList[0].(*FuncDecl).Type.ParamList[0] }, ) testPos(t, stmts, "package p; func _() { ", "; }", - func { f | return f.DeclList[0].(*FuncDecl).Body.List[0] }, + func { f -> return f.DeclList[0].(*FuncDecl).Body.List[0] }, ) testPos(t, ranges, "package p; func _() { for ", " {} }", - func { f | return f.DeclList[0].(*FuncDecl).Body.List[0].(*ForStmt).Init.(*RangeClause) }, + func { f -> return f.DeclList[0].(*FuncDecl).Body.List[0].(*ForStmt).Init.(*RangeClause) }, ) testPos(t, guards, "package p; func _() { switch ", " {} }", - func { f | return f.DeclList[0].(*FuncDecl).Body.List[0].(*SwitchStmt).Tag.(*TypeSwitchGuard) }, + func { f -> return f.DeclList[0].(*FuncDecl).Body.List[0].(*SwitchStmt).Tag.(*TypeSwitchGuard) }, ) testPos(t, cases, "package p; func _() { switch { ", " } }", - func { f | return f.DeclList[0].(*FuncDecl).Body.List[0].(*SwitchStmt).Body[0] }, + func { f -> return f.DeclList[0].(*FuncDecl).Body.List[0].(*SwitchStmt).Body[0] }, ) testPos(t, comms, "package p; func _() { select { ", " } }", - func { f | return f.DeclList[0].(*FuncDecl).Body.List[0].(*SelectStmt).Body[0] }, + func { f -> return f.DeclList[0].(*FuncDecl).Body.List[0].(*SelectStmt).Body[0] }, ) } diff --git a/src/cmd/compile/internal/syntax/parser.go b/src/cmd/compile/internal/syntax/parser.go index b45d3f1bb0fad..4fe29d2469a38 100644 --- a/src/cmd/compile/internal/syntax/parser.go +++ b/src/cmd/compile/internal/syntax/parser.go @@ -47,7 +47,7 @@ func (p *parser) init(file *PosBase, r io.Reader, errh ErrorHandler, pragh Pragm // handler is always at or after the current reading // position, it is safe to use the most recent position // base to compute the corresponding Pos value. - func { line, col, msg | + func { line, col, msg -> if msg[0] != '/' { p.errorAt(p.posAt(line, col), msg) return diff --git a/src/cmd/compile/internal/syntax/parser_test.go b/src/cmd/compile/internal/syntax/parser_test.go index ac0c398de5e96..f836d4a7c7cec 100644 --- a/src/cmd/compile/internal/syntax/parser_test.go +++ b/src/cmd/compile/internal/syntax/parser_test.go @@ -27,11 +27,11 @@ var ( ) func TestParse(t *testing.T) { - ParseFile(*src_, func { err | t.Error(err) }, nil, 0) + ParseFile(*src_, func { err -> t.Error(err) }, nil, 0) } func TestVerify(t *testing.T) { - ast, err := ParseFile(*src_, func { err | t.Error(err) }, nil, 0) + ast, err := ParseFile(*src_, func { err -> t.Error(err) }, nil, 0) if err != nil { return // error already reported } @@ -82,7 +82,7 @@ func TestStdLib(t *testing.T) { } } - walkDirs(t, dir, func { filename | + walkDirs(t, dir, func { filename -> if skipRx != nil && skipRx.MatchString(filename) { // Always report skipped files since regexp // typos can lead to surprising results. @@ -213,7 +213,7 @@ func TestParseFile(t *testing.T) { } var first error - _, err = ParseFile("", func { err | if first == nil { + _, err = ParseFile("", func { err -> if first == nil { first = err } }, nil, 0) if err == nil || first == nil { diff --git a/src/cmd/compile/internal/syntax/printer_test.go b/src/cmd/compile/internal/syntax/printer_test.go index 0498914c596ed..96efa497cade1 100644 --- a/src/cmd/compile/internal/syntax/printer_test.go +++ b/src/cmd/compile/internal/syntax/printer_test.go @@ -17,7 +17,7 @@ func TestPrint(t *testing.T) { t.Skip("skipping test in short mode") } - ast, _ := ParseFile(*src_, func { err | t.Error(err) }, nil, 0) + ast, _ := ParseFile(*src_, func { err -> t.Error(err) }, nil, 0) if ast != nil { Fprint(testOut(), ast, LineForm) diff --git a/src/cmd/compile/internal/syntax/scanner_test.go b/src/cmd/compile/internal/syntax/scanner_test.go index 94b9938cf2c51..2c1cefe1302e1 100644 --- a/src/cmd/compile/internal/syntax/scanner_test.go +++ b/src/cmd/compile/internal/syntax/scanner_test.go @@ -37,7 +37,7 @@ func TestSmoke(t *testing.T) { func TestTokens(t *testing.T) { var got scanner for _, want := range sampleTokens { - got.init(strings.NewReader(want.src), func { line, col, msg | t.Errorf("%s:%d:%d: %s", want.src, line, col, msg) }, 0) + got.init(strings.NewReader(want.src), func { line, col, msg -> t.Errorf("%s:%d:%d: %s", want.src, line, col, msg) }, 0) got.next() if got.tok != want.tok { t.Errorf("%s: got %s; want %s", want.src, got.tok, want.tok) @@ -95,7 +95,7 @@ func TestEmbeddedTokens(t *testing.T) { // scan source var got scanner var src string - got.init(&buf, func { line, col, msg | t.Fatalf("%s:%d:%d: %s", src, line, col, msg) }, 0) + got.init(&buf, func { line, col, msg -> t.Fatalf("%s:%d:%d: %s", src, line, col, msg) }, 0) got.next() for i, want := range sampleTokens { src = want.src @@ -348,7 +348,7 @@ func TestComments(t *testing.T) { } { var s scanner var got comment - s.init(strings.NewReader(test.src), func { line, col, msg | + s.init(strings.NewReader(test.src), func { line, col, msg -> if msg[0] != '/' { // error if msg != "comment not terminated" { @@ -532,7 +532,7 @@ func TestNumbers(t *testing.T) { } { var s scanner var err string - s.init(strings.NewReader(test.src), func { _, _, msg | if err == "" { + s.init(strings.NewReader(test.src), func { _, _, msg -> if err == "" { err = msg } }, 0) @@ -654,7 +654,7 @@ func TestScanErrors(t *testing.T) { var s scanner var line, col uint var err string - s.init(strings.NewReader(test.src), func { l, c, msg | if err == "" { + s.init(strings.NewReader(test.src), func { l, c, msg -> if err == "" { line, col = l-linebase, c-colbase err = msg } }, 0) @@ -699,7 +699,7 @@ func TestDirectives(t *testing.T) { } { got := "" var s scanner - s.init(strings.NewReader(src), func { _, col, msg | + s.init(strings.NewReader(src), func { _, col, msg -> if col != colbase { t.Errorf("%s: got col = %d; want %d", src, col, colbase) } @@ -741,7 +741,7 @@ func TestIssue33961(t *testing.T) { for _, lit := range strings.Split(literals, " ") { n := 0 var got scanner - got.init(strings.NewReader(lit), func { _, _, msg | + got.init(strings.NewReader(lit), func { _, _, msg -> // fmt.Printf("%s: %s\n", lit, msg) // uncomment for debugging n++ }, 0) got.next() diff --git a/src/cmd/compile/internal/syntax/testing.go b/src/cmd/compile/internal/syntax/testing.go index 0b2d5183de102..74f0bb291af1f 100644 --- a/src/cmd/compile/internal/syntax/testing.go +++ b/src/cmd/compile/internal/syntax/testing.go @@ -39,7 +39,7 @@ func CommentMap(src io.Reader, rx *regexp.Regexp) (res map[uint][]Error) { var prev struct{ line, col uint } var s scanner - s.init(src, func { _, _, text | + s.init(src, func { _, _, text -> if text[0] != '/' { return // not a comment, ignore } diff --git a/src/cmd/compile/internal/test/divconst_test.go b/src/cmd/compile/internal/test/divconst_test.go index 30480bf7b43c3..4dbc78a9c0d1e 100644 --- a/src/cmd/compile/internal/test/divconst_test.go +++ b/src/cmd/compile/internal/test/divconst_test.go @@ -67,56 +67,56 @@ func TestDivmodConstU64(t *testing.T) { } } } - t.Run("2", testdiv(2, func { n | return n / 2, n % 2 })) - t.Run("3", testdiv(3, func { n | return n / 3, n % 3 })) - t.Run("4", testdiv(4, func { n | return n / 4, n % 4 })) - t.Run("5", testdiv(5, func { n | return n / 5, n % 5 })) - t.Run("6", testdiv(6, func { n | return n / 6, n % 6 })) - t.Run("7", testdiv(7, func { n | return n / 7, n % 7 })) - t.Run("8", testdiv(8, func { n | return n / 8, n % 8 })) - t.Run("9", testdiv(9, func { n | return n / 9, n % 9 })) - t.Run("10", testdiv(10, func { n | return n / 10, n % 10 })) - t.Run("11", testdiv(11, func { n | return n / 11, n % 11 })) - t.Run("12", testdiv(12, func { n | return n / 12, n % 12 })) - t.Run("13", testdiv(13, func { n | return n / 13, n % 13 })) - t.Run("14", testdiv(14, func { n | return n / 14, n % 14 })) - t.Run("15", testdiv(15, func { n | return n / 15, n % 15 })) - t.Run("16", testdiv(16, func { n | return n / 16, n % 16 })) - t.Run("17", testdiv(17, func { n | return n / 17, n % 17 })) - t.Run("255", testdiv(255, func { n | return n / 255, n % 255 })) - t.Run("256", testdiv(256, func { n | return n / 256, n % 256 })) - t.Run("257", testdiv(257, func { n | return n / 257, n % 257 })) - t.Run("65535", testdiv(65535, func { n | return n / 65535, n % 65535 })) - t.Run("65536", testdiv(65536, func { n | return n / 65536, n % 65536 })) - t.Run("65537", testdiv(65537, func { n | return n / 65537, n % 65537 })) - t.Run("1<<32-1", testdiv(1<<32-1, func { n | return n / (1<<32 - 1), n % (1<<32 - 1) })) - t.Run("1<<32+1", testdiv(1<<32+1, func { n | return n / (1<<32 + 1), n % (1<<32 + 1) })) - t.Run("1<<64-1", testdiv(1<<64-1, func { n | return n / (1<<64 - 1), n % (1<<64 - 1) })) + t.Run("2", testdiv(2, func { n -> return n / 2, n % 2 })) + t.Run("3", testdiv(3, func { n -> return n / 3, n % 3 })) + t.Run("4", testdiv(4, func { n -> return n / 4, n % 4 })) + t.Run("5", testdiv(5, func { n -> return n / 5, n % 5 })) + t.Run("6", testdiv(6, func { n -> return n / 6, n % 6 })) + t.Run("7", testdiv(7, func { n -> return n / 7, n % 7 })) + t.Run("8", testdiv(8, func { n -> return n / 8, n % 8 })) + t.Run("9", testdiv(9, func { n -> return n / 9, n % 9 })) + t.Run("10", testdiv(10, func { n -> return n / 10, n % 10 })) + t.Run("11", testdiv(11, func { n -> return n / 11, n % 11 })) + t.Run("12", testdiv(12, func { n -> return n / 12, n % 12 })) + t.Run("13", testdiv(13, func { n -> return n / 13, n % 13 })) + t.Run("14", testdiv(14, func { n -> return n / 14, n % 14 })) + t.Run("15", testdiv(15, func { n -> return n / 15, n % 15 })) + t.Run("16", testdiv(16, func { n -> return n / 16, n % 16 })) + t.Run("17", testdiv(17, func { n -> return n / 17, n % 17 })) + t.Run("255", testdiv(255, func { n -> return n / 255, n % 255 })) + t.Run("256", testdiv(256, func { n -> return n / 256, n % 256 })) + t.Run("257", testdiv(257, func { n -> return n / 257, n % 257 })) + t.Run("65535", testdiv(65535, func { n -> return n / 65535, n % 65535 })) + t.Run("65536", testdiv(65536, func { n -> return n / 65536, n % 65536 })) + t.Run("65537", testdiv(65537, func { n -> return n / 65537, n % 65537 })) + t.Run("1<<32-1", testdiv(1<<32-1, func { n -> return n / (1<<32 - 1), n % (1<<32 - 1) })) + t.Run("1<<32+1", testdiv(1<<32+1, func { n -> return n / (1<<32 + 1), n % (1<<32 + 1) })) + t.Run("1<<64-1", testdiv(1<<64-1, func { n -> return n / (1<<64 - 1), n % (1<<64 - 1) })) } func BenchmarkDivconstU64(b *testing.B) { - b.Run("3", func { b | + b.Run("3", func { b -> x := uint64(123456789123456789) for i := 0; i < b.N; i++ { x += x << 4 u64res = uint64(x) / 3 } }) - b.Run("5", func { b | + b.Run("5", func { b -> x := uint64(123456789123456789) for i := 0; i < b.N; i++ { x += x << 4 u64res = uint64(x) / 5 } }) - b.Run("37", func { b | + b.Run("37", func { b -> x := uint64(123456789123456789) for i := 0; i < b.N; i++ { x += x << 4 u64res = uint64(x) / 37 } }) - b.Run("1234567", func { b | + b.Run("1234567", func { b -> x := uint64(123456789123456789) for i := 0; i < b.N; i++ { x += x << 4 diff --git a/src/cmd/compile/internal/test/mulconst_test.go b/src/cmd/compile/internal/test/mulconst_test.go index e08b9c1fa0e30..f8f136193709b 100644 --- a/src/cmd/compile/internal/test/mulconst_test.go +++ b/src/cmd/compile/internal/test/mulconst_test.go @@ -23,7 +23,7 @@ var ( func BenchmarkMulconstI32(b *testing.B) { // 3x = 2x + x - b.Run("3", func { b | + b.Run("3", func { b -> x := int32(1) for i := 0; i < b.N; i++ { x *= 3 @@ -31,7 +31,7 @@ func BenchmarkMulconstI32(b *testing.B) { mulSinkI32 = x }) // 5x = 4x + x - b.Run("5", func { b | + b.Run("5", func { b -> x := int32(1) for i := 0; i < b.N; i++ { x *= 5 @@ -39,7 +39,7 @@ func BenchmarkMulconstI32(b *testing.B) { mulSinkI32 = x }) // 12x = 8x + 4x - b.Run("12", func { b | + b.Run("12", func { b -> x := int32(1) for i := 0; i < b.N; i++ { x *= 12 @@ -47,7 +47,7 @@ func BenchmarkMulconstI32(b *testing.B) { mulSinkI32 = x }) // 120x = 128x - 8x - b.Run("120", func { b | + b.Run("120", func { b -> x := int32(1) for i := 0; i < b.N; i++ { x *= 120 @@ -55,7 +55,7 @@ func BenchmarkMulconstI32(b *testing.B) { mulSinkI32 = x }) // -120x = 8x - 120x - b.Run("-120", func { b | + b.Run("-120", func { b -> x := int32(1) for i := 0; i < b.N; i++ { x *= -120 @@ -63,7 +63,7 @@ func BenchmarkMulconstI32(b *testing.B) { mulSinkI32 = x }) // 65537x = 65536x + x - b.Run("65537", func { b | + b.Run("65537", func { b -> x := int32(1) for i := 0; i < b.N; i++ { x *= 65537 @@ -71,7 +71,7 @@ func BenchmarkMulconstI32(b *testing.B) { mulSinkI32 = x }) // 65538x = 65536x + 2x - b.Run("65538", func { b | + b.Run("65538", func { b -> x := int32(1) for i := 0; i < b.N; i++ { x *= 65538 @@ -82,7 +82,7 @@ func BenchmarkMulconstI32(b *testing.B) { func BenchmarkMulconstI64(b *testing.B) { // 3x = 2x + x - b.Run("3", func { b | + b.Run("3", func { b -> x := int64(1) for i := 0; i < b.N; i++ { x *= 3 @@ -90,7 +90,7 @@ func BenchmarkMulconstI64(b *testing.B) { mulSinkI64 = x }) // 5x = 4x + x - b.Run("5", func { b | + b.Run("5", func { b -> x := int64(1) for i := 0; i < b.N; i++ { x *= 5 @@ -98,7 +98,7 @@ func BenchmarkMulconstI64(b *testing.B) { mulSinkI64 = x }) // 12x = 8x + 4x - b.Run("12", func { b | + b.Run("12", func { b -> x := int64(1) for i := 0; i < b.N; i++ { x *= 12 @@ -106,7 +106,7 @@ func BenchmarkMulconstI64(b *testing.B) { mulSinkI64 = x }) // 120x = 128x - 8x - b.Run("120", func { b | + b.Run("120", func { b -> x := int64(1) for i := 0; i < b.N; i++ { x *= 120 @@ -114,7 +114,7 @@ func BenchmarkMulconstI64(b *testing.B) { mulSinkI64 = x }) // -120x = 8x - 120x - b.Run("-120", func { b | + b.Run("-120", func { b -> x := int64(1) for i := 0; i < b.N; i++ { x *= -120 @@ -122,7 +122,7 @@ func BenchmarkMulconstI64(b *testing.B) { mulSinkI64 = x }) // 65537x = 65536x + x - b.Run("65537", func { b | + b.Run("65537", func { b -> x := int64(1) for i := 0; i < b.N; i++ { x *= 65537 @@ -130,7 +130,7 @@ func BenchmarkMulconstI64(b *testing.B) { mulSinkI64 = x }) // 65538x = 65536x + 2x - b.Run("65538", func { b | + b.Run("65538", func { b -> x := int64(1) for i := 0; i < b.N; i++ { x *= 65538 @@ -141,7 +141,7 @@ func BenchmarkMulconstI64(b *testing.B) { func BenchmarkMulconstU32(b *testing.B) { // 3x = 2x + x - b.Run("3", func { b | + b.Run("3", func { b -> x := uint32(1) for i := 0; i < b.N; i++ { x *= 3 @@ -149,7 +149,7 @@ func BenchmarkMulconstU32(b *testing.B) { mulSinkU32 = x }) // 5x = 4x + x - b.Run("5", func { b | + b.Run("5", func { b -> x := uint32(1) for i := 0; i < b.N; i++ { x *= 5 @@ -157,7 +157,7 @@ func BenchmarkMulconstU32(b *testing.B) { mulSinkU32 = x }) // 12x = 8x + 4x - b.Run("12", func { b | + b.Run("12", func { b -> x := uint32(1) for i := 0; i < b.N; i++ { x *= 12 @@ -165,7 +165,7 @@ func BenchmarkMulconstU32(b *testing.B) { mulSinkU32 = x }) // 120x = 128x - 8x - b.Run("120", func { b | + b.Run("120", func { b -> x := uint32(1) for i := 0; i < b.N; i++ { x *= 120 @@ -173,7 +173,7 @@ func BenchmarkMulconstU32(b *testing.B) { mulSinkU32 = x }) // 65537x = 65536x + x - b.Run("65537", func { b | + b.Run("65537", func { b -> x := uint32(1) for i := 0; i < b.N; i++ { x *= 65537 @@ -181,7 +181,7 @@ func BenchmarkMulconstU32(b *testing.B) { mulSinkU32 = x }) // 65538x = 65536x + 2x - b.Run("65538", func { b | + b.Run("65538", func { b -> x := uint32(1) for i := 0; i < b.N; i++ { x *= 65538 @@ -192,7 +192,7 @@ func BenchmarkMulconstU32(b *testing.B) { func BenchmarkMulconstU64(b *testing.B) { // 3x = 2x + x - b.Run("3", func { b | + b.Run("3", func { b -> x := uint64(1) for i := 0; i < b.N; i++ { x *= 3 @@ -200,7 +200,7 @@ func BenchmarkMulconstU64(b *testing.B) { mulSinkU64 = x }) // 5x = 4x + x - b.Run("5", func { b | + b.Run("5", func { b -> x := uint64(1) for i := 0; i < b.N; i++ { x *= 5 @@ -208,7 +208,7 @@ func BenchmarkMulconstU64(b *testing.B) { mulSinkU64 = x }) // 12x = 8x + 4x - b.Run("12", func { b | + b.Run("12", func { b -> x := uint64(1) for i := 0; i < b.N; i++ { x *= 12 @@ -216,7 +216,7 @@ func BenchmarkMulconstU64(b *testing.B) { mulSinkU64 = x }) // 120x = 128x - 8x - b.Run("120", func { b | + b.Run("120", func { b -> x := uint64(1) for i := 0; i < b.N; i++ { x *= 120 @@ -224,7 +224,7 @@ func BenchmarkMulconstU64(b *testing.B) { mulSinkU64 = x }) // 65537x = 65536x + x - b.Run("65537", func { b | + b.Run("65537", func { b -> x := uint64(1) for i := 0; i < b.N; i++ { x *= 65537 @@ -232,7 +232,7 @@ func BenchmarkMulconstU64(b *testing.B) { mulSinkU64 = x }) // 65538x = 65536x + 2x - b.Run("65538", func { b | + b.Run("65538", func { b -> x := uint64(1) for i := 0; i < b.N; i++ { x *= 65538 diff --git a/src/cmd/compile/internal/test/pgo_inl_test.go b/src/cmd/compile/internal/test/pgo_inl_test.go index f94525350eb3c..ab0d4327b39e0 100644 --- a/src/cmd/compile/internal/test/pgo_inl_test.go +++ b/src/cmd/compile/internal/test/pgo_inl_test.go @@ -252,7 +252,7 @@ func TestPGOSingleIndex(t *testing.T) { }, { originalIndex: 1, }} { - t.Run(fmt.Sprintf("originalIndex=%d", tc.originalIndex), func { t | + t.Run(fmt.Sprintf("originalIndex=%d", tc.originalIndex), func { t -> wd, err := os.Getwd() if err != nil { t.Fatalf("error getting wd: %v", err) diff --git a/src/cmd/compile/internal/test/race.go b/src/cmd/compile/internal/test/race.go index 490217a410477..a1e95b0320035 100644 --- a/src/cmd/compile/internal/test/race.go +++ b/src/cmd/compile/internal/test/race.go @@ -44,7 +44,7 @@ func (q *T55357[T]) do(w, v bool, fn func(bk []byte, v T) error) error { } func (q *T55357[T]) Count() (n int, rerr error) { - err := q.do(false, false, func { kb, _ | + err := q.do(false, false, func { kb, _ -> n++ return nil }) @@ -53,7 +53,7 @@ func (q *T55357[T]) Count() (n int, rerr error) { func (q *T55357[T]) List() (list []T, rerr error) { var l []T - err := q.do(false, true, func { _, v | + err := q.do(false, true, func { _, v -> l = append(l, v) return nil }) diff --git a/src/cmd/compile/internal/test/reproduciblebuilds_test.go b/src/cmd/compile/internal/test/reproduciblebuilds_test.go index 295a7423e799e..8649485c6dff4 100644 --- a/src/cmd/compile/internal/test/reproduciblebuilds_test.go +++ b/src/cmd/compile/internal/test/reproduciblebuilds_test.go @@ -27,7 +27,7 @@ func TestReproducibleBuilds(t *testing.T) { t.Parallel() for _, test := range tests { test := test - t.Run(test, func { t | + t.Run(test, func { t -> t.Parallel() var want []byte tmp, err := os.CreateTemp("", "") diff --git a/src/cmd/compile/internal/test/ssa_test.go b/src/cmd/compile/internal/test/ssa_test.go index c4bfa0e036731..9d71fa6e7d8e9 100644 --- a/src/cmd/compile/internal/test/ssa_test.go +++ b/src/cmd/compile/internal/test/ssa_test.go @@ -168,7 +168,7 @@ func TestCode(t *testing.T) { // No point in running the soft float version if the test doesn't use floats. continue } - t.Run(fmt.Sprintf("%s%s", test.name[4:], flag), func { t | + t.Run(fmt.Sprintf("%s%s", test.name[4:], flag), func { t -> out, err := testenv.Command(t, filepath.Join(tmpdir, "code.test"), "-test.run=^"+test.name+"$").CombinedOutput() if err != nil || string(out) != "PASS\n" { t.Errorf("Failed:\n%s\n", out) diff --git a/src/cmd/compile/internal/typecheck/stmt.go b/src/cmd/compile/internal/typecheck/stmt.go index 9b42137d4f9f3..b214bcdd44fc3 100644 --- a/src/cmd/compile/internal/typecheck/stmt.go +++ b/src/cmd/compile/internal/typecheck/stmt.go @@ -236,7 +236,7 @@ func normalizeGoDeferCall(pos src.XPos, op ir.Op, call ir.Node, init *ir.Nodes) var argps []*ir.Node var visit func(argp *ir.Node) - visit = func { argp | + visit = func { argp -> arg := *argp if arg == nil { return diff --git a/src/cmd/compile/internal/typecheck/typecheck.go b/src/cmd/compile/internal/typecheck/typecheck.go index 6256a0c10b0b4..d6874fe6ce42e 100644 --- a/src/cmd/compile/internal/typecheck/typecheck.go +++ b/src/cmd/compile/internal/typecheck/typecheck.go @@ -634,7 +634,7 @@ func RewriteNonNameCall(n *ir.CallExpr) { // Check for side effects in the callee expression. // We explicitly special case new(T) though, because it doesn't have // observable side effects, and keeping it in place allows better escape analysis. - if !ir.Any(*np, func { n | return n.Op() != ir.ONEW && callOrChan(n) }) { + if !ir.Any(*np, func { n -> return n.Op() != ir.ONEW && callOrChan(n) }) { return } diff --git a/src/cmd/compile/internal/typecheck/universe.go b/src/cmd/compile/internal/typecheck/universe.go index 67f83c37c411f..e25a661e3d998 100644 --- a/src/cmd/compile/internal/typecheck/universe.go +++ b/src/cmd/compile/internal/typecheck/universe.go @@ -64,7 +64,7 @@ var unsafeFuncs = [...]struct { // InitUniverse initializes the universe block. func InitUniverse() { - types.InitTypes(func { sym, typ | + types.InitTypes(func { sym, typ -> n := ir.NewDeclNameAt(src.NoXPos, ir.OTYPE, sym) n.SetType(typ) n.SetTypecheck(1) diff --git a/src/cmd/compile/internal/types/size.go b/src/cmd/compile/internal/types/size.go index 071483f0fa1f5..d071e6debe1fb 100644 --- a/src/cmd/compile/internal/types/size.go +++ b/src/cmd/compile/internal/types/size.go @@ -93,7 +93,7 @@ func expandiface(t *Type) { { methods := t.Methods() - sort.SliceStable(methods, func { i, j | + sort.SliceStable(methods, func { i, j -> mi, mj := methods[i], methods[j] // Sort embedded types by type name (if any). diff --git a/src/cmd/compile/internal/types/sym_test.go b/src/cmd/compile/internal/types/sym_test.go index 7b7333c44dcd4..a8fce15292d7e 100644 --- a/src/cmd/compile/internal/types/sym_test.go +++ b/src/cmd/compile/internal/types/sym_test.go @@ -50,7 +50,7 @@ func TestSymLess(t *testing.T) { if reflect.DeepEqual(data, want) { t.Fatal("data must be shuffled") } - sort.Slice(data, func { i, j | return data[i].Less(data[j]) }) + sort.Slice(data, func { i, j -> return data[i].Less(data[j]) }) if !reflect.DeepEqual(data, want) { t.Logf("want: %#v", want) t.Logf("data: %#v", data) diff --git a/src/cmd/compile/internal/types2/api_test.go b/src/cmd/compile/internal/types2/api_test.go index 94a968595630e..e8eae89e671d4 100644 --- a/src/cmd/compile/internal/types2/api_test.go +++ b/src/cmd/compile/internal/types2/api_test.go @@ -634,7 +634,7 @@ type T[P any] []P makePkg(lib) pkg := makePkg(test.src) - t.Run(pkg.Name(), func { t | + t.Run(pkg.Name(), func { t -> // Sort instances in source order for stability. instances := sortedInstances(instMap) if got, want := len(instances), len(test.instances); got != want { @@ -694,7 +694,7 @@ func sortedInstances(m map[*syntax.Name]Instance) (instances []recordedInstance) for id, inst := range m { instances = append(instances, recordedInstance{id, inst}) } - sort.Slice(instances, func { i, j | return CmpPos(instances[i].Name.Pos(), instances[j].Name.Pos()) < 0 }) + sort.Slice(instances, func { i, j -> return CmpPos(instances[i].Name.Pos(), instances[j].Name.Pos()) < 0 }) return instances } @@ -850,7 +850,7 @@ func (r *N[C]) n() { } switch fdecl.Name.Value { case "m": dm = def - syntax.Inspect(fdecl.Body, func { n | + syntax.Inspect(fdecl.Body, func { n -> if call, ok := n.(*syntax.CallExpr); ok { sel := call.Fun.(*syntax.SelectorExpr) use := info.Uses[sel.Sel].(*Func) @@ -1932,7 +1932,7 @@ func F[T *U, U any](param1, param2 int) /*param1=undef*/ (res1 /*res1=undef*/, r rx := regexp.MustCompile(`^/\*(\w*)=([\w:]*)\*/$`) base := syntax.NewFileBase("main") - syntax.CommentsDo(strings.NewReader(mainSrc), func { line, col, text | + syntax.CommentsDo(strings.NewReader(mainSrc), func { line, col, text -> pos := syntax.MakePos(base, line, col) // Syntax errors are not comments. @@ -1988,7 +1988,7 @@ func F[T *U, U any](param1, param2 int) /*param1=undef*/ (res1 /*res1=undef*/, r if gotObj != wantObj { // Print the scope tree of mainScope in case of error. var printScopeTree func(indent string, s *Scope) - printScopeTree = func { indent, s | + printScopeTree = func { indent, s -> t.Logf("%sscope %s %v-%v = %v", indent, ScopeComment(s), @@ -2627,7 +2627,7 @@ func fn() { // Collect all identifiers by name. idents := make(map[string][]*syntax.Name) - syntax.Inspect(f, func { n | + syntax.Inspect(f, func { n -> if id, ok := n.(*syntax.Name); ok { idents[id.Value] = append(idents[id.Value], id) } @@ -2636,7 +2636,7 @@ func fn() { for _, test := range tests { test := test - t.Run(test.name, func { t | + t.Run(test.name, func { t -> if got := len(idents[test.name]); got != 1 { t.Fatalf("found %d identifiers named %s, want 1", got, test.name) } @@ -3054,7 +3054,7 @@ type C = int // (concurrent) type checking. func TestAnyHijacking_Check(t *testing.T) { for _, enableAlias := range []bool{false, true} { - t.Run(fmt.Sprintf("EnableAlias=%t", enableAlias), func { t | + t.Run(fmt.Sprintf("EnableAlias=%t", enableAlias), func { t -> var wg sync.WaitGroup for i := 0; i < 10; i++ { wg.Add(1) diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go index 82a2c17f667d2..8069470a417e4 100644 --- a/src/cmd/compile/internal/types2/builtins.go +++ b/src/cmd/compile/internal/types2/builtins.go @@ -184,7 +184,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( if !isTypeParam(x.typ) { break } - if t.typeSet().underIs(func { t | + if t.typeSet().underIs(func { t -> switch t := arrayPtrDeref(t).(type) { case *Basic: if isString(t) && id == _Len { @@ -228,7 +228,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // clear(m) check.verifyVersionf(call.Fun, go1_21, "clear") - if !underIs(x.typ, func { u | + if !underIs(x.typ, func { u -> switch u.(type) { case *Map, *Slice: return true @@ -246,7 +246,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( case _Close: // close(c) - if !underIs(x.typ, func { u | + if !underIs(x.typ, func { u -> uch, _ := u.(*Chan) if uch == nil { check.errorf(x, InvalidClose, invalidOp+"cannot close non-channel %s", x) @@ -388,7 +388,7 @@ func (check *Checker) builtin(x *operand, call *syntax.CallExpr, id builtinId) ( // The key cannot be a type parameter for now. map_ := x.typ var key Type - if !underIs(map_, func { u | + if !underIs(map_, func { u -> map_, _ := u.(*Map) if map_ == nil { check.errorf(x, InvalidDelete, invalidArg+"%s is not a map", x) @@ -964,7 +964,7 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x *operand, id builtinId) // Test if t satisfies the requirements for the argument // type and collect possible result types at the same time. var terms []*Term - if !tp.is(func { t | + if !tp.is(func { t -> if t == nil { return false } diff --git a/src/cmd/compile/internal/types2/check_test.go b/src/cmd/compile/internal/types2/check_test.go index 0d732a96bab77..54e04f55f7c98 100644 --- a/src/cmd/compile/internal/types2/check_test.go +++ b/src/cmd/compile/internal/types2/check_test.go @@ -123,7 +123,7 @@ func parseFlags(src []byte, flags *flag.FlagSet) error { // If provided, opts may be used to mutate the Config before type-checking. func testFiles(t *testing.T, filenames []string, srcs [][]byte, colDelta uint, manual bool, opts ...func(*Config)) { enableAlias := true - opts = append(opts, func { conf | conf.EnableAlias = enableAlias }) + opts = append(opts, func { conf -> conf.EnableAlias = enableAlias }) testFilesImpl(t, filenames, srcs, colDelta, manual, opts...) if !manual { enableAlias = false @@ -154,7 +154,7 @@ func testFilesImpl(t *testing.T, filenames []string, srcs [][]byte, colDelta uin var conf Config conf.Trace = manual && testing.Verbose() conf.Importer = defaultImporter() - conf.Error = func { err | + conf.Error = func { err -> if *haltOnError { defer panic(err) } @@ -425,7 +425,7 @@ func testDirFiles(t *testing.T, dir string, colDelta uint, manual bool) { if fi.IsDir() { testDir(t, path, colDelta, manual) } else { - t.Run(filepath.Base(path), func { t | testPkg(t, []string{path}, colDelta, manual) }) + t.Run(filepath.Base(path), func { t -> testPkg(t, []string{path}, colDelta, manual) }) } } } @@ -442,7 +442,7 @@ func testDir(t *testing.T, dir string, colDelta uint, manual bool) { filenames = append(filenames, filepath.Join(dir, fi.Name())) } - t.Run(filepath.Base(dir), func { t | testPkg(t, filenames, colDelta, manual) }) + t.Run(filepath.Base(dir), func { t -> testPkg(t, filenames, colDelta, manual) }) } func testPkg(t *testing.T, filenames []string, colDelta uint, manual bool) { diff --git a/src/cmd/compile/internal/types2/conversions.go b/src/cmd/compile/internal/types2/conversions.go index 943f448b3ce24..51fd427be1877 100644 --- a/src/cmd/compile/internal/types2/conversions.go +++ b/src/cmd/compile/internal/types2/conversions.go @@ -56,7 +56,7 @@ func (check *Checker) conversion(x *operand, T Type) { // If T's type set is empty, or if it doesn't // have specific types, constant x cannot be // converted. - ok = Unalias(T).(*TypeParam).underIs(func { u | + ok = Unalias(T).(*TypeParam).underIs(func { u -> // u is nil if there are no specific type terms if u == nil { cause = check.sprintf("%s does not contain specific types", T) @@ -246,12 +246,12 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { switch { case Vp != nil && Tp != nil: x := *x // don't clobber outer x - return Vp.is(func { V | + return Vp.is(func { V -> if V == nil { return false // no specific types } x.typ = V.typ - return Tp.is(func { T | + return Tp.is(func { T -> if T == nil { return false // no specific types } @@ -264,7 +264,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { }) case Vp != nil: x := *x // don't clobber outer x - return Vp.is(func { V | + return Vp.is(func { V -> if V == nil { return false // no specific types } @@ -276,7 +276,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { return true }) case Tp != nil: - return Tp.is(func { T | + return Tp.is(func { T -> if T == nil { return false // no specific types } diff --git a/src/cmd/compile/internal/types2/errorcalls_test.go b/src/cmd/compile/internal/types2/errorcalls_test.go index 36016115e3487..542f629425273 100644 --- a/src/cmd/compile/internal/types2/errorcalls_test.go +++ b/src/cmd/compile/internal/types2/errorcalls_test.go @@ -25,7 +25,7 @@ func TestErrorCalls(t *testing.T) { } for _, file := range files { - syntax.Inspect(file, func { n | + syntax.Inspect(file, func { n -> call, _ := n.(*syntax.CallExpr) if call == nil { return true @@ -44,7 +44,7 @@ func TestErrorCalls(t *testing.T) { return false } format := call.ArgList[errorfFormatIndex] - syntax.Inspect(format, func { n | + syntax.Inspect(format, func { n -> if lit, _ := n.(*syntax.BasicLit); lit != nil && lit.Kind == syntax.StringLit { if s, err := strconv.Unquote(lit.Value); err == nil { if !balancedParentheses(s) { diff --git a/src/cmd/compile/internal/types2/expr.go b/src/cmd/compile/internal/types2/expr.go index 6f85e4c754aeb..a8da3b6fad407 100644 --- a/src/cmd/compile/internal/types2/expr.go +++ b/src/cmd/compile/internal/types2/expr.go @@ -449,7 +449,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const } case *Interface: if isTypeParam(target) { - if !u.typeSet().underIs(func { u | + if !u.typeSet().underIs(func { u -> if u == nil { return false } @@ -601,7 +601,7 @@ func (check *Checker) incomparableCause(typ Type) string { } // see if we can extract a more specific error var cause string - comparable(typ, true, nil, func { format, args | cause = check.sprintf(format, args...) }) + comparable(typ, true, nil, func { format, args -> cause = check.sprintf(format, args...) }) return cause } @@ -1467,7 +1467,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e syntax.Expr, hint Ty x.typ = &Pointer{base: x.typ} default: var base Type - if !underIs(x.typ, func { u | + if !underIs(x.typ, func { u -> p, _ := u.(*Pointer) if p == nil { check.errorf(x, InvalidIndirection, invalidOp+"cannot indirect %s", x) diff --git a/src/cmd/compile/internal/types2/index.go b/src/cmd/compile/internal/types2/index.go index 26fc2f855728e..89cf5564e2c07 100644 --- a/src/cmd/compile/internal/types2/index.go +++ b/src/cmd/compile/internal/types2/index.go @@ -108,7 +108,7 @@ func (check *Checker) indexExpr(x *operand, e *syntax.IndexExpr) (isFuncInst boo var key, elem Type // key != nil: we must have all maps mode := variable // non-maps result mode // TODO(gri) factor out closure and use it for non-typeparam cases as well - if typ.typeSet().underIs(func { u | + if typ.typeSet().underIs(func { u -> l := int64(-1) // valid if >= 0 var k, e Type // k is only set for maps switch t := u.(type) { diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index 3b537a11ac2e0..b32df492e1665 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -279,7 +279,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type, // Eventually, unify should return an error with cause. var cause string constraint := tpar.iface() - if m, _ := check.missingMethod(tx, constraint, true, func { x, y | return u.unify(x, y, exact) }, &cause); m != nil { + if m, _ := check.missingMethod(tx, constraint, true, func { x, y -> return u.unify(x, y, exact) }, &cause); m != nil { // TODO(gri) better error message (see TODO above) err.addf(pos, "%s (type %s) does not satisfy %s %s", tpar, tx, tpar.Constraint(), cause) return nil @@ -600,7 +600,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) { return true } } - return tset.is(func { t | return t != nil && w.isParameterized(t.typ) }) + return tset.is(func { t -> return t != nil && w.isParameterized(t.typ) }) case *Map: return w.isParameterized(t.key) || w.isParameterized(t.elem) @@ -642,7 +642,7 @@ func coreTerm(tpar *TypeParam) (*term, bool) { n := 0 var single *term // valid if n == 1 var tilde bool - tpar.is(func { t | + tpar.is(func { t -> if t == nil { assert(n == 0) return false // no terms diff --git a/src/cmd/compile/internal/types2/initorder.go b/src/cmd/compile/internal/types2/initorder.go index 9be6b64b90b83..8494f4defed27 100644 --- a/src/cmd/compile/internal/types2/initorder.go +++ b/src/cmd/compile/internal/types2/initorder.go @@ -257,7 +257,7 @@ func dependencyGraph(objMap map[Object]*declInfo) []*graphNode { // throughout the function graph, the cost of removing a function at // position X is proportional to cost * (len(funcG)-X). Therefore, we should // remove high-cost functions last. - sort.Slice(funcG, func { i, j | return funcG[i].cost() < funcG[j].cost() }) + sort.Slice(funcG, func { i, j -> return funcG[i].cost() < funcG[j].cost() }) for _, n := range funcG { // connect each predecessor p of n with each successor s // and drop the function node (don't collect it in G) diff --git a/src/cmd/compile/internal/types2/instantiate.go b/src/cmd/compile/internal/types2/instantiate.go index b26ecaf3219dc..c76b6f2917b26 100644 --- a/src/cmd/compile/internal/types2/instantiate.go +++ b/src/cmd/compile/internal/types2/instantiate.go @@ -331,7 +331,7 @@ func (check *Checker) implements(pos syntax.Pos, V, T Type, constraint bool, cau // Otherwise, V's type must be included in the iface type set. var alt Type - if Ti.typeSet().is(func { t | + if Ti.typeSet().is(func { t -> if !t.includes(V) { // If V ∉ t.typ but V ∈ ~t.typ then remember this type // so we can suggest it as an alternative in the error diff --git a/src/cmd/compile/internal/types2/instantiate_test.go b/src/cmd/compile/internal/types2/instantiate_test.go index 62c06589e3f37..596f0c53ca835 100644 --- a/src/cmd/compile/internal/types2/instantiate_test.go +++ b/src/cmd/compile/internal/types2/instantiate_test.go @@ -109,7 +109,7 @@ func TestInstantiateEquality(t *testing.T) { for _, test := range tests { pkg := mustTypecheck(test.src, nil, nil) - t.Run(pkg.Name(), func { t | + t.Run(pkg.Name(), func { t -> ctxt := NewContext() T1 := pkg.Scope().Lookup(test.name1).Type() diff --git a/src/cmd/compile/internal/types2/issues_test.go b/src/cmd/compile/internal/types2/issues_test.go index 4c3df4c429bb6..bbe96c406414d 100644 --- a/src/cmd/compile/internal/types2/issues_test.go +++ b/src/cmd/compile/internal/types2/issues_test.go @@ -292,7 +292,7 @@ func TestIssue25627(t *testing.T) { } } - syntax.Inspect(f, func { n | + syntax.Inspect(f, func { n -> if decl, _ := n.(*syntax.TypeDecl); decl != nil { if tv, ok := info.Types[decl.Type]; ok && decl.Name.Value == "T" { want := strings.Count(src, ";") + 1 @@ -895,7 +895,7 @@ func _cgoCheckPointer(interface{}, interface{}) //go:linkname _cgoCheckResult runtime.cgoCheckResult func _cgoCheckResult(interface{}) ` - testFiles(t, []string{"p.go", "_cgo_gotypes.go"}, [][]byte{[]byte(src), []byte(cgoTypes)}, 0, false, func { cfg | *boolFieldAddr(cfg, "go115UsesCgo") = true }) + testFiles(t, []string{"p.go", "_cgo_gotypes.go"}, [][]byte{[]byte(src), []byte(cgoTypes)}, 0, false, func { cfg -> *boolFieldAddr(cfg, "go115UsesCgo") = true }) } func TestIssue61931(t *testing.T) { diff --git a/src/cmd/compile/internal/types2/labels.go b/src/cmd/compile/internal/types2/labels.go index 0b4c39445be04..5755fcda364dc 100644 --- a/src/cmd/compile/internal/types2/labels.go +++ b/src/cmd/compile/internal/types2/labels.go @@ -119,7 +119,7 @@ func (check *Checker) blockBranches(all *Scope, parent *block, lstmt *syntax.Lab } var stmtBranches func(syntax.Stmt) - stmtBranches = func { s | + stmtBranches = func { s -> switch s := s.(type) { case *syntax.DeclStmt: for _, d := range s.DeclList { diff --git a/src/cmd/compile/internal/types2/mono.go b/src/cmd/compile/internal/types2/mono.go index 33d30053bb1e2..8add39b948f92 100644 --- a/src/cmd/compile/internal/types2/mono.go +++ b/src/cmd/compile/internal/types2/mono.go @@ -206,7 +206,7 @@ func (w *monoGraph) assign(pkg *Package, pos syntax.Pos, tpar *TypeParam, targ T // Recursively walk the type argument to find any defined types or // type parameters. var do func(typ Type) - do = func { typ | + do = func { typ -> switch typ := Unalias(typ).(type) { default: panic("unexpected type") diff --git a/src/cmd/compile/internal/types2/named_test.go b/src/cmd/compile/internal/types2/named_test.go index 06dac6b51509f..ada3e062db61a 100644 --- a/src/cmd/compile/internal/types2/named_test.go +++ b/src/cmd/compile/internal/types2/named_test.go @@ -50,9 +50,9 @@ type Inst = G[int] {"user instance", UserInst}, } - b.Run("Underlying", func { b | + b.Run("Underlying", func { b -> for _, test := range tests { - b.Run(test.name, func { b | + b.Run(test.name, func { b -> // Access underlying once, to trigger any lazy calculation. _ = test.typ.Underlying() b.ResetTimer() diff --git a/src/cmd/compile/internal/types2/object_test.go b/src/cmd/compile/internal/types2/object_test.go index d39cd7947a4d6..3768747cfd7cc 100644 --- a/src/cmd/compile/internal/types2/object_test.go +++ b/src/cmd/compile/internal/types2/object_test.go @@ -112,7 +112,7 @@ func TestObjectString(t *testing.T) { testenv.MustHaveGoBuild(t) for i, test := range testObjects { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> src := "package p; " + test.src conf := Config{Error: func(error) {}, Importer: defaultImporter(), EnableAlias: test.alias} pkg, err := typecheck(src, &conf, nil) diff --git a/src/cmd/compile/internal/types2/operand.go b/src/cmd/compile/internal/types2/operand.go index 11ca774d7545a..2b3cb57f0923c 100644 --- a/src/cmd/compile/internal/types2/operand.go +++ b/src/cmd/compile/internal/types2/operand.go @@ -280,7 +280,7 @@ func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Cod if Tp != nil { // T is a type parameter: x is assignable to T if it is // representable by each specific type in the type set of T. - return Tp.is(func { t | + return Tp.is(func { t -> if t == nil { return false } @@ -360,7 +360,7 @@ func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Cod if !hasName(V) && Tp != nil { ok := false code := IncompatibleAssign - Tp.is(func { T | + Tp.is(func { T -> if T == nil { return false // no specific types } @@ -381,7 +381,7 @@ func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Cod x := *x // don't clobber outer x ok := false code := IncompatibleAssign - Vp.is(func { V | + Vp.is(func { V -> if V == nil { return false // no specific types } diff --git a/src/cmd/compile/internal/types2/predicates.go b/src/cmd/compile/internal/types2/predicates.go index c2a65037284e3..e0f27e3aec3d4 100644 --- a/src/cmd/compile/internal/types2/predicates.go +++ b/src/cmd/compile/internal/types2/predicates.go @@ -51,7 +51,7 @@ func allNumericOrString(t Type) bool { return allBasic(t, IsNumeric|IsString) } // allBasic(t, info) is an optimized version of isBasic(coreType(t), info). func allBasic(t Type, info BasicInfo) bool { if tpar, _ := Unalias(t).(*TypeParam); tpar != nil { - return tpar.is(func { t | return t != nil && isBasic(t.typ, info) }) + return tpar.is(func { t -> return t != nil && isBasic(t.typ, info) }) } return isBasic(t, info) } @@ -209,7 +209,7 @@ func hasNil(t Type) bool { case *Slice, *Pointer, *Signature, *Map, *Chan: return true case *Interface: - return !isTypeParam(t) || u.typeSet().underIs(func { u | return u != nil && hasNil(u) }) + return !isTypeParam(t) || u.typeSet().underIs(func { u -> return u != nil && hasNil(u) }) } return false } diff --git a/src/cmd/compile/internal/types2/resolver_test.go b/src/cmd/compile/internal/types2/resolver_test.go index 031d082a325de..74b8f25511b01 100644 --- a/src/cmd/compile/internal/types2/resolver_test.go +++ b/src/cmd/compile/internal/types2/resolver_test.go @@ -139,7 +139,7 @@ func TestResolveIdents(t *testing.T) { // check that qualified identifiers are resolved for _, f := range files { - syntax.Inspect(f, func { n | + syntax.Inspect(f, func { n -> if s, ok := n.(*syntax.SelectorExpr); ok { if x, ok := s.X.(*syntax.Name); ok { obj := uses[x] @@ -173,7 +173,7 @@ func TestResolveIdents(t *testing.T) { foundDefs := make(map[*syntax.Name]bool) var both []string for _, f := range files { - syntax.Inspect(f, func { n | + syntax.Inspect(f, func { n -> if x, ok := n.(*syntax.Name); ok { var objects int if _, found := uses[x]; found { diff --git a/src/cmd/compile/internal/types2/self_test.go b/src/cmd/compile/internal/types2/self_test.go index 1667f1d2f0827..e02f63dd1d12f 100644 --- a/src/cmd/compile/internal/types2/self_test.go +++ b/src/cmd/compile/internal/types2/self_test.go @@ -41,16 +41,16 @@ func BenchmarkCheck(b *testing.B) { filepath.Join("src", "runtime"), filepath.Join("src", "go", "internal", "gcimporter"), } { - b.Run(path.Base(p), func { b | + b.Run(path.Base(p), func { b -> path := filepath.Join(runtime.GOROOT(), p) for _, ignoreFuncBodies := range []bool{false, true} { name := "funcbodies" if ignoreFuncBodies { name = "nofuncbodies" } - b.Run(name, func { b | - b.Run("info", func { b | runbench(b, path, ignoreFuncBodies, true) }) - b.Run("noinfo", func { b | runbench(b, path, ignoreFuncBodies, false) }) + b.Run(name, func { b -> + b.Run("info", func { b -> runbench(b, path, ignoreFuncBodies, true) }) + b.Run("noinfo", func { b -> runbench(b, path, ignoreFuncBodies, false) }) }) } }) diff --git a/src/cmd/compile/internal/types2/signature.go b/src/cmd/compile/internal/types2/signature.go index 9a734542d5836..996eef23173df 100644 --- a/src/cmd/compile/internal/types2/signature.go +++ b/src/cmd/compile/internal/types2/signature.go @@ -182,7 +182,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams [] } params, variadic := check.collectParams(scope, ftyp.ParamList, true, scopePos) results, _ := check.collectParams(scope, ftyp.ResultList, false, scopePos) - scope.Squash(func { obj, alt | + scope.Squash(func { obj, alt -> err := check.newError(DuplicateDecl) err.addf(obj, "%s redeclared in this block", obj.Name()) err.addAltDecl(alt) diff --git a/src/cmd/compile/internal/types2/sizes_test.go b/src/cmd/compile/internal/types2/sizes_test.go index 005f0c3de8cc8..f9ca305b966a8 100644 --- a/src/cmd/compile/internal/types2/sizes_test.go +++ b/src/cmd/compile/internal/types2/sizes_test.go @@ -114,7 +114,7 @@ var s struct { want := []int64{0, 8, 16} for _, arch := range []string{"386", "amd64"} { - t.Run(arch, func { t | + t.Run(arch, func { t -> conf := types2.Config{ Importer: defaultImporter(), Sizes: types2.SizesFor("gc", arch), @@ -185,7 +185,7 @@ func TestGCSizes(t *testing.T) { types2.DefPredeclaredTestFuncs() for _, tc := range gcSizesTests { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() conf := types2.Config{Importer: defaultImporter(), Sizes: types2.SizesFor("gc", "amd64")} mustTypecheck(tc.src, &conf, nil) diff --git a/src/cmd/compile/internal/types2/stdlib_test.go b/src/cmd/compile/internal/types2/stdlib_test.go index aa84e131e9b10..a4e7c8fe6508b 100644 --- a/src/cmd/compile/internal/types2/stdlib_test.go +++ b/src/cmd/compile/internal/types2/stdlib_test.go @@ -37,7 +37,7 @@ func TestStdlib(t *testing.T) { // Collect non-test files. dirFiles := make(map[string][]string) root := filepath.Join(testenv.GOROOT(t), "src") - walkPkgDirs(root, func { dir, filenames | dirFiles[dir] = filenames }, t.Error) + walkPkgDirs(root, func { dir, filenames -> dirFiles[dir] = filenames }, t.Error) c := &stdlibChecker{ dirFiles: dirFiles, @@ -178,7 +178,7 @@ func firstComment(filename string) (first string) { } }() - syntax.CommentsDo(src, func { _, _, text | + syntax.CommentsDo(src, func { _, _, text -> if text[0] != '/' { return // not a comment } diff --git a/src/cmd/compile/internal/types2/stmt.go b/src/cmd/compile/internal/types2/stmt.go index d813b4d710dca..3c89fcd382a52 100644 --- a/src/cmd/compile/internal/types2/stmt.go +++ b/src/cmd/compile/internal/types2/stmt.go @@ -60,7 +60,7 @@ func (check *Checker) usage(scope *Scope) { unused = append(unused, v) } } - sort.Slice(unused, func { i, j | return cmpPos(unused[i].pos, unused[j].pos) < 0 }) + sort.Slice(unused, func { i, j -> return cmpPos(unused[i].pos, unused[j].pos) < 0 }) for _, v := range unused { check.softErrorf(v.pos, UnusedVar, "declared and not used: %s", v.name) } @@ -859,7 +859,7 @@ func (check *Checker) rangeStmt(inner stmtContext, s *syntax.ForStmt, rclause *s var key, val Type if x.mode != invalid { // Ranging over a type parameter is permitted if it has a core type. - k, v, cause, ok := rangeKeyVal(x.typ, func { v | return check.allowVersion(x.expr, v) }) + k, v, cause, ok := rangeKeyVal(x.typ, func { v -> return check.allowVersion(x.expr, v) }) switch { case !ok && cause != "": check.softErrorf(&x, InvalidRangeExpr, "cannot range over %s: %s", &x, cause) diff --git a/src/cmd/compile/internal/types2/typeset.go b/src/cmd/compile/internal/types2/typeset.go index 3a3a6f2b6f1dc..3c5373cae0f5d 100644 --- a/src/cmd/compile/internal/types2/typeset.go +++ b/src/cmd/compile/internal/types2/typeset.go @@ -43,7 +43,7 @@ func (s *_TypeSet) IsComparable(seen map[Type]bool) bool { if s.terms.isAll() { return s.comparable } - return s.is(func { t | return t != nil && comparable(t.typ, false, seen, nil) }) + return s.is(func { t -> return t != nil && comparable(t.typ, false, seen, nil) }) } // NumMethods returns the number of methods available. diff --git a/src/cmd/compile/internal/types2/under.go b/src/cmd/compile/internal/types2/under.go index 623d5578f6afa..b9e0a92e92ece 100644 --- a/src/cmd/compile/internal/types2/under.go +++ b/src/cmd/compile/internal/types2/under.go @@ -29,7 +29,7 @@ func coreType(t Type) Type { } var su Type - if tpar.underIs(func { u | + if tpar.underIs(func { u -> if u == nil { return false } @@ -60,7 +60,7 @@ func coreString(t Type) Type { var su Type hasString := false - if tpar.underIs(func { u | + if tpar.underIs(func { u -> if u == nil { return false } diff --git a/src/cmd/compile/internal/walk/assign.go b/src/cmd/compile/internal/walk/assign.go index eb4ddd9ea3f78..277e9f4fd475b 100644 --- a/src/cmd/compile/internal/walk/assign.go +++ b/src/cmd/compile/internal/walk/assign.go @@ -293,7 +293,7 @@ func ascompatee(op ir.Op, nl, nr []ir.Node) []ir.Node { if deferResultWrite { return true } - return ir.Any(n, func { n | + return ir.Any(n, func { n -> if n.Op() == ir.ONAME && assigned.Has(n.(*ir.Name)) { return true } diff --git a/src/cmd/compile/internal/walk/complit.go b/src/cmd/compile/internal/walk/complit.go index ef2780f766f25..b113be4f09523 100644 --- a/src/cmd/compile/internal/walk/complit.go +++ b/src/cmd/compile/internal/walk/complit.go @@ -195,7 +195,7 @@ func fixedlit(ctxt initContext, kind initKind, n *ir.CompLitExpr, var_ ir.Node, switch n.Op() { case ir.OARRAYLIT, ir.OSLICELIT: var k int64 - splitnode = func { r | + splitnode = func { r -> if r.Op() == ir.OKEY { kv := r.(*ir.KeyExpr) k = typecheck.IndexConst(kv.Key) @@ -212,7 +212,7 @@ func fixedlit(ctxt initContext, kind initKind, n *ir.CompLitExpr, var_ ir.Node, return a, r } case ir.OSTRUCTLIT: - splitnode = func { rn | + splitnode = func { rn -> r := rn.(*ir.StructKeyExpr) if r.Sym().IsBlank() || isBlank { return ir.BlankNode, r.Value @@ -642,7 +642,7 @@ func oaslit(n *ir.AssignStmt, init *ir.Nodes) bool { return false case ir.OSTRUCTLIT, ir.OARRAYLIT, ir.OSLICELIT, ir.OMAPLIT: - if ir.Any(n.Y, func { y | return ir.Uses(y, x) }) { + if ir.Any(n.Y, func { y -> return ir.Uses(y, x) }) { // not safe to do a special composite literal assignment if RHS uses LHS. return false } diff --git a/src/cmd/compile/internal/walk/convert.go b/src/cmd/compile/internal/walk/convert.go index 804dce82dc77f..424350d6666b9 100644 --- a/src/cmd/compile/internal/walk/convert.go +++ b/src/cmd/compile/internal/walk/convert.go @@ -486,7 +486,7 @@ func walkCheckPtrArithmetic(n *ir.ConvExpr, init *ir.Nodes) ir.Node { // pointers, usually for alignment." var originals []ir.Node var walk func(n ir.Node) - walk = func { n | + walk = func { n -> switch n.Op() { case ir.OADD: n := n.(*ir.BinaryExpr) diff --git a/src/cmd/compile/internal/walk/switch.go b/src/cmd/compile/internal/walk/switch.go index 0cca5422c720f..d7f5538d88156 100644 --- a/src/cmd/compile/internal/walk/switch.go +++ b/src/cmd/compile/internal/walk/switch.go @@ -172,7 +172,7 @@ func (s *exprSwitch) flush() { // much cheaper to compare lengths than values, and // all we need here is consistency. We respect this // sorting below. - sort.Slice(cc, func { i, j | + sort.Slice(cc, func { i, j -> si := ir.StringVal(cc[i].lo) sj := ir.StringVal(cc[j].lo) if len(si) != len(sj) { @@ -248,7 +248,7 @@ func (s *exprSwitch) flush() { return } - sort.Slice(cc, func { i, j | return constant.Compare(cc[i].lo.Val(), token.LSS, cc[j].lo.Val()) }) + sort.Slice(cc, func { i, j -> return constant.Compare(cc[i].lo.Val(), token.LSS, cc[j].lo.Val()) }) // Merge consecutive integer cases. if s.exprname.Type().IsInteger() { @@ -277,8 +277,8 @@ func (s *exprSwitch) search(cc []exprClause, out *ir.Nodes) { return } binarySearch(len(cc), out, - func { i | return ir.NewBinaryExpr(base.Pos, ir.OLE, s.exprname, cc[i-1].hi) }, - func { i, nif | + func { i -> return ir.NewBinaryExpr(base.Pos, ir.OLE, s.exprname, cc[i-1].hi) }, + func { i, nif -> c := &cc[i] nif.Cond = c.test(s.exprname) nif.Body = []ir.Node{c.jmp} @@ -724,7 +724,7 @@ func (s *typeSwitch) flush(cc []typeClause, compiled *ir.Nodes) { return } - sort.Slice(cc, func { i, j | return cc[i].hash < cc[j].hash }) + sort.Slice(cc, func { i, j -> return cc[i].hash < cc[j].hash }) // Combine adjacent cases with the same hash. merged := cc[:1] @@ -742,8 +742,8 @@ func (s *typeSwitch) flush(cc []typeClause, compiled *ir.Nodes) { return } binarySearch(len(cc), compiled, - func { i | return ir.NewBinaryExpr(base.Pos, ir.OLE, s.hashName, ir.NewInt(base.Pos, int64(cc[i-1].hash))) }, - func { i, nif | + func { i -> return ir.NewBinaryExpr(base.Pos, ir.OLE, s.hashName, ir.NewInt(base.Pos, int64(cc[i-1].hash))) }, + func { i, nif -> // TODO(mdempsky): Omit hash equality check if // there's only one type. c := cc[i] @@ -777,7 +777,7 @@ func (s *typeSwitch) tryJumpTable(cc []typeClause, out *ir.Nodes) bool { hashes = append(hashes, h) } // Order by increasing hash. - sort.Slice(hashes, func { j, k | return hashes[j] < hashes[k] }) + sort.Slice(hashes, func { j, k -> return hashes[j] < hashes[k] }) for j := 1; j < len(hashes); j++ { if hashes[j] == hashes[j-1] { // There is a duplicate hash; try a different b/i pair. @@ -841,7 +841,7 @@ func binarySearch(n int, out *ir.Nodes, less func(i int) ir.Node, leaf func(i in const binarySearchMin = 4 // minimum number of cases for binary search var do func(lo, hi int, out *ir.Nodes) - do = func { lo, hi, out | + do = func { lo, hi, out -> n := hi - lo if n < binarySearchMin { for i := lo; i < hi; i++ { diff --git a/src/cmd/compile/internal/walk/walk.go b/src/cmd/compile/internal/walk/walk.go index e432b7faa94d9..5ef607d5b8df2 100644 --- a/src/cmd/compile/internal/walk/walk.go +++ b/src/cmd/compile/internal/walk/walk.go @@ -277,7 +277,7 @@ func mayCall(n ir.Node) bool { return types.IsFloat[typ.Kind()] || types.IsComplex[typ.Kind()] } - return ir.Any(n, func { n | + return ir.Any(n, func { n -> // walk should have already moved any Init blocks off of // expressions. if len(n.Init()) != 0 { diff --git a/src/cmd/covdata/covdata.go b/src/cmd/covdata/covdata.go index 16195db9e1ad6..3108e30db2d73 100644 --- a/src/cmd/covdata/covdata.go +++ b/src/cmd/covdata/covdata.go @@ -164,7 +164,7 @@ func main() { f := pkgpattern.MatchSimplePattern(p) matchers = append(matchers, f) } - matchpkg = func { name | + matchpkg = func { name -> for _, f := range matchers { if f(name) { return true diff --git a/src/cmd/covdata/tool_test.go b/src/cmd/covdata/tool_test.go index 11d1a843670f4..744fd917aa844 100644 --- a/src/cmd/covdata/tool_test.go +++ b/src/cmd/covdata/tool_test.go @@ -229,54 +229,54 @@ func TestCovTool(t *testing.T) { // At this point we can fork off a bunch of child tests // to check different tool modes. - t.Run("MergeSimple", func { t | + t.Run("MergeSimple", func { t -> t.Parallel() testMergeSimple(t, s, s.outdirs[0], s.outdirs[1], "set") testMergeSimple(t, s, s.outdirs[2], s.outdirs[3], "atomic") }) - t.Run("MergeSelect", func { t | + t.Run("MergeSelect", func { t -> t.Parallel() testMergeSelect(t, s, s.outdirs[0], s.outdirs[1], "set") testMergeSelect(t, s, s.outdirs[2], s.outdirs[3], "atomic") }) - t.Run("MergePcombine", func { t | + t.Run("MergePcombine", func { t -> t.Parallel() testMergeCombinePrograms(t, s) }) - t.Run("Dump", func { t | + t.Run("Dump", func { t -> t.Parallel() testDump(t, s) }) - t.Run("Percent", func { t | + t.Run("Percent", func { t -> t.Parallel() testPercent(t, s) }) - t.Run("PkgList", func { t | + t.Run("PkgList", func { t -> t.Parallel() testPkgList(t, s) }) - t.Run("Textfmt", func { t | + t.Run("Textfmt", func { t -> t.Parallel() testTextfmt(t, s) }) - t.Run("Subtract", func { t | + t.Run("Subtract", func { t -> t.Parallel() testSubtract(t, s) }) - t.Run("Intersect", func { t | + t.Run("Intersect", func { t -> t.Parallel() testIntersect(t, s, s.outdirs[0], s.outdirs[1], "set") testIntersect(t, s, s.outdirs[2], s.outdirs[3], "atomic") }) - t.Run("CounterClash", func { t | + t.Run("CounterClash", func { t -> t.Parallel() testCounterClash(t, s) }) - t.Run("TestEmpty", func { t | + t.Run("TestEmpty", func { t -> t.Parallel() testEmpty(t, s) }) - t.Run("TestCommandLineErrors", func { t | + t.Run("TestCommandLineErrors", func { t -> t.Parallel() testCommandLineErrors(t, s, s.outdirs[0]) }) diff --git a/src/cmd/cover/cfg_test.go b/src/cmd/cover/cfg_test.go index 784cb2763b0cc..cac9ae347ab9b 100644 --- a/src/cmd/cover/cfg_test.go +++ b/src/cmd/cover/cfg_test.go @@ -175,8 +175,8 @@ func TestCoverOnPackageWithNoTestFiles(t *testing.T) { // simulating the effect that you would get if you added a dummy // "no-op" x_test.go file and then did a build and run of the test. - t.Run("YesFuncsNoTests", func { t | testCoverNoTestsYesFuncs(t) }) - t.Run("NoFuncsNoTests", func { t | testCoverNoTestsNoFuncs(t) }) + t.Run("YesFuncsNoTests", func { t -> testCoverNoTestsYesFuncs(t) }) + t.Run("NoFuncsNoTests", func { t -> testCoverNoTestsNoFuncs(t) }) } func testCoverNoTestsYesFuncs(t *testing.T) { diff --git a/src/cmd/cover/cover.go b/src/cmd/cover/cover.go index ea494fad09477..c856135d4eb86 100644 --- a/src/cmd/cover/cover.go +++ b/src/cmd/cover/cover.go @@ -541,7 +541,7 @@ func (f *File) postFunc(fn ast.Node, funcname string, flit bool, body *ast.Block return fmt.Sprintf("%s[%d] = %s", cv, which, val) } if *mode == "atomic" { - hookWrite = func { cv, which, val | return fmt.Sprintf("%sStoreUint32(&%s[%d], %s)", + hookWrite = func { cv, which, val -> return fmt.Sprintf("%sStoreUint32(&%s[%d], %s)", atomicPackagePrefix(), cv, which, val) } } diff --git a/src/cmd/cover/cover_test.go b/src/cmd/cover/cover_test.go index 0875ee8fe04a3..b5ffc28517283 100644 --- a/src/cmd/cover/cover_test.go +++ b/src/cmd/cover/cover_test.go @@ -117,10 +117,10 @@ func TestCoverWithToolExec(t *testing.T) { toolexecArg := "-toolexec=" + testcover(t) - t.Run("CoverHTML", func { t | testCoverHTML(t, toolexecArg) }) - t.Run("HtmlUnformatted", func { t | testHtmlUnformatted(t, toolexecArg) }) - t.Run("FuncWithDuplicateLines", func { t | testFuncWithDuplicateLines(t, toolexecArg) }) - t.Run("MissingTrailingNewlineIssue58370", func { t | testMissingTrailingNewlineIssue58370(t, toolexecArg) }) + t.Run("CoverHTML", func { t -> testCoverHTML(t, toolexecArg) }) + t.Run("HtmlUnformatted", func { t -> testHtmlUnformatted(t, toolexecArg) }) + t.Run("FuncWithDuplicateLines", func { t -> testFuncWithDuplicateLines(t, toolexecArg) }) + t.Run("MissingTrailingNewlineIssue58370", func { t -> testMissingTrailingNewlineIssue58370(t, toolexecArg) }) } // Execute this command sequence: diff --git a/src/cmd/dist/build.go b/src/cmd/dist/build.go index e4b2bc8dd977d..74409fab8c867 100644 --- a/src/cmd/dist/build.go +++ b/src/cmd/dist/build.go @@ -747,7 +747,7 @@ func runInstall(pkg string, ch chan struct{}) { // This is the same heuristic build.ScanDir uses. // There do exist real C files beginning with _, // so limit that check to just Go files. - files = filter(files, func { p | return !strings.HasPrefix(p, ".") && (!strings.HasPrefix(p, "_") || !strings.HasSuffix(p, ".go")) }) + files = filter(files, func { p -> return !strings.HasPrefix(p, ".") && (!strings.HasPrefix(p, "_") || !strings.HasSuffix(p, ".go")) }) // Add generated files for this package. for _, gt := range gentab { @@ -767,7 +767,7 @@ func runInstall(pkg string, ch chan struct{}) { // Is the target up-to-date? var gofiles, sfiles []string stale := rebuildall - files = filter(files, func { p | + files = filter(files, func { p -> for _, suf := range depsuffix { if strings.HasSuffix(p, suf) { goto ok @@ -1164,7 +1164,7 @@ func clean() { generated := []byte(generatedHeader) // Remove generated source files. - filepath.WalkDir(pathf("%s/src", goroot), func { path, d, err | + filepath.WalkDir(pathf("%s/src", goroot), func { path, d, err -> switch { case err != nil: // ignore diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go index 8af28e0f1626a..335ec46be4011 100644 --- a/src/cmd/dist/buildtool.go +++ b/src/cmd/dist/buildtool.go @@ -155,7 +155,7 @@ func bootstrapBuildTools() { for _, dir := range bootstrapDirs { recurse := strings.HasSuffix(dir, "/...") dir = strings.TrimSuffix(dir, "/...") - filepath.Walk(dir, func { path, info, err | + filepath.Walk(dir, func { path, info, err -> if err != nil { fatalf("walking bootstrap dirs failed: %v: %v", path, err) } diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go index a2b64b96ccae8..5c7110113f3f2 100644 --- a/src/cmd/dist/test.go +++ b/src/cmd/dist/test.go @@ -484,7 +484,7 @@ func (opts *goTest) buildArgs(t *tester) (build, run, pkgs, testFlags []string, testFlags = append(testFlags, "-target="+goos+"/"+goarch) } - setupCmd = func { cmd | + setupCmd = func { cmd -> setDir(cmd, filepath.Join(goroot, "src")) if len(opts.env) != 0 { for _, kv := range opts.env { @@ -550,7 +550,7 @@ func (t *tester) registerStdTest(pkg string) { if t.runRx == nil || t.runRx.MatchString(name) == t.runRxWant { stdMatches = append(stdMatches, pkg) } - t.addTest(name, stdTestHeading, func { dt | + t.addTest(name, stdTestHeading, func { dt -> if ranGoTest { return nil } @@ -580,7 +580,7 @@ func (t *tester) registerRaceBenchTest(pkg string) { if t.runRx == nil || t.runRx.MatchString(name) == t.runRxWant { benchMatches = append(benchMatches, pkg) } - t.addTest(name, raceBenchHeading, func { dt | + t.addTest(name, raceBenchHeading, func { dt -> if ranGoBench { return nil } @@ -969,7 +969,7 @@ func (t *tester) registerTest(heading string, test *goTest, opts ...registerTest panic("empty variant") } name := testName(test.pkg, test.variant) - t.addTest(name, heading, func { dt | + t.addTest(name, heading, func { dt -> if skipFunc != nil { msg, skip := skipFunc(dt) if skip { @@ -1518,7 +1518,7 @@ func (t *tester) makeGOROOTUnwritable() (undo func()) { } } - filepath.WalkDir(dir, func { path, d, err | + filepath.WalkDir(dir, func { path, d, err -> if suffix := strings.TrimPrefix(path, dir+string(filepath.Separator)); suffix != "" { if suffix == ".git" { // Leave Git metadata in whatever state it was in. It may contain a lot diff --git a/src/cmd/dist/testjson.go b/src/cmd/dist/testjson.go index c6bf6f0d25e4d..15b5299f5c475 100644 --- a/src/cmd/dist/testjson.go +++ b/src/cmd/dist/testjson.go @@ -155,7 +155,7 @@ func decodeJSONValue(dec *json.Decoder) (jsonValue, error) { func (v jsonValue) MarshalJSON() ([]byte, error) { var buf bytes.Buffer var marshal1 func(v jsonValue) error - marshal1 = func { v | + marshal1 = func { v -> if t, ok := v.atom.(json.Delim); ok { buf.WriteRune(rune(t)) for i, v2 := range v.seq { diff --git a/src/cmd/dist/testjson_test.go b/src/cmd/dist/testjson_test.go index 655dc7dcee607..d7374908cc322 100644 --- a/src/cmd/dist/testjson_test.go +++ b/src/cmd/dist/testjson_test.go @@ -45,14 +45,14 @@ func TestJSONFilterBoundaries(t *testing.T) { want := strings.ReplaceAll(in, `"}`, `:variant"}`) // Write one bytes at a time. - t.Run("bytes", func { t | - checkJSONFilterWith(t, want, func { f | for i := 0; i < len(in); i++ { + t.Run("bytes", func { t -> + checkJSONFilterWith(t, want, func { f -> for i := 0; i < len(in); i++ { f.Write([]byte{in[i]}) } }) }) // Write a block containing a whole line bordered by two partial lines. - t.Run("bytes", func { t | - checkJSONFilterWith(t, want, func { f | + t.Run("bytes", func { t -> + checkJSONFilterWith(t, want, func { f -> const b1 = 5 const b2 = len(in) - 5 f.Write([]byte(in[:b1])) @@ -64,7 +64,7 @@ func TestJSONFilterBoundaries(t *testing.T) { func checkJSONFilter(t *testing.T, in, want string) { t.Helper() - checkJSONFilterWith(t, want, func { f | f.Write([]byte(in)) }) + checkJSONFilterWith(t, want, func { f -> f.Write([]byte(in)) }) } func checkJSONFilterWith(t *testing.T, want string, write func(*testJSONFilter)) { diff --git a/src/cmd/distpack/archive.go b/src/cmd/distpack/archive.go index 53b363ffd0abe..982e8d7a19e38 100644 --- a/src/cmd/distpack/archive.go +++ b/src/cmd/distpack/archive.go @@ -56,7 +56,7 @@ func (i fileInfo) String() string { // The archive can be amended afterward using methods like Add and Filter. func NewArchive(dir string) (*Archive, error) { a := new(Archive) - err := fs.WalkDir(os.DirFS(dir), ".", func { name, d, err | + err := fs.WalkDir(os.DirFS(dir), ".", func { name, d, err -> if err != nil { return err } @@ -112,7 +112,7 @@ func nameLess(x, y string) bool { // NewArchive returns a sorted archive, and the other methods // preserve the sorting of the archive. func (a *Archive) Sort() { - sort.Slice(a.Files, func { i, j | return nameLess(a.Files[i].Name, a.Files[j].Name) }) + sort.Slice(a.Files, func { i, j -> return nameLess(a.Files[i].Name, a.Files[j].Name) }) } // Clone returns a copy of the Archive. @@ -157,7 +157,7 @@ func (a *Archive) SetMode(mode func(name string, m fs.FileMode) fs.FileMode) { // a leading **/ or trailing /**, which match any number of path elements // (including no path elements) before or after the main match. func (a *Archive) Remove(patterns ...string) { - a.Filter(func { name | + a.Filter(func { name -> for _, pattern := range patterns { match, err := amatch(pattern, name) if err != nil { diff --git a/src/cmd/distpack/pack.go b/src/cmd/distpack/pack.go index ef855d4bf7b05..2f15906b91c58 100644 --- a/src/cmd/distpack/pack.go +++ b/src/cmd/distpack/pack.go @@ -148,7 +148,7 @@ func main() { // The binary distribution includes only a subset of bin and pkg. binArch := base.Clone() - binArch.Filter(func { name | + binArch.Filter(func { name -> // Discard bin/ for now, will add back later. if strings.HasPrefix(name, "bin/") { return false @@ -351,7 +351,7 @@ func writeTgz(name string, a *Archive) { // these tar files expect that. See go.dev/issue/61862. haveDir := map[string]bool{".": true} var mkdirAll func(string) - mkdirAll = func { dir | + mkdirAll = func { dir -> if dir == "/" { panic("mkdirAll /") } @@ -409,7 +409,7 @@ func writeZip(name string, a *Archive) { }() zw := zip.NewWriter(out) - zw.RegisterCompressor(zip.Deflate, func { out | return flate.NewWriter(out, flate.BestCompression) }) + zw.RegisterCompressor(zip.Deflate, func { out -> return flate.NewWriter(out, flate.BestCompression) }) for _, f = range a.Files { h := check(zip.FileInfoHeader(f.Info())) h.Name = f.Name diff --git a/src/cmd/fix/cftype.go b/src/cmd/fix/cftype.go index d767fbe715d18..a75d6d0d97425 100644 --- a/src/cmd/fix/cftype.go +++ b/src/cmd/fix/cftype.go @@ -34,7 +34,7 @@ var cftypeFix = fix{ // and similar for other *Ref types. // This fix finds nils initializing these types and replaces the nils with 0s. func cftypefix(f *ast.File) bool { - return typefix(f, func { s | return strings.HasPrefix(s, "C.") && strings.HasSuffix(s, "Ref") && s != "C.CFAllocatorRef" }) + return typefix(f, func { s -> return strings.HasPrefix(s, "C.") && strings.HasSuffix(s, "Ref") && s != "C.CFAllocatorRef" }) } // typefix replaces nil with 0 for all nils whose type, when passed to badType, returns true. @@ -48,7 +48,7 @@ func typefix(f *ast.File, badType func(string) bool) bool { // step 1: Find all the nils with the offending types. // Compute their replacement. badNils := map[any]ast.Expr{} - walk(f, func { n | + walk(f, func { n -> if i, ok := n.(*ast.Ident); ok && i.Name == "nil" && badType(typeof[n]) { badNils[n] = &ast.BasicLit{ValuePos: i.NamePos, Kind: token.INT, Value: "0"} } @@ -60,7 +60,7 @@ func typefix(f *ast.File, badType func(string) bool) bool { if len(badNils) > 0 { exprType := reflect.TypeFor[ast.Expr]() exprSliceType := reflect.TypeFor[[]ast.Expr]() - walk(f, func { n | + walk(f, func { n -> if n == nil { return } @@ -101,7 +101,7 @@ func typefix(f *ast.File, badType func(string) bool) bool { // Now we need unsafe.Pointer as an intermediate cast. // (*unsafe.Pointer)(x) where x is type *bad -> (*unsafe.Pointer)(unsafe.Pointer(x)) // (*bad.type)(x) where x is type *unsafe.Pointer -> (*bad.type)(unsafe.Pointer(x)) - walk(f, func { n | + walk(f, func { n -> if n == nil { return } diff --git a/src/cmd/fix/egltype.go b/src/cmd/fix/egltype.go index 89e884dde373c..990da3501c302 100644 --- a/src/cmd/fix/egltype.go +++ b/src/cmd/fix/egltype.go @@ -31,7 +31,7 @@ var eglFixDisplay = fix{ // // This fix finds nils initializing these types and replaces the nils with 0s. func eglfixDisp(f *ast.File) bool { - return typefix(f, func { s | return s == "C.EGLDisplay" }) + return typefix(f, func { s -> return s == "C.EGLDisplay" }) } var eglFixConfig = fix{ @@ -52,5 +52,5 @@ var eglFixConfig = fix{ // // This fix finds nils initializing these types and replaces the nils with 0s. func eglfixConfig(f *ast.File) bool { - return typefix(f, func { s | return s == "C.EGLConfig" }) + return typefix(f, func { s -> return s == "C.EGLConfig" }) } diff --git a/src/cmd/fix/fix.go b/src/cmd/fix/fix.go index 975a4b8f19702..67a5265f950a5 100644 --- a/src/cmd/fix/fix.go +++ b/src/cmd/fix/fix.go @@ -390,7 +390,7 @@ func renameTop(f *ast.File, old, new string) bool { // Rename top-level old to new, both unresolved names // (probably defined in another file) and names that resolve // to a declaration we renamed. - walk(f, func { n | + walk(f, func { n -> id, ok := n.(*ast.Ident) if ok && isTopName(id, old) { id.Name = new diff --git a/src/cmd/fix/gotypes.go b/src/cmd/fix/gotypes.go index 047b595801d1c..27bc9d8bb22bb 100644 --- a/src/cmd/fix/gotypes.go +++ b/src/cmd/fix/gotypes.go @@ -36,7 +36,7 @@ func fixGoExact(f *ast.File) bool { // This one is harder because the import name changes. // First find the import spec. var importSpec *ast.ImportSpec - walk(f, func { n | + walk(f, func { n -> if importSpec != nil { return } diff --git a/src/cmd/fix/jnitype.go b/src/cmd/fix/jnitype.go index 9f0c8910fcf30..7cc41f1f0fae7 100644 --- a/src/cmd/fix/jnitype.go +++ b/src/cmd/fix/jnitype.go @@ -31,7 +31,7 @@ var jniFix = fix{ // and similar for subtypes of jobject. // This fix finds nils initializing these types and replaces the nils with 0s. func jnifix(f *ast.File) bool { - return typefix(f, func { s | + return typefix(f, func { s -> switch s { case "C.jobject": return true diff --git a/src/cmd/fix/main_test.go b/src/cmd/fix/main_test.go index 6d4e964963ec2..1faee1d1e123c 100644 --- a/src/cmd/fix/main_test.go +++ b/src/cmd/fix/main_test.go @@ -87,13 +87,13 @@ func TestRewrite(t *testing.T) { // Instead, simply set it to panic on error: the goroutine dump // from the panic should help us determine which test failed. prevReportCgoError := reportCgoError - reportCgoError = func { err | panic(fmt.Sprintf("unexpected cgo error: %v", err)) } + reportCgoError = func { err -> panic(fmt.Sprintf("unexpected cgo error: %v", err)) } t.Cleanup(func() { reportCgoError = prevReportCgoError }) } for _, tt := range testCases { tt := tt - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> if tt.Version == "" { if testing.Verbose() { // Don't run in parallel: cmd/fix sometimes writes directly to stderr, diff --git a/src/cmd/fix/netipv6zone.go b/src/cmd/fix/netipv6zone.go index 8d8fd08b45ee8..6023d11a390c0 100644 --- a/src/cmd/fix/netipv6zone.go +++ b/src/cmd/fix/netipv6zone.go @@ -26,7 +26,7 @@ func netipv6zone(f *ast.File) bool { } fixed := false - walk(f, func { n | + walk(f, func { n -> cl, ok := n.(*ast.CompositeLit) if !ok { return diff --git a/src/cmd/fix/printerconfig.go b/src/cmd/fix/printerconfig.go index 78fbd52cfc3c6..8bce06ed86f78 100644 --- a/src/cmd/fix/printerconfig.go +++ b/src/cmd/fix/printerconfig.go @@ -23,7 +23,7 @@ func printerconfig(f *ast.File) bool { } fixed := false - walk(f, func { n | + walk(f, func { n -> cl, ok := n.(*ast.CompositeLit) if !ok { return diff --git a/src/cmd/go/chdir_test.go b/src/cmd/go/chdir_test.go index d02dfbf35aa70..119dbb5bc8797 100644 --- a/src/cmd/go/chdir_test.go +++ b/src/cmd/go/chdir_test.go @@ -22,7 +22,7 @@ func TestChdir(t *testing.T) { } var walk func(string, *base.Command) - walk = func { name, cmd | + walk = func { name, cmd -> if len(cmd.Commands) > 0 { for _, sub := range cmd.Commands { walk(name+" "+sub.Name(), sub) diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index ca11752776618..27ea219602e99 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -114,7 +114,7 @@ func TestMain(m *testing.M) { if testGOROOT := os.Getenv("TESTGO_GOROOT"); testGOROOT != "" { // Disallow installs to the GOROOT from which testgo was built. // Installs to other GOROOTs — such as one set explicitly within a test — are ok. - work.AllowInstall = func { a | + work.AllowInstall = func { a -> if cfg.BuildN { return nil } @@ -327,7 +327,7 @@ func TestMain(m *testing.M) { if !*testWork { // There shouldn't be anything left in topTmpdir. var extraFiles, extraDirs []string - err := filepath.WalkDir(topTmpdir, func { path, d, err | + err := filepath.WalkDir(topTmpdir, func { path, d, err -> if err != nil { return err } @@ -846,7 +846,7 @@ func (tg *testgoData) cleanup() { func removeAll(dir string) error { // module cache has 0444 directories; // make them writable in order to remove content. - filepath.WalkDir(dir, func { path, info, err | + filepath.WalkDir(dir, func { path, info, err -> // chmod not only directories, but also things that we couldn't even stat // due to permission errors: they may also be unreadable directories. if err != nil || info.IsDir() { @@ -887,7 +887,7 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) { srcdir := filepath.Join(testGOROOT, copydir) tg.tempDir(filepath.Join("goroot", copydir)) err := filepath.WalkDir(srcdir, - func { path, info, err | + func { path, info, err -> if err != nil { return err } @@ -1539,7 +1539,7 @@ func TestListTemplateContextFunction(t *testing.T) { {"InstallSuffix", ""}, } { tt := tt - t.Run(tt.v, func { t | + t.Run(tt.v, func { t -> tg := testgo(t) tg.parallel() defer tg.cleanup() @@ -2033,8 +2033,8 @@ func TestBuildmodePIE(t *testing.T) { if strings.HasSuffix(testenv.Builder(), "-alpine") { t.Skip("skipping PIE tests on alpine; see https://go.dev/issues/54354") } - t.Run("non-cgo", func { t | testBuildmodePIE(t, false, true) }) - t.Run("cgo", func { t | + t.Run("non-cgo", func { t -> testBuildmodePIE(t, false, true) }) + t.Run("cgo", func { t -> testenv.MustHaveCGO(t) testBuildmodePIE(t, true, true) }) @@ -2046,8 +2046,8 @@ func TestWindowsDefaultBuildmodIsPIE(t *testing.T) { } tooSlow(t, "links binaries") - t.Run("non-cgo", func { t | testBuildmodePIE(t, false, false) }) - t.Run("cgo", func { t | + t.Run("non-cgo", func { t -> testBuildmodePIE(t, false, false) }) + t.Run("cgo", func { t -> testenv.MustHaveCGO(t) testBuildmodePIE(t, true, false) }) diff --git a/src/cmd/go/init_test.go b/src/cmd/go/init_test.go index 486f8a236abd9..8137f20c5b818 100644 --- a/src/cmd/go/init_test.go +++ b/src/cmd/go/init_test.go @@ -24,7 +24,7 @@ func BenchmarkExecGoEnv(b *testing.B) { var n, userTime, systemTime int64 b.ResetTimer() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { cmd := testenv.Command(b, gotool, "env", "GOARCH") diff --git a/src/cmd/go/internal/cfg/cfg.go b/src/cmd/go/internal/cfg/cfg.go index b109708aeb5c3..a724ac57cd6fe 100644 --- a/src/cmd/go/internal/cfg/cfg.go +++ b/src/cmd/go/internal/cfg/cfg.go @@ -174,9 +174,9 @@ func defaultContext() build.Context { } CGOChanged = ctxt.CgoEnabled != defaultCgoEnabled - ctxt.OpenFile = func { path | return fsys.Open(path) } + ctxt.OpenFile = func { path -> return fsys.Open(path) } ctxt.ReadDir = fsys.ReadDir - ctxt.IsDir = func { path | + ctxt.IsDir = func { path -> isDir, err := fsys.IsDir(path) return err == nil && isDir } diff --git a/src/cmd/go/internal/envcmd/env.go b/src/cmd/go/internal/envcmd/env.go index a633bdc891eb3..3fa537d88efc8 100644 --- a/src/cmd/go/internal/envcmd/env.go +++ b/src/cmd/go/internal/envcmd/env.go @@ -744,5 +744,5 @@ func lineToKey(line string) string { // sortKeyValues sorts a sequence of lines by key. // It differs from sort.Strings in that GO386= sorts after GO=. func sortKeyValues(lines []string) { - sort.Slice(lines, func { i, j | return lineToKey(lines[i]) < lineToKey(lines[j]) }) + sort.Slice(lines, func { i, j -> return lineToKey(lines[i]) < lineToKey(lines[j]) }) } diff --git a/src/cmd/go/internal/envcmd/env_test.go b/src/cmd/go/internal/envcmd/env_test.go index b93af1f3636e6..48ed96678a999 100644 --- a/src/cmd/go/internal/envcmd/env_test.go +++ b/src/cmd/go/internal/envcmd/env_test.go @@ -32,7 +32,7 @@ func FuzzPrintEnvEscape(f *testing.F) { f.Add("\r") f.Add("\n") f.Add("E,%") - f.Fuzz(func { t, s | + f.Fuzz(func { t, s -> t.Parallel() for _, c := range []byte(s) { diff --git a/src/cmd/go/internal/fsys/fsys.go b/src/cmd/go/internal/fsys/fsys.go index 2e6a476c50b58..c2c9d29b6bf8e 100644 --- a/src/cmd/go/internal/fsys/fsys.go +++ b/src/cmd/go/internal/fsys/fsys.go @@ -380,7 +380,7 @@ func ReadDir(dir string) ([]fs.FileInfo, error) { for _, f := range files { sortedFiles = append(sortedFiles, f) } - sort.Slice(sortedFiles, func { i, j | return sortedFiles[i].Name() < sortedFiles[j].Name() }) + sort.Slice(sortedFiles, func { i, j -> return sortedFiles[i].Name() < sortedFiles[j].Name() }) return sortedFiles, nil } diff --git a/src/cmd/go/internal/fsys/fsys_test.go b/src/cmd/go/internal/fsys/fsys_test.go index 9f255333b812b..3ee891a9e9cc6 100644 --- a/src/cmd/go/internal/fsys/fsys_test.go +++ b/src/cmd/go/internal/fsys/fsys_test.go @@ -694,11 +694,11 @@ contents of other file } for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> initOverlay(t, tc.overlay) var got []file - Walk(tc.root, func { path, info, err | + Walk(tc.root, func { path, info, err -> got = append(got, file{path, info.Name(), info.Size(), info.Mode(), info.IsDir()}) return nil }) @@ -744,7 +744,7 @@ func TestWalkSkipDir(t *testing.T) { `) var seen []string - Walk("dir", func { path, info, err | + Walk("dir", func { path, info, err -> seen = append(seen, filepath.ToSlash(path)) if info.Name() == "skip" { return filepath.SkipDir @@ -780,7 +780,7 @@ func TestWalkSkipAll(t *testing.T) { `) var seen []string - Walk("dir", func { path, info, err | + Walk("dir", func { path, info, err -> seen = append(seen, filepath.ToSlash(path)) if info.Name() == "foo2" { return filepath.SkipAll @@ -805,7 +805,7 @@ func TestWalkError(t *testing.T) { initOverlay(t, "{}") alreadyCalled := false - err := Walk("foo", func { path, info, err | + err := Walk("foo", func { path, info, err -> if alreadyCalled { t.Fatal("expected walk function to be called exactly once, but it was called more than once") } @@ -854,10 +854,10 @@ func TestWalkSymlink(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> var got []string - err := Walk(tc.dir, func { path, info, err | + err := Walk(tc.dir, func { path, info, err -> t.Logf("walk %q", path) got = append(got, path) if err != nil { @@ -961,7 +961,7 @@ contents`, } for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> initOverlay(t, tc.overlay) got, err := Lstat(tc.path) if tc.wantErr { @@ -1078,7 +1078,7 @@ contents`, } for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> initOverlay(t, tc.overlay) got, err := Stat(tc.path) if tc.wantErr { diff --git a/src/cmd/go/internal/gover/mod.go b/src/cmd/go/internal/gover/mod.go index 04a2993e43cd3..fc511471b058a 100644 --- a/src/cmd/go/internal/gover/mod.go +++ b/src/cmd/go/internal/gover/mod.go @@ -44,7 +44,7 @@ func ModCompare(path string, x, y string) int { // ModSort is like module.Sort but understands the "go" and "toolchain" // modules and their version ordering. func ModSort(list []module.Version) { - sort.Slice(list, func { i, j | + sort.Slice(list, func { i, j -> mi := list[i] mj := list[j] if mi.Path != mj.Path { diff --git a/src/cmd/go/internal/gover/mod_test.go b/src/cmd/go/internal/gover/mod_test.go index aa52c55eb1834..d7d95ac18e844 100644 --- a/src/cmd/go/internal/gover/mod_test.go +++ b/src/cmd/go/internal/gover/mod_test.go @@ -47,7 +47,7 @@ var modIsValidTests = []testCase2[string, string, bool]{ } func TestModSort(t *testing.T) { - test1(t, modSortTests, "ModSort", func { list | + test1(t, modSortTests, "ModSort", func { list -> out := slices.Clone(list) ModSort(out) return out diff --git a/src/cmd/go/internal/imports/read_test.go b/src/cmd/go/internal/imports/read_test.go index 008da9531ca6d..c04cae56ed82a 100644 --- a/src/cmd/go/internal/imports/read_test.go +++ b/src/cmd/go/internal/imports/read_test.go @@ -159,7 +159,7 @@ func testRead(t *testing.T, tests []readTest, read func(io.Reader) ([]byte, erro } func TestReadImports(t *testing.T) { - testRead(t, readImportsTests, func { r | return ReadImports(r, true, nil) }) + testRead(t, readImportsTests, func { r -> return ReadImports(r, true, nil) }) } func TestReadComments(t *testing.T) { @@ -235,7 +235,7 @@ var readFailuresTests = []readTest{ func TestReadFailures(t *testing.T) { // Errors should be reported (true arg to readImports). - testRead(t, readFailuresTests, func { r | return ReadImports(r, true, nil) }) + testRead(t, readFailuresTests, func { r -> return ReadImports(r, true, nil) }) } func TestReadFailuresIgnored(t *testing.T) { @@ -250,5 +250,5 @@ func TestReadFailuresIgnored(t *testing.T) { tt.err = "" } } - testRead(t, tests, func { r | return ReadImports(r, false, nil) }) + testRead(t, tests, func { r -> return ReadImports(r, false, nil) }) } diff --git a/src/cmd/go/internal/imports/scan_test.go b/src/cmd/go/internal/imports/scan_test.go index 3efe2b5bb4bef..2659380262a20 100644 --- a/src/cmd/go/internal/imports/scan_test.go +++ b/src/cmd/go/internal/imports/scan_test.go @@ -64,7 +64,7 @@ func TestScanDir(t *testing.T) { if !dir.IsDir() || strings.HasPrefix(dir.Name(), ".") { continue } - t.Run(dir.Name(), func { t | + t.Run(dir.Name(), func { t -> tagsData, err := os.ReadFile(filepath.Join("testdata", dir.Name(), "tags.txt")) if err != nil { t.Fatalf("error reading tags: %v", err) diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go index 6b0c6a61c1164..c68972193153a 100644 --- a/src/cmd/go/internal/list/list.go +++ b/src/cmd/go/internal/list/list.go @@ -449,7 +449,7 @@ func runList(ctx context.Context, cmd *base.Command, args []string) { var do func(x any) if listJson { - do = func { x | + do = func { x -> if !listJsonFields.needAll() { // Set x to a copy of itself with all non-requested fields cleared. v := reflect.New(reflect.TypeOf(x).Elem()).Elem() // do is always called with a non-nil pointer. @@ -486,7 +486,7 @@ func runList(ctx context.Context, cmd *base.Command, args []string) { if err != nil { base.Fatalf("%s", err) } - do = func { x | + do = func { x -> if err := tmpl.Execute(out, x); err != nil { out.Flush() base.Fatalf("%s", err) @@ -952,7 +952,7 @@ func collectDepsErrors(p *load.Package) { // Sort packages by the package on the top of the stack, which should be // the package the error was produced for. Each package can have at most // one error set on it. - sort.Slice(p.DepsErrors, func { i, j | + sort.Slice(p.DepsErrors, func { i, j -> stki, stkj := p.DepsErrors[i].ImportStack, p.DepsErrors[j].ImportStack // Some packages are missing import stacks. To ensure deterministic // sort order compare two errors that are missing import stacks by diff --git a/src/cmd/go/internal/load/flag_test.go b/src/cmd/go/internal/load/flag_test.go index 9eca26c8301fd..0267e861dcf50 100644 --- a/src/cmd/go/internal/load/flag_test.go +++ b/src/cmd/go/internal/load/flag_test.go @@ -115,7 +115,7 @@ func TestPerPackageFlag(t *testing.T) { } for i, tt := range ppfTests { - t.Run(fmt.Sprintf("#%d", i), func { t | + t.Run(fmt.Sprintf("#%d", i), func { t -> ppFlags := new(PerPackageFlag) for _, arg := range tt.args { t.Logf("set(%s)", arg) diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go index 71163bad29272..eb56b988c0b4c 100644 --- a/src/cmd/go/internal/load/pkg.go +++ b/src/cmd/go/internal/load/pkg.go @@ -2144,7 +2144,7 @@ func resolveEmbed(pkgdir string, patterns []string) (files []string, pmap map[st // Gather all files in the named directory, stopping at module boundaries // and ignoring files that wouldn't be packaged into a module. count := 0 - err := fsys.Walk(file, func { path, info, err | + err := fsys.Walk(file, func { path, info, err -> if err != nil { return err } @@ -2247,7 +2247,7 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) { } var debugModFromModinfo func(*modinfo.ModulePublic) *debug.Module - debugModFromModinfo = func { mi | + debugModFromModinfo = func { mi -> version := mi.Version if version == "" { version = "(devel)" @@ -2657,7 +2657,7 @@ func PackageList(roots []*Package) []*Package { seen := map[*Package]bool{} all := []*Package{} var walk func(*Package) - walk = func { p | + walk = func { p -> if seen[p] { return } @@ -2680,7 +2680,7 @@ func TestPackageList(ctx context.Context, opts PackageOpts, roots []*Package) [] seen := map[*Package]bool{} all := []*Package{} var walk func(*Package) - walk = func { p | + walk = func { p -> if seen[p] { return } @@ -2894,7 +2894,7 @@ func setPGOProfilePath(pkgs []*Package) { appendBuildSetting(p.Internal.BuildInfo, "-pgo", file) } // Adding -pgo breaks the sort order in BuildInfo.Settings. Restore it. - slices.SortFunc(p.Internal.BuildInfo.Settings, func { x, y | return strings.Compare(x.Key, y.Key) }) + slices.SortFunc(p.Internal.BuildInfo.Settings, func { x, y -> return strings.Compare(x.Key, y.Key) }) } switch cfg.BuildPGO { @@ -2924,7 +2924,7 @@ func setPGOProfilePath(pkgs []*Package) { // Package. visited := make(map[*Package]*Package) var split func(p *Package) *Package - split = func { p | + split = func { p -> if p1 := visited[p]; p1 != nil { return p1 } diff --git a/src/cmd/go/internal/load/test.go b/src/cmd/go/internal/load/test.go index baf9896db9f7d..bc0035b7c169f 100644 --- a/src/cmd/go/internal/load/test.go +++ b/src/cmd/go/internal/load/test.go @@ -773,7 +773,7 @@ func (t *testFuncs) load(filename, pkg string, doImport, seen *bool) error { } } ex := doc.Examples(f) - sort.Slice(ex, func { i, j | return ex[i].Order < ex[j].Order }) + sort.Slice(ex, func { i, j -> return ex[i].Order < ex[j].Order }) for _, e := range ex { *doImport = true // import test file whether executed or not if e.Output == "" && !e.EmptyOutput { diff --git a/src/cmd/go/internal/lockedfile/lockedfile.go b/src/cmd/go/internal/lockedfile/lockedfile.go index 068b8b45dc0be..99d6df09dab96 100644 --- a/src/cmd/go/internal/lockedfile/lockedfile.go +++ b/src/cmd/go/internal/lockedfile/lockedfile.go @@ -50,7 +50,7 @@ func OpenFile(name string, flag int, perm fs.FileMode) (*File, error) { // especially don't want to leave a file locked after we're done with it. Our // Close method is what releases the locks, so use a finalizer to report // missing Close calls on a best-effort basis. - runtime.SetFinalizer(f, func { f | panic(fmt.Sprintf("lockedfile.File %s became unreachable without a call to Close", f.Name())) }) + runtime.SetFinalizer(f, func { f -> panic(fmt.Sprintf("lockedfile.File %s became unreachable without a call to Close", f.Name())) }) return f, nil } diff --git a/src/cmd/go/internal/modcmd/edit.go b/src/cmd/go/internal/modcmd/edit.go index 7deb32d4ca233..0f48711f37443 100644 --- a/src/cmd/go/internal/modcmd/edit.go +++ b/src/cmd/go/internal/modcmd/edit.go @@ -289,7 +289,7 @@ func runEdit(ctx context.Context, cmd *base.Command, args []string) { defer unlock() } - err = lockedfile.Transform(gomod, func { lockedData | + err = lockedfile.Transform(gomod, func { lockedData -> if !bytes.Equal(lockedData, data) { return nil, errors.New("go.mod changed during editing; not overwriting") } @@ -393,7 +393,7 @@ func flagGodebug(arg string) { if !ok || strings.ContainsAny(arg, "\"`',") { base.Fatalf("go: -godebug=%s: need key=value", arg) } - edits = append(edits, func { f | + edits = append(edits, func { f -> if err := f.AddGodebug(key, value); err != nil { base.Fatalf("go: -godebug=%s: %v", arg, err) } @@ -402,7 +402,7 @@ func flagGodebug(arg string) { // flagDropGodebug implements the -dropgodebug flag. func flagDropGodebug(arg string) { - edits = append(edits, func { f | if err := f.DropGodebug(arg); err != nil { + edits = append(edits, func { f -> if err := f.DropGodebug(arg); err != nil { base.Fatalf("go: -dropgodebug=%s: %v", arg, err) } }) } @@ -410,7 +410,7 @@ func flagDropGodebug(arg string) { // flagRequire implements the -require flag. func flagRequire(arg string) { path, version := parsePathVersion("require", arg) - edits = append(edits, func { f | + edits = append(edits, func { f -> if err := f.AddRequire(path, version); err != nil { base.Fatalf("go: -require=%s: %v", arg, err) } @@ -420,7 +420,7 @@ func flagRequire(arg string) { // flagDropRequire implements the -droprequire flag. func flagDropRequire(arg string) { path := parsePath("droprequire", arg) - edits = append(edits, func { f | + edits = append(edits, func { f -> if err := f.DropRequire(path); err != nil { base.Fatalf("go: -droprequire=%s: %v", arg, err) } @@ -430,7 +430,7 @@ func flagDropRequire(arg string) { // flagExclude implements the -exclude flag. func flagExclude(arg string) { path, version := parsePathVersion("exclude", arg) - edits = append(edits, func { f | + edits = append(edits, func { f -> if err := f.AddExclude(path, version); err != nil { base.Fatalf("go: -exclude=%s: %v", arg, err) } @@ -440,7 +440,7 @@ func flagExclude(arg string) { // flagDropExclude implements the -dropexclude flag. func flagDropExclude(arg string) { path, version := parsePathVersion("dropexclude", arg) - edits = append(edits, func { f | + edits = append(edits, func { f -> if err := f.DropExclude(path, version); err != nil { base.Fatalf("go: -dropexclude=%s: %v", arg, err) } @@ -469,7 +469,7 @@ func flagReplace(arg string) { base.Fatalf("go: -replace=%s: unversioned new path must be local directory", arg) } - edits = append(edits, func { f | + edits = append(edits, func { f -> if err := f.AddReplace(oldPath, oldVersion, newPath, newVersion); err != nil { base.Fatalf("go: -replace=%s: %v", arg, err) } @@ -482,7 +482,7 @@ func flagDropReplace(arg string) { if err != nil { base.Fatalf("go: -dropreplace=%s: %v", arg, err) } - edits = append(edits, func { f | + edits = append(edits, func { f -> if err := f.DropReplace(path, version); err != nil { base.Fatalf("go: -dropreplace=%s: %v", arg, err) } @@ -495,7 +495,7 @@ func flagRetract(arg string) { if err != nil { base.Fatalf("go: -retract=%s: %v", arg, err) } - edits = append(edits, func { f | if err := f.AddRetract(vi, ""); err != nil { + edits = append(edits, func { f -> if err := f.AddRetract(vi, ""); err != nil { base.Fatalf("go: -retract=%s: %v", arg, err) } }) } @@ -506,7 +506,7 @@ func flagDropRetract(arg string) { if err != nil { base.Fatalf("go: -dropretract=%s: %v", arg, err) } - edits = append(edits, func { f | if err := f.DropRetract(vi); err != nil { + edits = append(edits, func { f -> if err := f.DropRetract(vi); err != nil { base.Fatalf("go: -dropretract=%s: %v", arg, err) } }) } diff --git a/src/cmd/go/internal/modcmd/graph.go b/src/cmd/go/internal/modcmd/graph.go index 83fd2aac2df50..0ff1cbb369d61 100644 --- a/src/cmd/go/internal/modcmd/graph.go +++ b/src/cmd/go/internal/modcmd/graph.go @@ -84,7 +84,7 @@ func runGraph(ctx context.Context, cmd *base.Command, args []string) { } } - mg.WalkBreadthFirst(func { m | + mg.WalkBreadthFirst(func { m -> reqs, _ := mg.RequiredBy(m) for _, r := range reqs { format(m) diff --git a/src/cmd/go/internal/modfetch/cache.go b/src/cmd/go/internal/modfetch/cache.go index 408f4f7dc7d0a..8384f37e4026a 100644 --- a/src/cmd/go/internal/modfetch/cache.go +++ b/src/cmd/go/internal/modfetch/cache.go @@ -339,7 +339,7 @@ func InfoFile(ctx context.Context, path, version string) (*RevInfo, string, erro var info *RevInfo var err2info map[error]*RevInfo - err := TryProxies(func { proxy | + err := TryProxies(func { proxy -> i, err := Lookup(ctx, proxy, path).Stat(ctx, version) if err == nil { info = i @@ -376,7 +376,7 @@ func GoMod(ctx context.Context, path, rev string) ([]byte, error) { if errors.Is(err, statCacheErr) { return nil, err } - err := TryProxies(func { proxy | + err := TryProxies(func { proxy -> info, err := Lookup(ctx, proxy, path).Stat(ctx, rev) if err == nil { rev = info.Version diff --git a/src/cmd/go/internal/modfetch/codehost/git.go b/src/cmd/go/internal/modfetch/codehost/git.go index d635847f4f175..edd59f231d59e 100644 --- a/src/cmd/go/internal/modfetch/codehost/git.go +++ b/src/cmd/go/internal/modfetch/codehost/git.go @@ -313,7 +313,7 @@ func (r *gitRepo) Tags(ctx context.Context, prefix string) (*Tags, error) { } tags.List = append(tags.List, Tag{tag, hash}) } - sort.Slice(tags.List, func { i, j | return tags.List[i].Name < tags.List[j].Name }) + sort.Slice(tags.List, func { i, j -> return tags.List[i].Name < tags.List[j].Name }) dir := prefix[:strings.LastIndex(prefix, "/")+1] h := sha256.New() diff --git a/src/cmd/go/internal/modfetch/codehost/vcs.go b/src/cmd/go/internal/modfetch/codehost/vcs.go index ef9ca9f2e569a..552ec4ab13f41 100644 --- a/src/cmd/go/internal/modfetch/codehost/vcs.go +++ b/src/cmd/go/internal/modfetch/codehost/vcs.go @@ -323,7 +323,7 @@ func (r *vcsRepo) Tags(ctx context.Context, prefix string) (*Tags, error) { tags.List = append(tags.List, Tag{tag, ""}) } } - sort.Slice(tags.List, func { i, j | return tags.List[i].Name < tags.List[j].Name }) + sort.Slice(tags.List, func { i, j -> return tags.List[i].Name < tags.List[j].Name }) return tags, nil } diff --git a/src/cmd/go/internal/modfetch/coderepo.go b/src/cmd/go/internal/modfetch/coderepo.go index 2122dd7d32ca2..8ce1ad5840fd3 100644 --- a/src/cmd/go/internal/modfetch/coderepo.go +++ b/src/cmd/go/internal/modfetch/coderepo.go @@ -261,7 +261,7 @@ func (r *codeRepo) appendIncompatibleVersions(ctx context.Context, origin *codeh if major != lastMajor { rem := incompatible[i:] - j := sort.Search(len(rem), func { j | return semver.Major(rem[j]) != major }) + j := sort.Search(len(rem), func { j -> return semver.Major(rem[j]) != major }) latestAtMajor := rem[j-1] var err error diff --git a/src/cmd/go/internal/modfetch/coderepo_test.go b/src/cmd/go/internal/modfetch/coderepo_test.go index 36082e06f63b1..da290fddcd39e 100644 --- a/src/cmd/go/internal/modfetch/coderepo_test.go +++ b/src/cmd/go/internal/modfetch/coderepo_test.go @@ -820,7 +820,7 @@ func TestCodeRepoVersions(t *testing.T) { for _, tt := range codeRepoVersionsTests { tt := tt - t.Run(strings.ReplaceAll(tt.path, "/", "_"), func { t | + t.Run(strings.ReplaceAll(tt.path, "/", "_"), func { t -> if strings.Contains(tt.path, "gopkg.in") { testenv.SkipFlaky(t, 54503) } @@ -891,7 +891,7 @@ func TestLatest(t *testing.T) { for _, tt := range latestTests { name := strings.ReplaceAll(tt.path, "/", "_") - t.Run(name, func { t | + t.Run(name, func { t -> tt := tt t.Parallel() if tt.vcs != "mod" { diff --git a/src/cmd/go/internal/modfetch/fetch.go b/src/cmd/go/internal/modfetch/fetch.go index f98fac260658b..85ef461b3065c 100644 --- a/src/cmd/go/internal/modfetch/fetch.go +++ b/src/cmd/go/internal/modfetch/fetch.go @@ -272,7 +272,7 @@ func downloadZip(ctx context.Context, mod module.Version, zipfile string) (err e }() var unrecoverableErr error - err = TryProxies(func { proxy | + err = TryProxies(func { proxy -> if unrecoverableErr != nil { return unrecoverableErr } @@ -372,7 +372,7 @@ func makeDirsReadOnly(dir string) { mode fs.FileMode } var dirs []pathMode // in lexical order - filepath.WalkDir(dir, func { path, d, err | + filepath.WalkDir(dir, func { path, d, err -> if err == nil && d.IsDir() { info, err := d.Info() if err == nil && info.Mode()&0222 != 0 { @@ -392,7 +392,7 @@ func makeDirsReadOnly(dir string) { // any permission changes needed to do so. func RemoveAll(dir string) error { // Module cache has 0555 directories; make them writable in order to remove content. - filepath.WalkDir(dir, func { path, info, err | + filepath.WalkDir(dir, func { path, info, err -> if err != nil { return nil // ignore errors walking in file system } @@ -869,7 +869,7 @@ Outer: defer unlock() } - err := lockedfile.Transform(GoSumFile, func { data | + err := lockedfile.Transform(GoSumFile, func { data -> tidyGoSum := tidyGoSum(data, keep) return tidyGoSum, nil }) diff --git a/src/cmd/go/internal/modfetch/repo.go b/src/cmd/go/internal/modfetch/repo.go index c3f0a41c07bab..fe04552cf6ea2 100644 --- a/src/cmd/go/internal/modfetch/repo.go +++ b/src/cmd/go/internal/modfetch/repo.go @@ -210,7 +210,7 @@ func Lookup(ctx context.Context, proxy, path string) Repo { } return lookupCache.Do(lookupCacheKey{proxy, path}, func { - return newCachingRepo(ctx, path, func { ctx | + return newCachingRepo(ctx, path, func { ctx -> r, err := lookup(ctx, proxy, path) if err == nil && traceRepo { r = newLoggingRepo(r) diff --git a/src/cmd/go/internal/modfetch/sumdb.go b/src/cmd/go/internal/modfetch/sumdb.go index ed8d636bcb5ec..cbf103d5f54b4 100644 --- a/src/cmd/go/internal/modfetch/sumdb.go +++ b/src/cmd/go/internal/modfetch/sumdb.go @@ -198,7 +198,7 @@ func (c *dbClient) initBase() { // Any other response is treated as the database being unavailable. // // See https://golang.org/design/25530-sumdb#proxying-a-checksum-database. - err := TryProxies(func { proxy | + err := TryProxies(func { proxy -> switch proxy { case "noproxy": return errUseProxy diff --git a/src/cmd/go/internal/modfetch/toolchain.go b/src/cmd/go/internal/modfetch/toolchain.go index aee17e165a4fc..5ffc6ae55ed1d 100644 --- a/src/cmd/go/internal/modfetch/toolchain.go +++ b/src/cmd/go/internal/modfetch/toolchain.go @@ -70,9 +70,9 @@ func (r *toolchainRepo) Versions(ctx context.Context, prefix string) (*Versions, } if r.path == "go" { - sort.Slice(list, func { i, j | return gover.Compare(list[i], list[j]) < 0 }) + sort.Slice(list, func { i, j -> return gover.Compare(list[i], list[j]) < 0 }) } else { - sort.Slice(list, func { i, j | return gover.Compare(gover.FromToolchain(list[i]), gover.FromToolchain(list[j])) < 0 }) + sort.Slice(list, func { i, j -> return gover.Compare(gover.FromToolchain(list[i]), gover.FromToolchain(list[j])) < 0 }) } versions.List = list return versions, nil diff --git a/src/cmd/go/internal/modfetch/zip_sum_test/zip_sum_test.go b/src/cmd/go/internal/modfetch/zip_sum_test/zip_sum_test.go index 1b10dd1d3a0ff..cc1551b5c5a7d 100644 --- a/src/cmd/go/internal/modfetch/zip_sum_test/zip_sum_test.go +++ b/src/cmd/go/internal/modfetch/zip_sum_test/zip_sum_test.go @@ -117,7 +117,7 @@ func TestZipSums(t *testing.T) { for i := range tests { test := &tests[i] name := fmt.Sprintf("%s@%s", strings.ReplaceAll(test.m.Path, "/", "_"), test.m.Version) - t.Run(name, func { t | + t.Run(name, func { t -> t.Parallel() ctx := context.Background() diff --git a/src/cmd/go/internal/modget/get.go b/src/cmd/go/internal/modget/get.go index 8d4a1e7fc613b..c948846aec237 100644 --- a/src/cmd/go/internal/modget/get.go +++ b/src/cmd/go/internal/modget/get.go @@ -1055,7 +1055,7 @@ func (r *resolver) performPatternAllQueries(ctx context.Context) { // including in which errors it chooses to report, so sort the candidates // into a deterministic-but-arbitrary order. for _, q := range r.patternAllQueries { - sort.Slice(q.candidates, func { i, j | return q.candidates[i].path < q.candidates[j].path }) + sort.Slice(q.candidates, func { i, j -> return q.candidates[i].path < q.candidates[j].path }) } } @@ -1144,7 +1144,7 @@ func (r *resolver) findAndUpgradeImports(ctx context.Context, queries []*query) // nondeterministic order. We want 'go get' to be fully deterministic, // including in which errors it chooses to report, so sort the candidates // into a deterministic-but-arbitrary order. - sort.Slice(upgrades, func { i, j | return upgrades[i].path < upgrades[j].path }) + sort.Slice(upgrades, func { i, j -> return upgrades[i].path < upgrades[j].path }) return upgrades } @@ -1170,7 +1170,7 @@ func (r *resolver) loadPackages(ctx context.Context, patterns []string, findPack Switcher: new(toolchain.Switcher), } - opts.AllowPackage = func { ctx, path, m | + opts.AllowPackage = func { ctx, path, m -> if m.Path == "" || m.Version == "" { // Packages in the standard library and main modules are already at their // latest (and only) available versions. @@ -1594,7 +1594,7 @@ func (r *resolver) checkPackageProblems(ctx context.Context, pkgPatterns []strin retractions = append(retractions, modMessage{m: m}) } } - sort.Slice(retractions, func { i, j | return retractions[i].m.Path < retractions[j].m.Path }) + sort.Slice(retractions, func { i, j -> return retractions[i].m.Path < retractions[j].m.Path }) for i := range retractions { i := i r.work.Add(func() { @@ -1615,7 +1615,7 @@ func (r *resolver) checkPackageProblems(ctx context.Context, pkgPatterns []strin deprecations = append(deprecations, modMessage{m: m}) } } - sort.Slice(deprecations, func { i, j | return deprecations[i].m.Path < deprecations[j].m.Path }) + sort.Slice(deprecations, func { i, j -> return deprecations[i].m.Path < deprecations[j].m.Path }) for i := range deprecations { i := i r.work.Add(func() { @@ -1773,7 +1773,7 @@ func (r *resolver) reportChanges(oldReqs, newReqs []module.Version) { for _, c := range changes { sortedChanges = append(sortedChanges, c) } - sort.Slice(sortedChanges, func { i, j | + sort.Slice(sortedChanges, func { i, j -> pi := sortedChanges[i].path pj := sortedChanges[j].path if pi == pj { diff --git a/src/cmd/go/internal/modindex/build.go b/src/cmd/go/internal/modindex/build.go index c26dab780408c..94645cb16b49c 100644 --- a/src/cmd/go/internal/modindex/build.go +++ b/src/cmd/go/internal/modindex/build.go @@ -842,7 +842,7 @@ func (ctxt *Context) matchAuto(text string, allTags map[string]bool) bool { } func (ctxt *Context) eval(x constraint.Expr, allTags map[string]bool) bool { - return x.Eval(func { tag | return ctxt.matchTag(tag, allTags) }) + return x.Eval(func { tag -> return ctxt.matchTag(tag, allTags) }) } // matchTag reports whether the name is one of: diff --git a/src/cmd/go/internal/modindex/index_test.go b/src/cmd/go/internal/modindex/index_test.go index 9ba6cba220da3..6dd816ff6216e 100644 --- a/src/cmd/go/internal/modindex/index_test.go +++ b/src/cmd/go/internal/modindex/index_test.go @@ -63,7 +63,7 @@ func TestIndex(t *testing.T) { for _, pkg := range pkgs { raw := importRaw(src, pkg) raws = append(raws, raw) - t.Run(pkg, func { t | + t.Run(pkg, func { t -> data := encodeModuleBytes([]*rawPackage{raw}) m, err := fromBytes(src, data) if err != nil { @@ -74,7 +74,7 @@ func TestIndex(t *testing.T) { } // Check that a multi-package index works too. - t.Run("all", func { t | + t.Run("all", func { t -> data := encodeModuleBytes(raws) m, err := fromBytes(src, data) if err != nil { diff --git a/src/cmd/go/internal/modindex/read.go b/src/cmd/go/internal/modindex/read.go index fe787410894f4..788c83fe49642 100644 --- a/src/cmd/go/internal/modindex/read.go +++ b/src/cmd/go/internal/modindex/read.go @@ -805,7 +805,7 @@ var errCannotFindPackage = errors.New("cannot find package") func (m *Module) Package(path string) *IndexPackage { defer unprotect(protect(), nil) - i, ok := sort.Find(m.n, func { i | return strings.Compare(path, m.pkgDir(i)) }) + i, ok := sort.Find(m.n, func { i -> return strings.Compare(path, m.pkgDir(i)) }) if !ok { return &IndexPackage{error: fmt.Errorf("%w %q in:\n\t%s", errCannotFindPackage, path, filepath.Join(m.modroot, path))} } diff --git a/src/cmd/go/internal/modindex/scan.go b/src/cmd/go/internal/modindex/scan.go index 57ddc5fcfccb4..602a8325d8cff 100644 --- a/src/cmd/go/internal/modindex/scan.go +++ b/src/cmd/go/internal/modindex/scan.go @@ -57,7 +57,7 @@ func indexModule(modroot string) ([]byte, error) { // we want to follow it (see https://go.dev/issue/50807). // Add a trailing separator to force that to happen. root := str.WithFilePathSeparator(modroot) - err := fsys.Walk(root, func { path, info, err | + err := fsys.Walk(root, func { path, info, err -> if err := moduleWalkErr(root, path, info, err); err != nil { return err } diff --git a/src/cmd/go/internal/modindex/write.go b/src/cmd/go/internal/modindex/write.go index 4e7f6c187a430..c266b7b8f9f42 100644 --- a/src/cmd/go/internal/modindex/write.go +++ b/src/cmd/go/internal/modindex/write.go @@ -20,7 +20,7 @@ func encodeModuleBytes(packages []*rawPackage) []byte { e.Bytes([]byte(indexVersion + "\n")) stringTableOffsetPos := e.Pos() // fill this at the end e.Uint32(0) // string table offset - sort.Slice(packages, func { i, j | return packages[i].dir < packages[j].dir }) + sort.Slice(packages, func { i, j -> return packages[i].dir < packages[j].dir }) e.Int(len(packages)) packagesPos := e.Pos() for _, p := range packages { diff --git a/src/cmd/go/internal/modload/buildlist.go b/src/cmd/go/internal/modload/buildlist.go index 43e2e0ac40825..57fe94b2d7d5e 100644 --- a/src/cmd/go/internal/modload/buildlist.go +++ b/src/cmd/go/internal/modload/buildlist.go @@ -392,7 +392,7 @@ func readModGraph(ctx context.Context, pruning modPruning, roots []module.Versio } var enqueue func(m module.Version, pruning modPruning) - enqueue = func { m, pruning | + enqueue = func { m, pruning -> if m.Version == "none" { return } @@ -524,7 +524,7 @@ func (mg *ModuleGraph) BuildList() []module.Version { } func (mg *ModuleGraph) findError() error { - errStack := mg.g.FindPath(func { m | + errStack := mg.g.FindPath(func { m -> _, err := mg.loadCache.Get(m) return err != nil && err != par.ErrCacheEntryNotFound }) @@ -944,7 +944,7 @@ func tidyPrunedRoots(ctx context.Context, mainModule module.Version, old *Requir } <-q.Idle() - disambiguateRoot.Range(func { k, _ | + disambiguateRoot.Range(func { k, _ -> m := k.(module.Version) roots = append(roots, m) pathIsRoot[m.Path] = true diff --git a/src/cmd/go/internal/modload/edit.go b/src/cmd/go/internal/modload/edit.go index 10d062a495ef5..f1488525153c7 100644 --- a/src/cmd/go/internal/modload/edit.go +++ b/src/cmd/go/internal/modload/edit.go @@ -256,7 +256,7 @@ func editRequirements(ctx context.Context, rs *Requirements, tryUpgrade, mustSel // Now check the resulting extended graph for errors and incompatibilities. t := dqTracker{extendedRootPruning: extendedRootPruning} - mg.g.WalkBreadthFirst(func { m | + mg.g.WalkBreadthFirst(func { m -> if max, ok := mustSelectVersion[m.Path]; ok && gover.ModCompare(m.Path, m.Version, max) > 0 { // m itself violates mustSelect, so it cannot appear in the module graph // even if its transitive dependencies would be pruned out. diff --git a/src/cmd/go/internal/modload/import.go b/src/cmd/go/internal/modload/import.go index 2cdb1100f91ce..f938eae4b7149 100644 --- a/src/cmd/go/internal/modload/import.go +++ b/src/cmd/go/internal/modload/import.go @@ -543,7 +543,7 @@ func queryImport(ctx context.Context, path string, rs *Requirements) (module.Ver // Every module path in mods is a prefix of the import path. // As in QueryPattern, prefer the longest prefix that satisfies the import. - sort.Slice(mods, func { i, j | return len(mods[i].Path) > len(mods[j].Path) }) + sort.Slice(mods, func { i, j -> return len(mods[i].Path) > len(mods[j].Path) }) for _, m := range mods { root, isLocal, err := fetch(ctx, m) if err != nil { diff --git a/src/cmd/go/internal/modload/import_test.go b/src/cmd/go/internal/modload/import_test.go index 2f4a26a313a72..52491e2086c3c 100644 --- a/src/cmd/go/internal/modload/import_test.go +++ b/src/cmd/go/internal/modload/import_test.go @@ -72,7 +72,7 @@ func TestQueryImport(t *testing.T) { rs := LoadModFile(ctx) for _, tt := range importTests { - t.Run(strings.ReplaceAll(tt.path, "/", "_"), func { t | + t.Run(strings.ReplaceAll(tt.path, "/", "_"), func { t -> // Note that there is no build list, so Import should always fail. m, err := queryImport(ctx, tt.path, rs) diff --git a/src/cmd/go/internal/modload/init.go b/src/cmd/go/internal/modload/init.go index 18cfa18c9247e..f9d62d02b077f 100644 --- a/src/cmd/go/internal/modload/init.go +++ b/src/cmd/go/internal/modload/init.go @@ -1928,7 +1928,7 @@ func commitRequirements(ctx context.Context, opts WriteOpts) (err error) { defer unlock() } - err = lockedfile.Transform(modFilePath, func { old | + err = lockedfile.Transform(modFilePath, func { old -> if bytes.Equal(old, updatedGoMod) { // The go.mod file is already equal to new, possibly as the result of some // other process. @@ -2042,7 +2042,7 @@ func keepSums(ctx context.Context, ld *loader, rs *Requirements, which whichSums } } else { mg, _ := rs.Graph(ctx) - mg.WalkBreadthFirst(func { m | + mg.WalkBreadthFirst(func { m -> if _, ok := mg.RequiredBy(m); ok { // The requirements from m's go.mod file are present in the module graph, // so they are relevant to the MVS result regardless of whether m was diff --git a/src/cmd/go/internal/modload/list.go b/src/cmd/go/internal/modload/list.go index 4a4bbe180d53c..7824c36d6a84c 100644 --- a/src/cmd/go/internal/modload/list.go +++ b/src/cmd/go/internal/modload/list.go @@ -228,10 +228,10 @@ func listModules(ctx context.Context, rs *Requirements, args []string, mode List // Module path or pattern. var match func(string) bool if arg == "all" { - match = func { p | return !gover.IsToolchain(p) } + match = func { p -> return !gover.IsToolchain(p) } } else if strings.Contains(arg, "...") { mp := pkgpattern.MatchPattern(arg) - match = func { p | return mp(p) && !gover.IsToolchain(p) } + match = func { p -> return mp(p) && !gover.IsToolchain(p) } } else { var v string if mg == nil { diff --git a/src/cmd/go/internal/modload/load.go b/src/cmd/go/internal/modload/load.go index a1130a788ecd0..b5ebb6bcd0b09 100644 --- a/src/cmd/go/internal/modload/load.go +++ b/src/cmd/go/internal/modload/load.go @@ -1253,7 +1253,7 @@ func loadFromRoots(ctx context.Context, params loaderParams) *loader { rs = tidy } else { conflict := Conflict{ - Path: mg.g.FindPath(func { m | return m.Path == "go" && m.Version == v })[1:], + Path: mg.g.FindPath(func { m -> return m.Path == "go" && m.Version == v })[1:], Constraint: module.Version{Path: "go", Version: ld.TidyGoVersion}, } msg := conflict.Summary() diff --git a/src/cmd/go/internal/modload/mvs.go b/src/cmd/go/internal/modload/mvs.go index 2101d18b964ca..cbd7a82163846 100644 --- a/src/cmd/go/internal/modload/mvs.go +++ b/src/cmd/go/internal/modload/mvs.go @@ -82,7 +82,7 @@ func (*mvsReqs) Upgrade(m module.Version) (module.Version, error) { func versions(ctx context.Context, path string, allowed AllowedFunc) (versions []string, origin *codehost.Origin, err error) { // Note: modfetch.Lookup and repo.Versions are cached, // so there's no need for us to add extra caching here. - err = modfetch.TryProxies(func { proxy | + err = modfetch.TryProxies(func { proxy -> repo, err := lookupRepo(ctx, proxy, path) if err != nil { return err @@ -123,7 +123,7 @@ func previousVersion(ctx context.Context, m module.Version) (module.Version, err } return module.Version{}, err } - i := sort.Search(len(list), func { i | return gover.ModCompare(m.Path, list[i], m.Version) >= 0 }) + i := sort.Search(len(list), func { i -> return gover.ModCompare(m.Path, list[i], m.Version) >= 0 }) if i > 0 { return module.Version{Path: m.Path, Version: list[i-1]}, nil } diff --git a/src/cmd/go/internal/modload/query.go b/src/cmd/go/internal/modload/query.go index 71c4b4829ab87..57ef2b20198fd 100644 --- a/src/cmd/go/internal/modload/query.go +++ b/src/cmd/go/internal/modload/query.go @@ -101,7 +101,7 @@ func queryReuse(ctx context.Context, path, query, current string, allowed Allowe // checkReuse checks whether a revision of a given module // for a given module may be reused, according to the information in origin. func checkReuse(ctx context.Context, m module.Version, old *codehost.Origin) error { - return modfetch.TryProxies(func { proxy | + return modfetch.TryProxies(func { proxy -> repo, err := lookupRepo(ctx, proxy, m.Path) if err != nil { return err @@ -453,7 +453,7 @@ func newQueryMatcher(path string, query, current string, allowed AllowedFunc) (* qm.mayUseLatest = true } else { qm.mayUseLatest = module.IsPseudoVersion(current) - qm.filter = func { mv | return gover.ModCompare(qm.path, mv, current) >= 0 } + qm.filter = func { mv -> return gover.ModCompare(qm.path, mv, current) >= 0 } } case query == "patch": @@ -465,7 +465,7 @@ func newQueryMatcher(path string, query, current string, allowed AllowedFunc) (* } else { qm.mayUseLatest = module.IsPseudoVersion(current) qm.prefix = gover.ModMajorMinor(qm.path, current) + "." - qm.filter = func { mv | return gover.ModCompare(qm.path, mv, current) >= 0 } + qm.filter = func { mv -> return gover.ModCompare(qm.path, mv, current) >= 0 } } case strings.HasPrefix(query, "<="): @@ -477,7 +477,7 @@ func newQueryMatcher(path string, query, current string, allowed AllowedFunc) (* // Refuse to say whether <=v1.2 allows v1.2.3 (remember, @v1.2 might mean v1.2.3). return nil, fmt.Errorf("ambiguous semantic version %q in range %q", v, query) } - qm.filter = func { mv | return gover.ModCompare(qm.path, mv, v) <= 0 } + qm.filter = func { mv -> return gover.ModCompare(qm.path, mv, v) <= 0 } if !matchesMajor(v) { qm.preferIncompatible = true } @@ -487,7 +487,7 @@ func newQueryMatcher(path string, query, current string, allowed AllowedFunc) (* if !gover.ModIsValid(path, v) { return badVersion(v) } - qm.filter = func { mv | return gover.ModCompare(qm.path, mv, v) < 0 } + qm.filter = func { mv -> return gover.ModCompare(qm.path, mv, v) < 0 } if !matchesMajor(v) { qm.preferIncompatible = true } @@ -497,7 +497,7 @@ func newQueryMatcher(path string, query, current string, allowed AllowedFunc) (* if !gover.ModIsValid(path, v) { return badVersion(v) } - qm.filter = func { mv | return gover.ModCompare(qm.path, mv, v) >= 0 } + qm.filter = func { mv -> return gover.ModCompare(qm.path, mv, v) >= 0 } qm.preferLower = true if !matchesMajor(v) { qm.preferIncompatible = true @@ -512,7 +512,7 @@ func newQueryMatcher(path string, query, current string, allowed AllowedFunc) (* // Refuse to say whether >v1.2 allows v1.2.3 (remember, @v1.2 might mean v1.2.3). return nil, fmt.Errorf("ambiguous semantic version %q in range %q", v, query) } - qm.filter = func { mv | return gover.ModCompare(qm.path, mv, v) > 0 } + qm.filter = func { mv -> return gover.ModCompare(qm.path, mv, v) > 0 } qm.preferLower = true if !matchesMajor(v) { qm.preferIncompatible = true @@ -523,10 +523,10 @@ func newQueryMatcher(path string, query, current string, allowed AllowedFunc) (* qm.prefix = query + "." // Do not allow the query "v1.2" to match versions lower than "v1.2.0", // such as prereleases for that version. (https://golang.org/issue/31972) - qm.filter = func { mv | return gover.ModCompare(qm.path, mv, query) >= 0 } + qm.filter = func { mv -> return gover.ModCompare(qm.path, mv, query) >= 0 } } else { qm.canStat = true - qm.filter = func { mv | return gover.ModCompare(qm.path, mv, query) == 0 } + qm.filter = func { mv -> return gover.ModCompare(qm.path, mv, query) == 0 } qm.prefix = semver.Canonical(query) } if !matchesMajor(query) { @@ -691,13 +691,13 @@ func QueryPattern(ctx context.Context, pattern, query string, current func(strin if base == "." { return nil, nil, &WildcardInFirstElementError{Pattern: pattern, Query: query} } - match = func { mod, roots, isLocal | + match = func { mod, roots, isLocal -> m := search.NewMatch(pattern) matchPackages(ctx, m, imports.AnyTags(), omitStd, []module.Version{mod}) return m } } else { - match = func { mod, roots, isLocal | + match = func { mod, roots, isLocal -> m := search.NewMatch(pattern) prefix := mod.Path if MainModules.Contains(mod.Path) { @@ -776,7 +776,7 @@ func QueryPattern(ctx context.Context, pattern, query string, current func(strin } } - err = modfetch.TryProxies(func { proxy | + err = modfetch.TryProxies(func { proxy -> queryModule := func(ctx context.Context, path string) (r QueryResult, err error) { ctx, span := trace.StartSpan(ctx, "modload.QueryPattern.queryModule ["+proxy+"] "+path) defer span.Done() @@ -1202,7 +1202,7 @@ func (rr *replacementRepo) Versions(ctx context.Context, prefix string) (*modfet } path := rr.ModulePath() - sort.Slice(versions, func { i, j | return gover.ModCompare(path, versions[i], versions[j]) < 0 }) + sort.Slice(versions, func { i, j -> return gover.ModCompare(path, versions[i], versions[j]) < 0 }) str.Uniq(&versions) return &modfetch.Versions{List: versions}, nil } diff --git a/src/cmd/go/internal/modload/query_test.go b/src/cmd/go/internal/modload/query_test.go index 1bea6eda496b6..d1a8f164ae98d 100644 --- a/src/cmd/go/internal/modload/query_test.go +++ b/src/cmd/go/internal/modload/query_test.go @@ -179,7 +179,7 @@ func TestQuery(t *testing.T) { return nil } tt := tt - t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.query+"/"+tt.current+"/"+allow, func { t | + t.Run(strings.ReplaceAll(tt.path, "/", "_")+"/"+tt.query+"/"+tt.current+"/"+allow, func { t -> t.Parallel() info, err := Query(ctx, tt.path, tt.query, tt.current, allowed) diff --git a/src/cmd/go/internal/modload/search.go b/src/cmd/go/internal/modload/search.go index a6d86611c3f6b..d9e9e11ff65ae 100644 --- a/src/cmd/go/internal/modload/search.go +++ b/src/cmd/go/internal/modload/search.go @@ -83,7 +83,7 @@ func matchPackages(ctx context.Context, m *search.Match, tags map[string]bool, f // we want to follow it (see https://go.dev/issue/50807). // Add a trailing separator to force that to happen. root = str.WithFilePathSeparator(filepath.Clean(root)) - err := fsys.Walk(root, func { pkgDir, fi, err | + err := fsys.Walk(root, func { pkgDir, fi, err -> if err != nil { m.AddError(err) return nil @@ -219,7 +219,7 @@ func matchPackages(ctx context.Context, m *search.Match, tags map[string]bool, f // is the module's root directory on disk, index is the modindex.Module for the // module, and importPathRoot is the module's path prefix. func walkFromIndex(index *modindex.Module, importPathRoot string, isMatch, treeCanMatch func(string) bool, tags, have map[string]bool, addPkg func(string)) { - index.Walk(func { reldir | + index.Walk(func { reldir -> // Avoid .foo, _foo, and testdata subdirectory trees. p := reldir for { diff --git a/src/cmd/go/internal/mvs/mvs.go b/src/cmd/go/internal/mvs/mvs.go index d2d2c54ac77a4..e92f0ba11064a 100644 --- a/src/cmd/go/internal/mvs/mvs.go +++ b/src/cmd/go/internal/mvs/mvs.go @@ -115,7 +115,7 @@ func buildList(targets []module.Version, reqs Reqs, upgrade func(module.Version) for _, target := range targets { work.Add(target) } - work.Do(10, func { m | + work.Do(10, func { m -> var required []module.Version var err error @@ -152,7 +152,7 @@ func buildList(targets []module.Version, reqs Reqs, upgrade func(module.Version) // If there was an error, find the shortest path from the target to the // node where the error occurred so we can report a useful error message. if len(errs) > 0 { - errPath := g.FindPath(func { m | return errs[m] != nil }) + errPath := g.FindPath(func { m -> return errs[m] != nil }) if len(errPath) == 0 { panic("internal error: could not reconstruct path to module with error") } @@ -203,7 +203,7 @@ func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version, reqCache[mainModule] = nil var walk func(module.Version) error - walk = func { m | + walk = func { m -> _, ok := reqCache[m] if ok { return nil @@ -229,7 +229,7 @@ func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version, // Walk modules in reverse post-order, only adding those not implied already. have := map[module.Version]bool{} - walk = func { m | + walk = func { m -> if have[m] { return nil } @@ -263,14 +263,14 @@ func Req(mainModule module.Version, base []string, reqs Reqs) ([]module.Version, walk(m) } } - sort.Slice(min, func { i, j | return min[i].Path < min[j].Path }) + sort.Slice(min, func { i, j -> return min[i].Path < min[j].Path }) return min, nil } // UpgradeAll returns a build list for the target module // in which every module is upgraded to its latest version. func UpgradeAll(target module.Version, reqs UpgradeReqs) ([]module.Version, error) { - return buildList([]module.Version{target}, reqs, func { m | + return buildList([]module.Version{target}, reqs, func { m -> if m.Path == target.Path { return target, nil } @@ -305,7 +305,7 @@ func Upgrade(target module.Version, reqs UpgradeReqs, upgrade ...module.Version) } } - return buildList([]module.Version{target}, &override{target, list, reqs}, func { m | + return buildList([]module.Version{target}, &override{target, list, reqs}, func { m -> if v, ok := upgradeTo[m.Path]; ok { return module.Version{Path: m.Path, Version: v}, nil } @@ -350,7 +350,7 @@ func Downgrade(target module.Version, reqs DowngradeReqs, downgrade ...module.Ve excluded = make(map[module.Version]bool) ) var exclude func(module.Version) - exclude = func { m | + exclude = func { m -> if excluded[m] { return } @@ -360,7 +360,7 @@ func Downgrade(target module.Version, reqs DowngradeReqs, downgrade ...module.Ve } } var add func(module.Version) - add = func { m | + add = func { m -> if added[m] { return } diff --git a/src/cmd/go/internal/mvs/mvs_test.go b/src/cmd/go/internal/mvs/mvs_test.go index 8ee84259e10cf..9331f88c96d5f 100644 --- a/src/cmd/go/internal/mvs/mvs_test.go +++ b/src/cmd/go/internal/mvs/mvs_test.go @@ -447,7 +447,7 @@ func Test(t *testing.T) { ) flush := func() { if name != "" { - t.Run(name, func { t | + t.Run(name, func { t -> for _, fn := range fns { fn(t) } @@ -506,7 +506,7 @@ func Test(t *testing.T) { if len(kf) != 2 { t.Fatalf("build takes one argument: %q", line) } - fns = append(fns, func { t | + fns = append(fns, func { t -> list, err := BuildList([]module.Version{m(kf[1])}, reqs) checkList(t, key, list, err, val) }) @@ -515,7 +515,7 @@ func Test(t *testing.T) { if len(kf) != 2 { t.Fatalf("upgrade* takes one argument: %q", line) } - fns = append(fns, func { t | + fns = append(fns, func { t -> list, err := UpgradeAll(m(kf[1]), reqs) checkList(t, key, list, err, val) }) @@ -524,7 +524,7 @@ func Test(t *testing.T) { if len(kf) < 2 { t.Fatalf("upgrade takes at least one argument: %q", line) } - fns = append(fns, func { t | + fns = append(fns, func { t -> list, err := Upgrade(m(kf[1]), reqs, ms(kf[2:])...) if err == nil { // Copy the reqs map, but substitute the upgraded requirements in @@ -544,7 +544,7 @@ func Test(t *testing.T) { if len(kf) < 2 { t.Fatalf("upgrade takes at least one argument: %q", line) } - fns = append(fns, func { t | + fns = append(fns, func { t -> list, err := Upgrade(m(kf[1]), reqs, ms(kf[2:])...) checkList(t, key, list, err, val) }) @@ -553,7 +553,7 @@ func Test(t *testing.T) { if len(kf) < 2 { t.Fatalf("downgrade takes at least one argument: %q", line) } - fns = append(fns, func { t | + fns = append(fns, func { t -> list, err := Downgrade(m(kf[1]), reqs, ms(kf[1:])...) checkList(t, key, list, err, val) }) @@ -562,7 +562,7 @@ func Test(t *testing.T) { if len(kf) < 2 { t.Fatalf("req takes at least one argument: %q", line) } - fns = append(fns, func { t | + fns = append(fns, func { t -> list, err := Req(m(kf[1]), kf[2:], reqs) checkList(t, key, list, err, val) }) diff --git a/src/cmd/go/internal/par/work_test.go b/src/cmd/go/internal/par/work_test.go index 6d74ca51a9d48..3c6aad3d7a956 100644 --- a/src/cmd/go/internal/par/work_test.go +++ b/src/cmd/go/internal/par/work_test.go @@ -16,7 +16,7 @@ func TestWork(t *testing.T) { const N = 10000 n := int32(0) w.Add(N) - w.Do(100, func { i | + w.Do(100, func { i -> atomic.AddInt32(&n, 1) if i >= 2 { w.Add(i - 1) @@ -39,7 +39,7 @@ func TestWorkParallel(t *testing.T) { } start := time.Now() var n int32 - w.Do(N, func { x | + w.Do(N, func { x -> time.Sleep(1 * time.Millisecond) atomic.AddInt32(&n, +1) }) diff --git a/src/cmd/go/internal/script/cmds.go b/src/cmd/go/internal/script/cmds.go index ed826f28d1ddc..76b0db5d393b4 100644 --- a/src/cmd/go/internal/script/cmds.go +++ b/src/cmd/go/internal/script/cmds.go @@ -36,7 +36,7 @@ func DefaultCmds() map[string]Cmd { "cp": Cp(), "echo": Echo(), "env": Env(), - "exec": Exec(func { cmd | return cmd.Process.Signal(os.Interrupt) }, 100*time.Millisecond), // arbitrary grace period + "exec": Exec(func { cmd -> return cmd.Process.Signal(os.Interrupt) }, 100*time.Millisecond), // arbitrary grace period "exists": Exists(), "grep": Grep(), "help": Help(), @@ -96,7 +96,7 @@ func Cat() Cmd { Summary: "concatenate files and print to the script's stdout buffer", Args: "files...", }, - func { s, args | + func { s, args -> if len(args) == 0 { return nil, ErrUsage } @@ -135,7 +135,7 @@ func Cd() Cmd { Summary: "change the working directory", Args: "dir", }, - func { s, args | + func { s, args -> if len(args) != 1 { return nil, ErrUsage } @@ -154,7 +154,7 @@ func Chmod() Cmd { "Only numerical permissions are supported.", }, }, - func { s, args | + func { s, args -> if len(args) < 2 { return nil, ErrUsage } @@ -188,7 +188,7 @@ func Cmp() Cmd { "File1 can be 'stdout' or 'stderr' to compare the stdout or stderr buffer from the most recent command.", }, }, - func { s, args | return nil, doCompare(s, false, args...) }) + func { s, args -> return nil, doCompare(s, false, args...) }) } // Cmpenv is like Compare, but also performs environment substitutions @@ -204,7 +204,7 @@ func Cmpenv() Cmd { "File1 can be 'stdout' or 'stderr' to compare the script's stdout or stderr buffer.", }, }, - func { s, args | return nil, doCompare(s, true, args...) }) + func { s, args -> return nil, doCompare(s, true, args...) }) } func doCompare(s *State, env bool, args ...string) error { @@ -263,7 +263,7 @@ func Cp() Cmd { "src can include 'stdout' or 'stderr' to copy from the script's stdout or stderr buffer.", }, }, - func { s, args | + func { s, args -> if len(args) < 2 { return nil, ErrUsage } @@ -323,7 +323,7 @@ func Echo() Cmd { Summary: "display a line of text", Args: "string...", }, - func { s, args | + func { s, args -> var buf strings.Builder for i, arg := range args { if i > 0 { @@ -362,7 +362,7 @@ func Env() Cmd { "Otherwise, add the listed key=value pairs to the environment or print the listed keys.", }, }, - func { s, args | + func { s, args -> out := new(strings.Builder) if len(args) == 0 { for _, kv := range s.env { @@ -406,7 +406,7 @@ func Exec(cancel func(*exec.Cmd) error, waitDelay time.Duration) Cmd { }, Async: true, }, - func { s, args | + func { s, args -> if len(args) < 1 { return nil, ErrUsage } @@ -478,7 +478,7 @@ func lookPath(s *State, command string) (string, error) { // TODO(bcmills): Remove this assumption. strEqual = strings.EqualFold } else { - strEqual = func { a, b | return a == b } + strEqual = func { a, b -> return a == b } } var pathExt []string @@ -499,9 +499,9 @@ func lookPath(s *State, command string) (string, error) { break } } - isExecutable = func { fi | return fi.Mode().IsRegular() } + isExecutable = func { fi -> return fi.Mode().IsRegular() } } else { - isExecutable = func { fi | return fi.Mode().IsRegular() && fi.Mode().Perm()&0111 != 0 } + isExecutable = func { fi -> return fi.Mode().IsRegular() && fi.Mode().Perm()&0111 != 0 } } pathEnv, _ := s.LookupEnv(pathEnvName()) @@ -561,7 +561,7 @@ func Exists() Cmd { Summary: "check that files exist", Args: "[-readonly] [-exec] file...", }, - func { s, args | + func { s, args -> var readonly, exec bool loop: for len(args) > 0 { @@ -614,7 +614,7 @@ func Grep() Cmd { }, RegexpArgs: firstNonFlag, }, - func { s, args | return nil, match(s, args, "", "grep") }) + func { s, args -> return nil, match(s, args, "", "grep") }) } const matchUsage = "[-count=N] [-q] 'pattern'" @@ -702,7 +702,7 @@ func Help() Cmd { "To display complete documentation when listing all commands, pass the -v flag.", }, }, - func { s, args | + func { s, args -> if s.engine == nil { return nil, errors.New("no engine configured") } @@ -757,7 +757,7 @@ func Mkdir() Cmd { "Unlike Unix mkdir, parent directories are always created if needed.", }, }, - func { s, args | + func { s, args -> if len(args) < 1 { return nil, ErrUsage } @@ -780,7 +780,7 @@ func Mv() Cmd { "OS-specific restrictions may apply when old and new are in different directories.", }, }, - func { s, args | + func { s, args -> if len(args) != 2 { return nil, ErrUsage } @@ -813,7 +813,7 @@ func Program(name string, cancel func(*exec.Cmd) error, waitDelay time.Duration) Args: "[args...]", Async: true, }, - func { s, args | + func { s, args -> lookPathOnce.Do(func() { path, pathErr = cfg.LookPath(name) }) @@ -834,7 +834,7 @@ func Replace() Cmd { "The 'old' and 'new' arguments are unquoted as if in quoted Go strings.", }, }, - func { s, args | + func { s, args -> if len(args)%2 != 1 { return nil, ErrUsage } @@ -874,7 +874,7 @@ func Rm() Cmd { "If the path is a directory, its contents are removed recursively.", }, }, - func { s, args | + func { s, args -> if len(args) < 1 { return nil, ErrUsage } @@ -894,7 +894,7 @@ func Rm() Cmd { func removeAll(dir string) error { // module cache has 0444 directories; // make them writable in order to remove content. - filepath.WalkDir(dir, func { path, info, err | + filepath.WalkDir(dir, func { path, info, err -> // chmod not only directories, but also things that we couldn't even stat // due to permission errors: they may also be unreadable directories. if err != nil || info.IsDir() { @@ -917,7 +917,7 @@ func Sleep() Cmd { }, Async: true, }, - func { s, args | + func { s, args -> if len(args) != 1 { return nil, ErrUsage } @@ -954,7 +954,7 @@ func Stderr() Cmd { }, RegexpArgs: firstNonFlag, }, - func { s, args | return nil, match(s, args, s.Stderr(), "stderr") }) + func { s, args -> return nil, match(s, args, s.Stderr(), "stderr") }) } // Stdout searches for a regular expression in the stdout buffer. @@ -969,7 +969,7 @@ func Stdout() Cmd { }, RegexpArgs: firstNonFlag, }, - func { s, args | return nil, match(s, args, s.Stdout(), "stdout") }) + func { s, args -> return nil, match(s, args, s.Stdout(), "stdout") }) } // Stop returns a sentinel error that causes script execution to halt @@ -983,7 +983,7 @@ func Stop() Cmd { "The message is written to the script log, but no error is reported from the script engine.", }, }, - func { s, args | + func { s, args -> if len(args) > 1 { return nil, ErrUsage } @@ -1019,7 +1019,7 @@ func Symlink() Cmd { "The '->' token (like in 'ls -l' output on Unix) is required.", }, }, - func { s, args | + func { s, args -> if len(args) != 3 || args[1] != "->" { return nil, ErrUsage } @@ -1046,7 +1046,7 @@ func Wait() Cmd { "After the call to 'wait', the script's stdout and stderr buffers contain the concatenation of the background commands' outputs.", }, }, - func { s, args | + func { s, args -> if len(args) > 0 { return nil, ErrUsage } diff --git a/src/cmd/go/internal/script/conds.go b/src/cmd/go/internal/script/conds.go index 0cf817508d511..e5d7f41a317b7 100644 --- a/src/cmd/go/internal/script/conds.go +++ b/src/cmd/go/internal/script/conds.go @@ -21,7 +21,7 @@ func DefaultConds() map[string]Cond { conds["GOOS"] = PrefixCondition( "runtime.GOOS == ", - func { _, suffix | + func { _, suffix -> if suffix == runtime.GOOS { return true, nil } @@ -33,7 +33,7 @@ func DefaultConds() map[string]Cond { conds["GOARCH"] = PrefixCondition( "runtime.GOARCH == ", - func { _, suffix | + func { _, suffix -> if suffix == runtime.GOARCH { return true, nil } @@ -45,7 +45,7 @@ func DefaultConds() map[string]Cond { conds["compiler"] = PrefixCondition( "runtime.Compiler == ", - func { _, suffix | + func { _, suffix -> if suffix == runtime.Compiler { return true, nil } diff --git a/src/cmd/go/internal/script/scripttest/scripttest.go b/src/cmd/go/internal/script/scripttest/scripttest.go index ec8511fa84760..fa3012fb405e8 100644 --- a/src/cmd/go/internal/script/scripttest/scripttest.go +++ b/src/cmd/go/internal/script/scripttest/scripttest.go @@ -108,7 +108,7 @@ func Skip() script.Cmd { Summary: "skip the current test", Args: "[msg]", }, - func { _, args | + func { _, args -> if len(args) > 1 { return nil, script.ErrUsage } @@ -136,7 +136,7 @@ func (s skipError) Error() string { func CachedExec() script.Cond { return script.CachedCondition( " names an executable in the test binary's PATH", - func { name | + func { name -> _, err := cfg.LookPath(name) return err == nil, nil }) diff --git a/src/cmd/go/internal/script/state.go b/src/cmd/go/internal/script/state.go index 265b0dde93e32..068bc52cf5b22 100644 --- a/src/cmd/go/internal/script/state.go +++ b/src/cmd/go/internal/script/state.go @@ -129,7 +129,7 @@ func (s *State) Environ() []string { // the environment variables in s. References to undefined variables are // replaced by the empty string. func (s *State) ExpandEnv(str string, inRegexp bool) string { - return os.Expand(str, func { key | + return os.Expand(str, func { key -> e := s.envMap[key] if inRegexp { // Quote to literal strings: we want paths like C:\work\go1.4 to remain diff --git a/src/cmd/go/internal/search/search.go b/src/cmd/go/internal/search/search.go index abfe1b5cb36bd..ab43fc1ffb363 100644 --- a/src/cmd/go/internal/search/search.go +++ b/src/cmd/go/internal/search/search.go @@ -135,7 +135,7 @@ func (m *Match) MatchPackages() { root += "cmd" + string(filepath.Separator) } - err := fsys.Walk(root, func { path, fi, err | + err := fsys.Walk(root, func { path, fi, err -> if err != nil { return err // Likely a permission error, which could interfere with matching. } @@ -278,7 +278,7 @@ func (m *Match) MatchDirs(modRoots []string) { // we want to follow it (see https://go.dev/issue/50807). // Add a trailing separator to force that to happen. dir = str.WithFilePathSeparator(dir) - err := fsys.Walk(dir, func { path, fi, err | + err := fsys.Walk(dir, func { path, fi, err -> if err != nil { return err // Likely a permission error, which could interfere with matching. } diff --git a/src/cmd/go/internal/test/internal/genflags/testflag.go b/src/cmd/go/internal/test/internal/genflags/testflag.go index 5a896e22dd2ae..0cfae9db7359c 100644 --- a/src/cmd/go/internal/test/internal/genflags/testflag.go +++ b/src/cmd/go/internal/test/internal/genflags/testflag.go @@ -16,7 +16,7 @@ func ShortTestFlags() []string { testing.Init() var names []string - flag.VisitAll(func { f | + flag.VisitAll(func { f -> var name string var found bool if name, found = strings.CutPrefix(f.Name, "test."); !found { diff --git a/src/cmd/go/internal/test/testflag.go b/src/cmd/go/internal/test/testflag.go index 5a31878fc39fa..b9513b95b13be 100644 --- a/src/cmd/go/internal/test/testflag.go +++ b/src/cmd/go/internal/test/testflag.go @@ -224,7 +224,7 @@ func (f *shuffleFlag) Set(value string) error { func testFlags(args []string) (packageNames, passToTest []string) { base.SetFromGOFLAGS(&CmdTest.Flag) addFromGOFLAGS := map[string]bool{} - CmdTest.Flag.Visit(func { f | + CmdTest.Flag.Visit(func { f -> if short := strings.TrimPrefix(f.Name, "test."); passFlagToTest[short] { addFromGOFLAGS[f.Name] = true } @@ -358,7 +358,7 @@ func testFlags(args []string) (packageNames, passToTest []string) { // (They must appear before the flag terminator or first non-flag argument.) // Also determine whether flags with awkward defaults have already been set. var timeoutSet, outputDirSet bool - CmdTest.Flag.Visit(func { f | + CmdTest.Flag.Visit(func { f -> short := strings.TrimPrefix(f.Name, "test.") if addFromGOFLAGS[f.Name] { injectedFlags = append(injectedFlags, fmt.Sprintf("-test.%s=%v", short, f.Value)) diff --git a/src/cmd/go/internal/toolchain/select.go b/src/cmd/go/internal/toolchain/select.go index 237bb461d1975..33b85a3017783 100644 --- a/src/cmd/go/internal/toolchain/select.go +++ b/src/cmd/go/internal/toolchain/select.go @@ -354,7 +354,7 @@ func Exec(gotoolchain string) { if info.Mode()&0111 == 0 { // allowExec sets the exec permission bits on all files found in dir. allowExec := func(dir string) { - err := filepath.WalkDir(dir, func { path, d, err | + err := filepath.WalkDir(dir, func { path, d, err -> if err != nil { return err } @@ -391,7 +391,7 @@ func Exec(gotoolchain string) { srcUGoMod := filepath.Join(dir, "src/_go.mod") srcGoMod := filepath.Join(dir, "src/go.mod") if size(srcGoMod) != size(srcUGoMod) { - err := filepath.WalkDir(dir, func { path, d, err | + err := filepath.WalkDir(dir, func { path, d, err -> if err != nil { return err } diff --git a/src/cmd/go/internal/toolchain/switch.go b/src/cmd/go/internal/toolchain/switch.go index c04a470a1e642..5b974ac6c7d9c 100644 --- a/src/cmd/go/internal/toolchain/switch.go +++ b/src/cmd/go/internal/toolchain/switch.go @@ -137,7 +137,7 @@ func NewerToolchain(ctx context.Context, version string) (string, error) { // autoToolchains returns the list of toolchain versions available to GOTOOLCHAIN=auto or =min+auto mode. func autoToolchains(ctx context.Context) ([]string, error) { var versions *modfetch.Versions - err := modfetch.TryProxies(func { proxy | + err := modfetch.TryProxies(func { proxy -> v, err := modfetch.Lookup(ctx, proxy, "go").Versions(ctx, "") if err != nil { return err @@ -180,7 +180,7 @@ func pathToolchains(ctx context.Context) ([]string, error) { list = append(list, v) } } - sort.Slice(list, func { i, j | return gover.Compare(list[i], list[j]) < 0 }) + sort.Slice(list, func { i, j -> return gover.Compare(list[i], list[j]) < 0 }) return list, nil } diff --git a/src/cmd/go/internal/vcweb/auth.go b/src/cmd/go/internal/vcweb/auth.go index 6db1f9c6087ff..77dc2b7b22049 100644 --- a/src/cmd/go/internal/vcweb/auth.go +++ b/src/cmd/go/internal/vcweb/auth.go @@ -35,7 +35,7 @@ func (h *authHandler) Available() bool { return true } func (h *authHandler) Handler(dir string, env []string, logger *log.Logger) (http.Handler, error) { fs := http.Dir(dir) - handler := http.HandlerFunc(func { w, req | + handler := http.HandlerFunc(func { w, req -> urlPath := req.URL.Path if urlPath != "" && strings.HasPrefix(path.Base(urlPath), ".") { http.Error(w, "filename contains leading dot", http.StatusBadRequest) diff --git a/src/cmd/go/internal/vcweb/fossil.go b/src/cmd/go/internal/vcweb/fossil.go index 4667293f60b9a..d5c74f4b554b5 100644 --- a/src/cmd/go/internal/vcweb/fossil.go +++ b/src/cmd/go/internal/vcweb/fossil.go @@ -42,7 +42,7 @@ func (h *fossilHandler) Handler(dir string, env []string, logger *log.Logger) (h return nil, err } - handler := http.HandlerFunc(func { w, req | + handler := http.HandlerFunc(func { w, req -> if _, err := os.Stat(db); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/src/cmd/go/internal/vcweb/git.go b/src/cmd/go/internal/vcweb/git.go index 1ed27a67217f7..7bf489a5eff6d 100644 --- a/src/cmd/go/internal/vcweb/git.go +++ b/src/cmd/go/internal/vcweb/git.go @@ -42,7 +42,7 @@ func (h *gitHandler) Handler(dir string, env []string, logger *log.Logger) (http "GIT_HTTP_EXPORT_ALL=1", ) - handler := http.HandlerFunc(func { w, req | + handler := http.HandlerFunc(func { w, req -> // The Git client sends the requested Git protocol version as a // "Git-Protocol" HTTP request header, which the CGI host then converts // to an environment variable (HTTP_GIT_PROTOCOL). diff --git a/src/cmd/go/internal/vcweb/hg.go b/src/cmd/go/internal/vcweb/hg.go index 8c7d00b4d5a3b..9b63e38c1aa67 100644 --- a/src/cmd/go/internal/vcweb/hg.go +++ b/src/cmd/go/internal/vcweb/hg.go @@ -39,7 +39,7 @@ func (h *hgHandler) Handler(dir string, env []string, logger *log.Logger) (http. return nil, ServerNotInstalledError{name: "hg"} } - handler := http.HandlerFunc(func { w, req | + handler := http.HandlerFunc(func { w, req -> // Mercurial has a CGI server implementation (called hgweb). In theory we // could use that — however, assuming that hgweb is even installed, the // configuration for hgweb varies by Python version (2 vs 3), and we would diff --git a/src/cmd/go/internal/vcweb/script.go b/src/cmd/go/internal/vcweb/script.go index e74b5f33e02f5..4037ca948b4fb 100644 --- a/src/cmd/go/internal/vcweb/script.go +++ b/src/cmd/go/internal/vcweb/script.go @@ -225,7 +225,7 @@ func scriptAt() script.Cmd { "The argument must be an absolute timestamp in RFC3339 format.", }, }, - func { st, args | + func { st, args -> if len(args) != 1 { return nil, script.ErrUsage } @@ -254,7 +254,7 @@ func scriptHandle() script.Cmd { "Valid handlers include 'dir' (for general http.Dir serving), 'bzr', 'fossil', 'git', and 'hg'", }, }, - func { st, args | + func { st, args -> if len(args) == 0 || len(args) > 2 { return nil, script.ErrUsage } @@ -327,7 +327,7 @@ func scriptUnquote() script.Cmd { Summary: "unquote the argument as a Go string", Args: "string", }, - func { st, args | + func { st, args -> if len(args) != 1 { return nil, script.ErrUsage } diff --git a/src/cmd/go/internal/vcweb/svn.go b/src/cmd/go/internal/vcweb/svn.go index 4f5c5b60adf47..378048bb0828a 100644 --- a/src/cmd/go/internal/vcweb/svn.go +++ b/src/cmd/go/internal/vcweb/svn.go @@ -124,7 +124,7 @@ func (h *svnHandler) Handler(dir string, env []string, logger *log.Logger) (http return nil, err } - handler := http.HandlerFunc(func { w, req | + handler := http.HandlerFunc(func { w, req -> if req.FormValue("vcwebsvn") != "" { w.Header().Add("Content-Type", "text/plain; charset=UTF-8") io.WriteString(w, "svn://"+addr+"\n") diff --git a/src/cmd/go/internal/vcweb/vcstest/vcstest_test.go b/src/cmd/go/internal/vcweb/vcstest/vcstest_test.go index ea5ec5da88015..a158bec804abb 100644 --- a/src/cmd/go/internal/vcweb/vcstest/vcstest_test.go +++ b/src/cmd/go/internal/vcweb/vcstest/vcstest_test.go @@ -92,7 +92,7 @@ func TestScripts(t *testing.T) { // overview of the script status at an arbitrary point during the test. // (We ignore the output because the expected failure mode is a friendly stack // dump from the race detector.) - t.Run("overview", func { t | + t.Run("overview", func { t -> t.Parallel() time.Sleep(1 * time.Millisecond) // Give the other handlers time to race. @@ -128,7 +128,7 @@ func TestScripts(t *testing.T) { srv.Close() }) - err = filepath.WalkDir(scriptDir, func { path, d, err | + err = filepath.WalkDir(scriptDir, func { path, d, err -> if err != nil || d.IsDir() { return err } @@ -141,7 +141,7 @@ func TestScripts(t *testing.T) { return nil } - t.Run(filepath.ToSlash(rel), func { t | + t.Run(filepath.ToSlash(rel), func { t -> t.Parallel() buf := new(strings.Builder) diff --git a/src/cmd/go/internal/vcweb/vcweb.go b/src/cmd/go/internal/vcweb/vcweb.go index bc8464ebeeaab..49eceab7b81f5 100644 --- a/src/cmd/go/internal/vcweb/vcweb.go +++ b/src/cmd/go/internal/vcweb/vcweb.go @@ -239,7 +239,7 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request) { } scriptPath += ".txt" - err := s.HandleScript(scriptPath, s.logger, func { handler | handler.ServeHTTP(w, req) }) + err := s.HandleScript(scriptPath, s.logger, func { handler -> handler.ServeHTTP(w, req) }) if err != nil { s.logger.Print(err) if notFound := (ScriptNotFoundError{}); errors.As(err, ¬Found) { @@ -365,7 +365,7 @@ func (s *Server) overview(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "cache\n") tw := tabwriter.NewWriter(w, 1, 8, 1, '\t', 0) - err := filepath.WalkDir(s.scriptDir, func { path, d, err | + err := filepath.WalkDir(s.scriptDir, func { path, d, err -> if err != nil { return err } diff --git a/src/cmd/go/internal/version/version.go b/src/cmd/go/internal/version/version.go index a532990705a48..40c85e6af4d95 100644 --- a/src/cmd/go/internal/version/version.go +++ b/src/cmd/go/internal/version/version.go @@ -99,7 +99,7 @@ func runVersion(ctx context.Context, cmd *base.Command, args []string) { // scanDir scans a directory for binary to run scanFile on. func scanDir(dir string) { - filepath.WalkDir(dir, func { path, d, err | + filepath.WalkDir(dir, func { path, d, err -> if d.Type().IsRegular() || d.Type()&fs.ModeSymlink != 0 { info, err := d.Info() if err != nil { diff --git a/src/cmd/go/internal/vet/vetflag.go b/src/cmd/go/internal/vet/vetflag.go index 54356a78e0a34..0a0a1559522fd 100644 --- a/src/cmd/go/internal/vet/vetflag.go +++ b/src/cmd/go/internal/vet/vetflag.go @@ -118,7 +118,7 @@ func vetFlags(args []string) (passToVet, packageNames []string) { // the vet tool, but only if they aren't overridden by an explicit argument. base.SetFromGOFLAGS(&CmdVet.Flag) addFromGOFLAGS := map[string]bool{} - CmdVet.Flag.Visit(func { f | if isVetFlag[f.Name] { + CmdVet.Flag.Visit(func { f -> if isVetFlag[f.Name] { addFromGOFLAGS[f.Name] = true } }) @@ -163,7 +163,7 @@ func vetFlags(args []string) (passToVet, packageNames []string) { } // Prepend arguments from GOFLAGS before other arguments. - CmdVet.Flag.Visit(func { f | + CmdVet.Flag.Visit(func { f -> if addFromGOFLAGS[f.Name] { passToVet = append(passToVet, fmt.Sprintf("-%s=%s", f.Name, f.Value)) } diff --git a/src/cmd/go/internal/web/http.go b/src/cmd/go/internal/web/http.go index d1516948d0f1f..e3eb41b23adb2 100644 --- a/src/cmd/go/internal/web/http.go +++ b/src/cmd/go/internal/web/http.go @@ -51,7 +51,7 @@ var securityPreservingDefaultClient = securityPreservingHTTPClient(http.DefaultC func securityPreservingHTTPClient(original *http.Client) *http.Client { c := new(http.Client) *c = *original - c.CheckRedirect = func { req, via | + c.CheckRedirect = func { req, via -> if len(via) > 0 && via[0].URL.Scheme == "https" && req.URL.Scheme != "https" { lastHop := via[len(via)-1].URL return fmt.Errorf("redirected from secure URL %s to insecure URL %s", lastHop, req.URL) diff --git a/src/cmd/go/internal/web/url_test.go b/src/cmd/go/internal/web/url_test.go index 81089cde803f7..6bfd9d1d447ff 100644 --- a/src/cmd/go/internal/web/url_test.go +++ b/src/cmd/go/internal/web/url_test.go @@ -16,7 +16,7 @@ func TestURLToFilePath(t *testing.T) { } tc := tc - t.Run(tc.url, func { t | + t.Run(tc.url, func { t -> u, err := url.Parse(tc.url) if err != nil { t.Fatalf("url.Parse(%q): %v", tc.url, err) @@ -48,7 +48,7 @@ func TestURLFromFilePath(t *testing.T) { } tc := tc - t.Run(tc.filePath, func { t | + t.Run(tc.filePath, func { t -> u, err := urlFromFilePath(tc.filePath) if err != nil { if err.Error() == tc.wantErr { diff --git a/src/cmd/go/internal/work/action.go b/src/cmd/go/internal/work/action.go index 4cdc28f880499..44a3e9dd9fcc0 100644 --- a/src/cmd/go/internal/work/action.go +++ b/src/cmd/go/internal/work/action.go @@ -339,7 +339,7 @@ func (b *Builder) Close() error { func closeBuilders() { leakedBuilders := 0 - builderWorkDirs.Range(func { bi, _ | + builderWorkDirs.Range(func { bi, _ -> leakedBuilders++ if err := bi.(*Builder).Close(); err != nil { base.Error(err) diff --git a/src/cmd/go/internal/work/build_test.go b/src/cmd/go/internal/work/build_test.go index a84b70a787e0b..89b73545c2f83 100644 --- a/src/cmd/go/internal/work/build_test.go +++ b/src/cmd/go/internal/work/build_test.go @@ -226,7 +226,7 @@ func TestRespectSetgidDir(t *testing.T) { // of `(*Shell).ShowCmd` afterwards as a sanity check. cfg.BuildX = true var cmdBuf strings.Builder - sh := NewShell("", func { a | return cmdBuf.WriteString(fmt.Sprint(a...)) }) + sh := NewShell("", func { a -> return cmdBuf.WriteString(fmt.Sprint(a...)) }) setgiddir, err := os.MkdirTemp("", "SetGroupID") if err != nil { diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go index 350e05fadc75b..bd82927eff663 100644 --- a/src/cmd/go/internal/work/exec.go +++ b/src/cmd/go/internal/work/exec.go @@ -54,7 +54,7 @@ func actionList(root *Action) []*Action { seen := map[*Action]bool{} all := []*Action{} var walk func(*Action) - walk = func { a | + walk = func { a -> if seen[a] { return } @@ -3077,7 +3077,7 @@ func (b *Builder) dynimport(a *Action, objdir, importGo, cgoExe string, cflags, var syso []string seen := make(map[*Action]bool) var gatherSyso func(*Action) - gatherSyso = func { a1 | + gatherSyso = func { a1 -> if seen[a1] { return } diff --git a/src/cmd/go/internal/work/shell.go b/src/cmd/go/internal/work/shell.go index 7801a214c3c49..224084939674a 100644 --- a/src/cmd/go/internal/work/shell.go +++ b/src/cmd/go/internal/work/shell.go @@ -54,7 +54,7 @@ type shellShared struct { // If print is nil, it defaults to printing to stderr. func NewShell(workDir string, print func(a ...any) (int, error)) *Shell { if print == nil { - print = func { a | return fmt.Fprint(os.Stderr, a...) } + print = func { a -> return fmt.Fprint(os.Stderr, a...) } } shared := &shellShared{ workDir: workDir, diff --git a/src/cmd/go/internal/work/shell_test.go b/src/cmd/go/internal/work/shell_test.go index ee6bc9d4c103c..16ca776d42709 100644 --- a/src/cmd/go/internal/work/shell_test.go +++ b/src/cmd/go/internal/work/shell_test.go @@ -74,7 +74,7 @@ func FuzzSplitPkgConfigOutput(f *testing.F) { f.Add([]byte(`\`)) f.Add([]byte(`"broken\"" "extra" \`)) - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> t.Parallel() if bytes.ContainsAny(b, "*?[#~%\x00{}!") { diff --git a/src/cmd/go/internal/workcmd/edit.go b/src/cmd/go/internal/workcmd/edit.go index 37e12d144f746..6675df5bcaac2 100644 --- a/src/cmd/go/internal/workcmd/edit.go +++ b/src/cmd/go/internal/workcmd/edit.go @@ -226,7 +226,7 @@ func flagEditworkGodebug(arg string) { if !ok || strings.ContainsAny(arg, "\"`',") { base.Fatalf("go: -godebug=%s: need key=value", arg) } - workedits = append(workedits, func { f | + workedits = append(workedits, func { f -> if err := f.AddGodebug(key, value); err != nil { base.Fatalf("go: -godebug=%s: %v", arg, err) } @@ -235,14 +235,14 @@ func flagEditworkGodebug(arg string) { // flagEditworkDropGodebug implements the -dropgodebug flag. func flagEditworkDropGodebug(arg string) { - workedits = append(workedits, func { f | if err := f.DropGodebug(arg); err != nil { + workedits = append(workedits, func { f -> if err := f.DropGodebug(arg); err != nil { base.Fatalf("go: -dropgodebug=%s: %v", arg, err) } }) } // flagEditworkUse implements the -use flag. func flagEditworkUse(arg string) { - workedits = append(workedits, func { f | + workedits = append(workedits, func { f -> _, mf, err := modload.ReadModFile(filepath.Join(arg, "go.mod"), nil) modulePath := "" if err == nil { @@ -257,7 +257,7 @@ func flagEditworkUse(arg string) { // flagEditworkDropUse implements the -dropuse flag. func flagEditworkDropUse(arg string) { - workedits = append(workedits, func { f | + workedits = append(workedits, func { f -> if err := f.DropUse(modload.ToDirectoryPath(arg)); err != nil { base.Fatalf("go: -dropdirectory=%s: %v", arg, err) } @@ -315,7 +315,7 @@ func flagEditworkReplace(arg string) { base.Fatalf("go: -replace=%s: unversioned new path must be local directory", arg) } - workedits = append(workedits, func { f | + workedits = append(workedits, func { f -> if err := f.AddReplace(oldPath, oldVersion, newPath, newVersion); err != nil { base.Fatalf("go: -replace=%s: %v", arg, err) } @@ -328,7 +328,7 @@ func flagEditworkDropReplace(arg string) { if err != nil { base.Fatalf("go: -dropreplace=%s: %v", arg, err) } - workedits = append(workedits, func { f | + workedits = append(workedits, func { f -> if err := f.DropReplace(path, version); err != nil { base.Fatalf("go: -dropreplace=%s: %v", arg, err) } diff --git a/src/cmd/go/internal/workcmd/use.go b/src/cmd/go/internal/workcmd/use.go index 7016e47ee873c..51655418641c9 100644 --- a/src/cmd/go/internal/workcmd/use.go +++ b/src/cmd/go/internal/workcmd/use.go @@ -149,7 +149,7 @@ func workUse(ctx context.Context, gowork string, wf *modfile.WorkFile, args []st // If the root itself is a symlink to a directory, // we want to follow it (see https://go.dev/issue/50807). // Add a trailing separator to force that to happen. - fsys.Walk(str.WithFilePathSeparator(useDir), func { path, info, err | + fsys.Walk(str.WithFilePathSeparator(useDir), func { path, info, err -> if err != nil { return err } diff --git a/src/cmd/go/proxy_test.go b/src/cmd/go/proxy_test.go index a1fe415e0ced8..c0f7ca15fc129 100644 --- a/src/cmd/go/proxy_test.go +++ b/src/cmd/go/proxy_test.go @@ -463,7 +463,7 @@ func proxyGoSum(path, vers string) ([]byte, error) { names = append(names, name) files[name] = f.Data } - h1, err := dirhash.Hash1(names, func { name | + h1, err := dirhash.Hash1(names, func { name -> data := files[name] return io.NopCloser(bytes.NewReader(data)), nil }) diff --git a/src/cmd/go/script_test.go b/src/cmd/go/script_test.go index fcc6d4169d770..9fd91f7bc4e13 100644 --- a/src/cmd/go/script_test.go +++ b/src/cmd/go/script_test.go @@ -94,7 +94,7 @@ func TestScript(t *testing.T) { Quiet: !testing.Verbose(), } - t.Run("README", func { t | checkScriptReadme(t, engine, env) }) + t.Run("README", func { t -> checkScriptReadme(t, engine, env) }) files, err := filepath.Glob("testdata/script/*.txt") if err != nil { @@ -103,7 +103,7 @@ func TestScript(t *testing.T) { for _, file := range files { file := file name := strings.TrimSuffix(filepath.Base(file), ".txt") - t.Run(name, func { t | + t.Run(name, func { t -> t.Parallel() StartProxy() diff --git a/src/cmd/go/scriptcmds_test.go b/src/cmd/go/scriptcmds_test.go index 3384f0d1d55af..125e25f14e350 100644 --- a/src/cmd/go/scriptcmds_test.go +++ b/src/cmd/go/scriptcmds_test.go @@ -23,7 +23,7 @@ func scriptCommands(interrupt os.Signal, waitDelay time.Duration) map[string]scr // Customize the "exec" interrupt signal and grace period. var cancel func(cmd *exec.Cmd) error if interrupt != nil { - cancel = func { cmd | return cmd.Process.Signal(interrupt) } + cancel = func { cmd -> return cmd.Process.Signal(interrupt) } } cmdExec := script.Exec(cancel, waitDelay) @@ -51,7 +51,7 @@ func scriptCC(cmdExec script.Cmd) script.Cmd { Summary: "run the platform C compiler", Args: "args...", }, - func { s, args | + func { s, args -> b := work.NewBuilder(s.Getwd()) wait, err := cmdExec.Run(s, append(b.GccCmd(".", ""), args...)...) if err != nil { @@ -74,7 +74,7 @@ var scriptGoInvoked sync.Map // testing.TB → go command was invoked func scriptGo(cancel func(*exec.Cmd) error, waitDelay time.Duration) script.Cmd { cmd := script.Program(testGo, cancel, waitDelay) // Inject code to update scriptGoInvoked before invoking the Go command. - return script.Command(*cmd.Usage(), func { state, s | + return script.Command(*cmd.Usage(), func { state, s -> t, ok := tbFromContext(state.Context()) if !ok { return nil, errors.New("script Context unexpectedly missing testing.TB key") @@ -94,7 +94,7 @@ func scriptStale(cmdGo script.Cmd) script.Cmd { Summary: "check that build targets are stale", Args: "target...", }, - func { s, args | + func { s, args -> if len(args) == 0 { return nil, script.ErrUsage } diff --git a/src/cmd/go/scriptconds_test.go b/src/cmd/go/scriptconds_test.go index 2f03143fa958a..04b66946a5c5b 100644 --- a/src/cmd/go/scriptconds_test.go +++ b/src/cmd/go/scriptconds_test.go @@ -87,7 +87,7 @@ func ccIs(s *script.State, want string) (bool, error) { func sysCondition(flag string, f func(goos, goarch string) bool, needsCgo bool) script.Cond { return script.Condition( "GOOS/GOARCH supports "+flag, - func { s | + func { s -> GOOS, _ := s.LookupEnv("GOOS") GOARCH, _ := s.LookupEnv("GOARCH") cross := goHostOS != GOOS || goHostArch != GOARCH diff --git a/src/cmd/go/terminal_test.go b/src/cmd/go/terminal_test.go index 04aae65855e03..4cb7ed3c90659 100644 --- a/src/cmd/go/terminal_test.go +++ b/src/cmd/go/terminal_test.go @@ -26,7 +26,7 @@ func TestTerminalPassthrough(t *testing.T) { // Start with a "self test" to make sure that if we *don't* pass in a // terminal, the test can correctly detect that. (cmd/go doesn't guarantee // that it won't add a terminal in the middle, but that would be pretty weird.) - t.Run("pipe", func { t | + t.Run("pipe", func { t -> r, w, err := os.Pipe() if err != nil { t.Fatalf("pipe failed: %s", err) @@ -43,7 +43,7 @@ func TestTerminalPassthrough(t *testing.T) { }) // Now test with a read PTY. - t.Run("pty", func { t | + t.Run("pty", func { t -> r, processTTY, err := testpty.Open() if errors.Is(err, testpty.ErrNotSupported) { t.Skipf("%s", err) diff --git a/src/cmd/gofmt/gofmt.go b/src/cmd/gofmt/gofmt.go index 478d1e506f193..62f5873d7ed19 100644 --- a/src/cmd/gofmt/gofmt.go +++ b/src/cmd/gofmt/gofmt.go @@ -169,7 +169,7 @@ func (s *sequencer) AddReport(err error) { // exit code for the sequence suitable for passing to os.Exit. func (s *sequencer) GetExitCode() int { c := make(chan int, 1) - s.Add(0, func { r | + s.Add(0, func { r -> c <- r.ExitCode() return nil }) @@ -404,7 +404,7 @@ func gofmtMain(s *sequencer) { s.AddReport(fmt.Errorf("error: cannot use -w with standard input")) return } - s.Add(0, func { r | return processFile("", nil, os.Stdin, r) }) + s.Add(0, func { r -> return processFile("", nil, os.Stdin, r) }) return } @@ -415,10 +415,10 @@ func gofmtMain(s *sequencer) { case !info.IsDir(): // Non-directory arguments are always formatted. arg := arg - s.Add(fileWeight(arg, info), func { r | return processFile(arg, info, nil, r) }) + s.Add(fileWeight(arg, info), func { r -> return processFile(arg, info, nil, r) }) default: // Directories are walked, ignoring non-Go files. - err := filepath.WalkDir(arg, func { path, f, err | + err := filepath.WalkDir(arg, func { path, f, err -> if err != nil || !isGoFile(f) { return err } @@ -427,7 +427,7 @@ func gofmtMain(s *sequencer) { s.AddReport(err) return nil } - s.Add(fileWeight(path, info), func { r | return processFile(path, info, nil, r) }) + s.Add(fileWeight(path, info), func { r -> return processFile(path, info, nil, r) }) return nil }) if err != nil { diff --git a/src/cmd/gofmt/gofmt_test.go b/src/cmd/gofmt/gofmt_test.go index 03a1e82822615..d897cfad60655 100644 --- a/src/cmd/gofmt/gofmt_test.go +++ b/src/cmd/gofmt/gofmt_test.go @@ -90,7 +90,7 @@ func runTest(t *testing.T, in, out string) { const maxWeight = 2 << 20 var buf, errBuf bytes.Buffer s := newSequencer(maxWeight, &buf, &errBuf) - s.Add(fileWeight(in, info), func { r | return processFile(in, info, nil, r) }) + s.Add(fileWeight(in, info), func { r -> return processFile(in, info, nil, r) }) if errBuf.Len() > 0 { t.Logf("%q", errBuf.Bytes()) } @@ -143,7 +143,7 @@ func TestRewrite(t *testing.T) { for _, in := range match { name := filepath.Base(in) - t.Run(name, func { t | + t.Run(name, func { t -> out := in // for files where input and output are identical if strings.HasSuffix(in, ".input") { out = in[:len(in)-len(".input")] + ".golden" diff --git a/src/cmd/gofmt/gofmt_unix_test.go b/src/cmd/gofmt/gofmt_unix_test.go index c516869b90e72..e91c6330530a5 100644 --- a/src/cmd/gofmt/gofmt_unix_test.go +++ b/src/cmd/gofmt/gofmt_unix_test.go @@ -47,7 +47,7 @@ func TestPermissions(t *testing.T) { const maxWeight = 2 << 20 var buf, errBuf strings.Builder s := newSequencer(maxWeight, &buf, &errBuf) - s.Add(fileWeight(fn, info), func { r | return processFile(fn, info, nil, r) }) + s.Add(fileWeight(fn, info), func { r -> return processFile(fn, info, nil, r) }) if s.GetExitCode() == 0 { t.Fatal("rewrite of read-only file succeeded unexpectedly") } diff --git a/src/cmd/gofmt/internal.go b/src/cmd/gofmt/internal.go index 2c5c3cbf1707b..1f8f35fed6e7f 100644 --- a/src/cmd/gofmt/internal.go +++ b/src/cmd/gofmt/internal.go @@ -42,7 +42,7 @@ func parse(fset *token.FileSet, filename string, src []byte, fragmentOk bool) ( psrc := append([]byte("package p;"), src...) file, err = parser.ParseFile(fset, filename, psrc, parserMode) if err == nil { - sourceAdj = func { src, indent | + sourceAdj = func { src, indent -> // Remove the package clause. // Gofmt has turned the ';' into a '\n'. src = src[indent+len("package p\n"):] @@ -66,7 +66,7 @@ func parse(fset *token.FileSet, filename string, src []byte, fragmentOk bool) ( fsrc := append(append([]byte("package p; func _() {"), src...), '\n', '\n', '}') file, err = parser.ParseFile(fset, filename, fsrc, parserMode) if err == nil { - sourceAdj = func { src, indent | + sourceAdj = func { src, indent -> // Cap adjusted indent to zero. if indent < 0 { indent = 0 diff --git a/src/cmd/gofmt/rewrite.go b/src/cmd/gofmt/rewrite.go index cf62a0b06fdbc..e9a06f2ffa371 100644 --- a/src/cmd/gofmt/rewrite.go +++ b/src/cmd/gofmt/rewrite.go @@ -28,7 +28,7 @@ func initRewrite() { } pattern := parseExpr(f[0], "pattern") replace := parseExpr(f[1], "replacement") - rewrite = func { fset, p | return rewriteFile(fset, pattern, replace, p) } + rewrite = func { fset, p -> return rewriteFile(fset, pattern, replace, p) } } // parseExpr parses s as an expression. @@ -61,7 +61,7 @@ func rewriteFile(fileSet *token.FileSet, pattern, replace ast.Expr, p *ast.File) repl := reflect.ValueOf(replace) var rewriteVal func(val reflect.Value) reflect.Value - rewriteVal = func { val | + rewriteVal = func { val -> // don't bother if val is invalid to start with if !val.IsValid() { return reflect.Value{} diff --git a/src/cmd/internal/bootstrap_test/overlaydir_test.go b/src/cmd/internal/bootstrap_test/overlaydir_test.go index ac95addeee19b..77fda98d75827 100644 --- a/src/cmd/internal/bootstrap_test/overlaydir_test.go +++ b/src/cmd/internal/bootstrap_test/overlaydir_test.go @@ -27,7 +27,7 @@ func overlayDir(dstRoot, srcRoot string) error { return err } - return filepath.WalkDir(srcRoot, func { srcPath, entry, err | + return filepath.WalkDir(srcRoot, func { srcPath, entry, err -> if err != nil || srcPath == srcRoot { return err } diff --git a/src/cmd/internal/bootstrap_test/reboot_test.go b/src/cmd/internal/bootstrap_test/reboot_test.go index a11cb7eadfa6f..942bab06c265c 100644 --- a/src/cmd/internal/bootstrap_test/reboot_test.go +++ b/src/cmd/internal/bootstrap_test/reboot_test.go @@ -83,7 +83,7 @@ func TestRepeatBootstrap(t *testing.T) { } // Test that go.dev/issue/42563 hasn't regressed. - t.Run("PATH reminder", func { t | + t.Run("PATH reminder", func { t -> var want string switch gorootBin := filepath.Join(goroot, "bin"); runtime.GOOS { default: diff --git a/src/cmd/internal/dwarf/dwarf_test.go b/src/cmd/internal/dwarf/dwarf_test.go index 3cd6c50326e15..823b695f28f1c 100644 --- a/src/cmd/internal/dwarf/dwarf_test.go +++ b/src/cmd/internal/dwarf/dwarf_test.go @@ -10,7 +10,7 @@ import ( ) func TestSevenBitEnc128(t *testing.T) { - t.Run("unsigned", func { t | + t.Run("unsigned", func { t -> for v := int64(-255); v < 255; v++ { s := sevenBitU(v) if s == nil { @@ -23,7 +23,7 @@ func TestSevenBitEnc128(t *testing.T) { } }) - t.Run("signed", func { t | + t.Run("signed", func { t -> for v := int64(-255); v < 255; v++ { s := sevenBitS(v) if s == nil { diff --git a/src/cmd/internal/dwarf/putvarabbrevgen_test.go b/src/cmd/internal/dwarf/putvarabbrevgen_test.go index 46929740af650..56a7ba8d53a4c 100644 --- a/src/cmd/internal/dwarf/putvarabbrevgen_test.go +++ b/src/cmd/internal/dwarf/putvarabbrevgen_test.go @@ -179,7 +179,7 @@ func pvacfgbody(t *testing.T, fset *token.FileSet, cm ast.CommentMap, body []ast } default: // check that nothing under this contains a putattr call - ast.Inspect(stmt, func { n | + ast.Inspect(stmt, func { n -> if call, _ := n.(*ast.CallExpr); call != nil { if exprToString(call.Fun) == "putattr" { t.Fatalf("%s use of putattr in unsupported block", fset.Position(call.Pos())) diff --git a/src/cmd/internal/moddeps/moddeps_test.go b/src/cmd/internal/moddeps/moddeps_test.go index 6579c5f8065cb..98ec1785faae9 100644 --- a/src/cmd/internal/moddeps/moddeps_test.go +++ b/src/cmd/internal/moddeps/moddeps_test.go @@ -49,7 +49,7 @@ func TestAllDependencies(t *testing.T) { for _, m := range findGorootModules(t) { // This short test does NOT ensure that the vendored contents match // the unmodified contents of the corresponding dependency versions. - t.Run(m.Path+"(quick)", func { t | + t.Run(m.Path+"(quick)", func { t -> t.Logf("module %s in directory %s", m.Path, m.Dir) if m.hasVendor { @@ -173,7 +173,7 @@ func TestAllDependencies(t *testing.T) { gorootCopyDir = makeGOROOTCopy(t) } - t.Run(m.Path+"(thorough)", func { t | + t.Run(m.Path+"(thorough)", func { t -> t.Logf("module %s in directory %s", m.Path, m.Dir) defer func() { @@ -254,7 +254,7 @@ func makeGOROOTCopy(t *testing.T) string { t.Helper() gorootCopyDir := t.TempDir() - err := filepath.Walk(testenv.GOROOT(t), func { src, info, err | + err := filepath.Walk(testenv.GOROOT(t), func { src, info, err -> if err != nil { return err } @@ -448,7 +448,7 @@ func findGorootModules(t *testing.T) []gorootModule { if !os.IsPathSeparator(root[len(root)-1]) { root += string(filepath.Separator) } - goroot.err = filepath.WalkDir(root, func { path, info, err | + goroot.err = filepath.WalkDir(root, func { path, info, err -> if err != nil { return err } @@ -521,7 +521,7 @@ func findGorootModules(t *testing.T) []gorootModule { break } } - sort.Slice(goroot.modules, func { i, j | return goroot.modules[i].Dir < goroot.modules[j].Dir }) + sort.Slice(goroot.modules, func { i, j -> return goroot.modules[i].Dir < goroot.modules[j].Dir }) }) if goroot.err != nil { t.Fatal(goroot.err) diff --git a/src/cmd/internal/notsha256/sha256_test.go b/src/cmd/internal/notsha256/sha256_test.go index 7ed38aefdc066..b7e561795bd2b 100644 --- a/src/cmd/internal/notsha256/sha256_test.go +++ b/src/cmd/internal/notsha256/sha256_test.go @@ -144,7 +144,7 @@ var buf = make([]byte, 8192) func benchmarkSize(b *testing.B, size int) { sum := make([]byte, bench.Size()) - b.Run("New", func { b | + b.Run("New", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { @@ -153,7 +153,7 @@ func benchmarkSize(b *testing.B, size int) { bench.Sum(sum[:0]) } }) - b.Run("Sum256", func { b | + b.Run("Sum256", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { diff --git a/src/cmd/internal/obj/dwarf.go b/src/cmd/internal/obj/dwarf.go index c9243500e9b86..170d1da353c56 100644 --- a/src/cmd/internal/obj/dwarf.go +++ b/src/cmd/internal/obj/dwarf.go @@ -388,7 +388,7 @@ func (ctxt *Link) DwarfIntConst(name, typename string, val int64) { if myimportpath == "" { return } - s := ctxt.LookupInit(dwarf.ConstInfoPrefix+myimportpath, func { s | + s := ctxt.LookupInit(dwarf.ConstInfoPrefix+myimportpath, func { s -> s.Type = objabi.SDWARFCONST ctxt.Data = append(ctxt.Data, s) }) diff --git a/src/cmd/internal/obj/inl.go b/src/cmd/internal/obj/inl.go index a2b316d145437..702105c1a398b 100644 --- a/src/cmd/internal/obj/inl.go +++ b/src/cmd/internal/obj/inl.go @@ -129,7 +129,7 @@ func (ctxt *Link) InnermostPos(xpos src.XPos) src.Pos { // AllPos invokes do with the position in f, then the position in g, then the position in h. func (ctxt *Link) AllPos(xpos src.XPos, do func(src.Pos)) { pos := ctxt.InnermostPos(xpos) - ctxt.InlTree.AllParents(pos.Base().InliningIndex(), func { call | do(ctxt.InnermostPos(call.Pos)) }) + ctxt.InlTree.AllParents(pos.Base().InliningIndex(), func { call -> do(ctxt.InnermostPos(call.Pos)) }) do(pos) } diff --git a/src/cmd/internal/obj/loong64/asm.go b/src/cmd/internal/obj/loong64/asm.go index 378f7bb3bb0c9..05d980eff1b0f 100644 --- a/src/cmd/internal/obj/loong64/asm.go +++ b/src/cmd/internal/obj/loong64/asm.go @@ -1044,7 +1044,7 @@ func opset(a, b0 obj.As) { func buildop(ctxt *obj.Link) { if ctxt.DiagFunc == nil { - ctxt.DiagFunc = func { format, args | log.Printf(format, args...) } + ctxt.DiagFunc = func { format, args -> log.Printf(format, args...) } } if oprange[AOR&obj.AMask] != nil { diff --git a/src/cmd/internal/obj/objfile.go b/src/cmd/internal/obj/objfile.go index ecb31bcd4c4ac..6001bf51d5ffa 100644 --- a/src/cmd/internal/obj/objfile.go +++ b/src/cmd/internal/obj/objfile.go @@ -282,7 +282,7 @@ func (w *writer) StringTable() { for _, pkg := range w.pkglist { w.AddString(pkg) } - w.ctxt.traverseSyms(traverseAll, func { s | + w.ctxt.traverseSyms(traverseAll, func { s -> // Don't put names of builtins into the string table (to save // space). if s.PkgIdx == goobj.PkgIdxBuiltin { @@ -637,7 +637,7 @@ func (w *writer) Aux(s *LSym) { // Emits flags of referenced indexed symbols. func (w *writer) refFlags() { seen := make(map[*LSym]bool) - w.ctxt.traverseSyms(traverseRefs, func { rs | // only traverse refs, not auxs, as tools don't need auxs + w.ctxt.traverseSyms(traverseRefs, func { rs -> // only traverse refs, not auxs, as tools don't need auxs switch rs.PkgIdx { case goobj.PkgIdxNone, goobj.PkgIdxHashed64, goobj.PkgIdxHashed, goobj.PkgIdxBuiltin, goobj.PkgIdxSelf: // not an external indexed reference return @@ -670,7 +670,7 @@ func (w *writer) refNames() { return } seen := make(map[*LSym]bool) - w.ctxt.traverseSyms(traverseRefs, func { rs | // only traverse refs, not auxs, as tools don't need auxs + w.ctxt.traverseSyms(traverseRefs, func { rs -> // only traverse refs, not auxs, as tools don't need auxs switch rs.PkgIdx { case goobj.PkgIdxNone, goobj.PkgIdxHashed64, goobj.PkgIdxHashed, goobj.PkgIdxBuiltin, goobj.PkgIdxSelf: // not an external indexed reference return @@ -769,7 +769,7 @@ func genFuncInfoSyms(ctxt *Link) { o.File[i] = f i++ } - sort.Slice(o.File, func { i, j | return o.File[i] < o.File[j] }) + sort.Slice(o.File, func { i, j -> return o.File[i] < o.File[j] }) o.InlTree = make([]goobj.InlTreeNode, len(pc.InlTree.nodes)) for i, inl := range pc.InlTree.nodes { f, l := ctxt.getFileIndexAndLine(inl.Pos) diff --git a/src/cmd/internal/obj/ppc64/obj9.go b/src/cmd/internal/obj/ppc64/obj9.go index c8c466bc7bb77..ba4670f561cc0 100644 --- a/src/cmd/internal/obj/ppc64/obj9.go +++ b/src/cmd/internal/obj/ppc64/obj9.go @@ -351,7 +351,7 @@ func (c *ctxt9) rewriteToUseTOC(p *obj.Prog) { sym = c.ctxt.Lookup("runtime.duffcopy") } // Retrieve or create the TOC anchor. - symtoc := c.ctxt.LookupInit("TOC."+sym.Name, func { s | + symtoc := c.ctxt.LookupInit("TOC."+sym.Name, func { s -> s.Type = objabi.SDATA s.Set(obj.AttrDuplicateOK, true) s.Set(obj.AttrStatic, true) @@ -433,7 +433,7 @@ func (c *ctxt9) rewriteToUseTOC(p *obj.Prog) { } // Retrieve or create the TOC anchor. - symtoc := c.ctxt.LookupInit("TOC."+source.Sym.Name, func { s | + symtoc := c.ctxt.LookupInit("TOC."+source.Sym.Name, func { s -> s.Type = objabi.SDATA s.Set(obj.AttrDuplicateOK, true) s.Set(obj.AttrStatic, true) diff --git a/src/cmd/internal/obj/sym.go b/src/cmd/internal/obj/sym.go index 5455df14d8e36..958eb47e7c3d3 100644 --- a/src/cmd/internal/obj/sym.go +++ b/src/cmd/internal/obj/sym.go @@ -140,7 +140,7 @@ func (ctxt *Link) LookupInit(name string, init func(s *LSym)) *LSym { func (ctxt *Link) Float32Sym(f float32) *LSym { i := math.Float32bits(f) name := fmt.Sprintf("$f32.%08x", i) - return ctxt.LookupInit(name, func { s | + return ctxt.LookupInit(name, func { s -> s.Size = 4 s.WriteFloat32(ctxt, 0, f) s.Type = objabi.SRODATA @@ -153,7 +153,7 @@ func (ctxt *Link) Float32Sym(f float32) *LSym { func (ctxt *Link) Float64Sym(f float64) *LSym { i := math.Float64bits(f) name := fmt.Sprintf("$f64.%016x", i) - return ctxt.LookupInit(name, func { s | + return ctxt.LookupInit(name, func { s -> s.Size = 8 s.WriteFloat64(ctxt, 0, f) s.Type = objabi.SRODATA @@ -165,7 +165,7 @@ func (ctxt *Link) Float64Sym(f float64) *LSym { func (ctxt *Link) Int32Sym(i int64) *LSym { name := fmt.Sprintf("$i32.%08x", uint64(i)) - return ctxt.LookupInit(name, func { s | + return ctxt.LookupInit(name, func { s -> s.Size = 4 s.WriteInt(ctxt, 0, 4, i) s.Type = objabi.SRODATA @@ -177,7 +177,7 @@ func (ctxt *Link) Int32Sym(i int64) *LSym { func (ctxt *Link) Int64Sym(i int64) *LSym { name := fmt.Sprintf("$i64.%016x", uint64(i)) - return ctxt.LookupInit(name, func { s | + return ctxt.LookupInit(name, func { s -> s.Size = 8 s.WriteInt(ctxt, 0, 8, i) s.Type = objabi.SRODATA @@ -189,7 +189,7 @@ func (ctxt *Link) Int64Sym(i int64) *LSym { func (ctxt *Link) Int128Sym(hi, lo int64) *LSym { name := fmt.Sprintf("$i128.%016x%016x", uint64(hi), uint64(lo)) - return ctxt.LookupInit(name, func { s | + return ctxt.LookupInit(name, func { s -> s.Size = 16 if ctxt.Arch.ByteOrder == binary.LittleEndian { s.WriteInt(ctxt, 0, 8, lo) @@ -209,7 +209,7 @@ func (ctxt *Link) Int128Sym(hi, lo int64) *LSym { func (ctxt *Link) GCLocalsSym(data []byte) *LSym { sum := notsha256.Sum256(data) str := base64.StdEncoding.EncodeToString(sum[:16]) - return ctxt.LookupInit(fmt.Sprintf("gclocals·%s", str), func { lsym | + return ctxt.LookupInit(fmt.Sprintf("gclocals·%s", str), func { lsym -> lsym.P = data lsym.Set(AttrContentAddressable, true) }) @@ -232,17 +232,17 @@ func (ctxt *Link) NumberSyms() { // any original entries with the same name (all DWARFVAR symbols // have empty names but different relocation sets) are not shuffled. // TODO: Find a better place and optimize to only sort TOC symbols. - sort.SliceStable(ctxt.Data, func { i, j | return ctxt.Data[i].Name < ctxt.Data[j].Name }) + sort.SliceStable(ctxt.Data, func { i, j -> return ctxt.Data[i].Name < ctxt.Data[j].Name }) } // Constant symbols are created late in the concurrent phase. Sort them // to ensure a deterministic order. - sort.Slice(ctxt.constSyms, func { i, j | return ctxt.constSyms[i].Name < ctxt.constSyms[j].Name }) + sort.Slice(ctxt.constSyms, func { i, j -> return ctxt.constSyms[i].Name < ctxt.constSyms[j].Name }) ctxt.Data = append(ctxt.Data, ctxt.constSyms...) ctxt.constSyms = nil // So are SEH symbols. - sort.Slice(ctxt.SEHSyms, func { i, j | return ctxt.SEHSyms[i].Name < ctxt.SEHSyms[j].Name }) + sort.Slice(ctxt.SEHSyms, func { i, j -> return ctxt.SEHSyms[i].Name < ctxt.SEHSyms[j].Name }) ctxt.Data = append(ctxt.Data, ctxt.SEHSyms...) ctxt.SEHSyms = nil @@ -253,7 +253,7 @@ func (ctxt *Link) NumberSyms() { ctxt.nonpkgdefs = []*LSym{} var idx, hashedidx, hashed64idx, nonpkgidx int32 - ctxt.traverseSyms(traverseDefs|traversePcdata, func { s | + ctxt.traverseSyms(traverseDefs|traversePcdata, func { s -> if s.ContentAddressable() { if s.Size <= 8 && len(s.R) == 0 && contentHashSection(s) == 0 { // We can use short hash only for symbols without relocations. @@ -297,7 +297,7 @@ func (ctxt *Link) NumberSyms() { ipkg := int32(1) // 0 is invalid index nonpkgdef := nonpkgidx - ctxt.traverseSyms(traverseRefs|traverseAux, func { rs | + ctxt.traverseSyms(traverseRefs|traverseAux, func { rs -> if rs.PkgIdx != goobj.PkgIdxInvalid { return } @@ -440,7 +440,7 @@ func (ctxt *Link) traverseFuncAux(flag traverseFlag, fsym *LSym, fn func(parent for f := range pc.UsedFiles { usedFiles = append(usedFiles, f) } - sort.Slice(usedFiles, func { i, j | return usedFiles[i] < usedFiles[j] }) + sort.Slice(usedFiles, func { i, j -> return usedFiles[i] < usedFiles[j] }) for _, f := range usedFiles { if filesym := ctxt.Lookup(files[f]); filesym != nil { fn(fsym, filesym) diff --git a/src/cmd/internal/obj/x86/asm_test.go b/src/cmd/internal/obj/x86/asm_test.go index cd8602f3634b5..27b7f6ec85454 100644 --- a/src/cmd/internal/obj/x86/asm_test.go +++ b/src/cmd/internal/obj/x86/asm_test.go @@ -215,13 +215,13 @@ func TestOclass(t *testing.T) { // TODO(quasilyte): test edge cases for Hsolaris, etc? - t.Run("linux/AMD64", func { t | + t.Run("linux/AMD64", func { t -> ctxtAMD64 := obj.Linknew(&Linkamd64) ctxtAMD64.Headtype = objabi.Hlinux // See #32028 runTest(t, ctxtAMD64, oclassTestsAMD64) }) - t.Run("linux/386", func { t | + t.Run("linux/386", func { t -> ctxt386 := obj.Linknew(&Link386) ctxt386.Headtype = objabi.Hlinux // See #32028 runTest(t, ctxt386, oclassTests386) diff --git a/src/cmd/internal/obj/x86/obj6.go b/src/cmd/internal/obj/x86/obj6.go index c4c809ca13eea..26985c154130f 100644 --- a/src/cmd/internal/obj/x86/obj6.go +++ b/src/cmd/internal/obj/x86/obj6.go @@ -570,7 +570,7 @@ func rewriteToPcrel(ctxt *obj.Link, p *obj.Prog, newprog obj.ProgAlloc) { r.RegTo2 = 1 q.As = obj.ACALL thunkname := "__x86.get_pc_thunk." + strings.ToLower(rconv(int(dst))) - q.To.Sym = ctxt.LookupInit(thunkname, func { s | s.Set(obj.AttrLocal, true) }) + q.To.Sym = ctxt.LookupInit(thunkname, func { s -> s.Set(obj.AttrLocal, true) }) q.To.Type = obj.TYPE_MEM q.To.Name = obj.NAME_EXTERN r.As = p.As diff --git a/src/cmd/internal/obj/x86/seh.go b/src/cmd/internal/obj/x86/seh.go index 149c6afd384b3..550268c47bcb7 100644 --- a/src/cmd/internal/obj/x86/seh.go +++ b/src/cmd/internal/obj/x86/seh.go @@ -146,7 +146,7 @@ func populateSeh(ctxt *obj.Link, s *obj.LSym) (sehsym *obj.LSym) { // Dedup them when possible. hash := base64.StdEncoding.EncodeToString(buf.data) symname := fmt.Sprintf("%d.%s", len(buf.data), hash) - return ctxt.LookupInit("go:sehuw."+symname, func { s | + return ctxt.LookupInit("go:sehuw."+symname, func { s -> s.WriteBytes(ctxt, 0, buf.data) s.Type = objabi.SSEHUNWINDINFO s.Set(obj.AttrDuplicateOK, true) diff --git a/src/cmd/internal/objabi/pkgspecial.go b/src/cmd/internal/objabi/pkgspecial.go index 0a024313f76a3..c02a19fee13e7 100644 --- a/src/cmd/internal/objabi/pkgspecial.go +++ b/src/cmd/internal/objabi/pkgspecial.go @@ -109,23 +109,23 @@ func LookupPkgSpecial(pkgPath string) PkgSpecial { pkgSpecials[elt] = s } for _, pkg := range runtimePkgs { - set(pkg, func { ps | + set(pkg, func { ps -> ps.Runtime = true ps.NoInstrument = true }) } for _, pkg := range extraNoInstrumentPkgs { if pkg[0] == '-' { - set(pkg[1:], func { ps | ps.NoInstrument = false }) + set(pkg[1:], func { ps -> ps.NoInstrument = false }) } else { - set(pkg, func { ps | ps.NoInstrument = true }) + set(pkg, func { ps -> ps.NoInstrument = true }) } } for _, pkg := range noRaceFuncPkgs { - set(pkg, func { ps | ps.NoRaceFunc = true }) + set(pkg, func { ps -> ps.NoRaceFunc = true }) } for _, pkg := range allowAsmABIPkgs { - set(pkg, func { ps | ps.AllowAsmABI = true }) + set(pkg, func { ps -> ps.AllowAsmABI = true }) } }) return pkgSpecials[pkgPath] diff --git a/src/cmd/internal/objfile/disasm.go b/src/cmd/internal/objfile/disasm.go index 310772c63e37d..03ae051640268 100644 --- a/src/cmd/internal/objfile/disasm.go +++ b/src/cmd/internal/objfile/disasm.go @@ -90,7 +90,7 @@ func (e *Entry) Disasm() (*Disasm, error) { // lookup finds the symbol name containing addr. func (d *Disasm) lookup(addr uint64) (name string, base uint64) { - i := sort.Search(len(d.syms), func { i | return addr < d.syms[i].Addr }) + i := sort.Search(len(d.syms), func { i -> return addr < d.syms[i].Addr }) if i > 0 { s := d.syms[i-1] if s.Addr != 0 && s.Addr <= addr && addr < s.Addr+uint64(s.Size) { @@ -229,7 +229,7 @@ func (d *Disasm) Print(w io.Writer, filter *regexp.Regexp, start, end uint64, pr var lastFile string var lastLine int - d.Decode(symStart, symEnd, relocs, gnuAsm, func { pc, size, file, line, text | + d.Decode(symStart, symEnd, relocs, gnuAsm, func { pc, size, file, line, text -> i := pc - d.textStart if printCode { diff --git a/src/cmd/internal/objfile/macho.go b/src/cmd/internal/objfile/macho.go index b9d3357fa7e76..659cc9e5c812d 100644 --- a/src/cmd/internal/objfile/macho.go +++ b/src/cmd/internal/objfile/macho.go @@ -51,7 +51,7 @@ func (f *machoFile) symbols() ([]Sym, error) { continue } sym := Sym{Name: s.Name, Addr: s.Value, Code: '?'} - i := sort.Search(len(addrs), func { x | return addrs[x] > s.Value }) + i := sort.Search(len(addrs), func { x -> return addrs[x] > s.Value }) if i < len(addrs) { sym.Size = int64(addrs[i] - s.Value) } diff --git a/src/cmd/internal/objfile/pe.go b/src/cmd/internal/objfile/pe.go index 8173edb41f129..24431b284772a 100644 --- a/src/cmd/internal/objfile/pe.go +++ b/src/cmd/internal/objfile/pe.go @@ -80,7 +80,7 @@ func (f *peFile) symbols() ([]Sym, error) { sort.Sort(uint64s(addrs)) for i := range syms { - j := sort.Search(len(addrs), func { x | return addrs[x] > syms[i].Addr }) + j := sort.Search(len(addrs), func { x -> return addrs[x] > syms[i].Addr }) if j < len(addrs) { syms[i].Size = int64(addrs[j] - syms[i].Addr) } diff --git a/src/cmd/internal/objfile/plan9obj.go b/src/cmd/internal/objfile/plan9obj.go index d6bd07f91c962..e2743015c9f3b 100644 --- a/src/cmd/internal/objfile/plan9obj.go +++ b/src/cmd/internal/objfile/plan9obj.go @@ -60,7 +60,7 @@ func (f *plan9File) symbols() ([]Sym, error) { continue } sym := Sym{Addr: s.Value, Name: s.Name, Code: s.Type} - i := sort.Search(len(addrs), func { x | return addrs[x] > s.Value }) + i := sort.Search(len(addrs), func { x -> return addrs[x] > s.Value }) if i < len(addrs) { sym.Size = int64(addrs[i] - s.Value) } diff --git a/src/cmd/internal/pgo/pprof.go b/src/cmd/internal/pgo/pprof.go index f058a73968a7b..4aa3a875e1787 100644 --- a/src/cmd/internal/pgo/pprof.go +++ b/src/cmd/internal/pgo/pprof.go @@ -103,7 +103,7 @@ func createNamedEdgeMap(g *profile.Graph) (edgeMap NamedEdgeMap, totalWeight int } func sortByWeight(edges []NamedCallEdge, weight map[NamedCallEdge]int64) { - sort.Slice(edges, func { i, j | + sort.Slice(edges, func { i, j -> ei, ej := edges[i], edges[j] if wi, wj := weight[ei], weight[ej]; wi != wj { return wi > wj // want larger weight first diff --git a/src/cmd/internal/pgo/serialize_test.go b/src/cmd/internal/pgo/serialize_test.go index 72dffd88e037f..80b54a67a549d 100644 --- a/src/cmd/internal/pgo/serialize_test.go +++ b/src/cmd/internal/pgo/serialize_test.go @@ -183,7 +183,7 @@ func constructFuzzProfile(t *testing.T, b []byte) *Profile { func FuzzRoundTrip(f *testing.F) { f.Add([]byte("")) // empty profile - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> d := constructFuzzProfile(t, b) testRoundTrip(t, d) }) diff --git a/src/cmd/internal/pkgpath/pkgpath_test.go b/src/cmd/internal/pkgpath/pkgpath_test.go index 2483bd97b5a88..613be5d09d802 100644 --- a/src/cmd/internal/pkgpath/pkgpath_test.go +++ b/src/cmd/internal/pkgpath/pkgpath_test.go @@ -67,7 +67,7 @@ func TestToSymbolFunc(t *testing.T) { defer os.Unsetenv(testEnvName) for _, test := range tests { - t.Run(test.env, func { t | + t.Run(test.env, func { t -> os.Setenv(testEnvName, test.env) fn, err := ToSymbolFunc(cmd, tmpdir) diff --git a/src/cmd/internal/pkgpattern/pat_test.go b/src/cmd/internal/pkgpattern/pat_test.go index 50d018edb49a5..f7d04511578e9 100644 --- a/src/cmd/internal/pkgpattern/pat_test.go +++ b/src/cmd/internal/pkgpattern/pat_test.go @@ -65,7 +65,7 @@ var matchPatternTests = ` ` func TestMatchPattern(t *testing.T) { - testPatterns(t, "MatchPattern", matchPatternTests, func { pattern, name | return MatchPattern(pattern)(name) }) + testPatterns(t, "MatchPattern", matchPatternTests, func { pattern, name -> return MatchPattern(pattern)(name) }) } var matchSimplePatternTests = ` @@ -97,7 +97,7 @@ var matchSimplePatternTests = ` ` func TestSimpleMatchPattern(t *testing.T) { - testPatterns(t, "MatchSimplePattern", matchSimplePatternTests, func { pattern, name | return MatchSimplePattern(pattern)(name) }) + testPatterns(t, "MatchSimplePattern", matchSimplePatternTests, func { pattern, name -> return MatchSimplePattern(pattern)(name) }) } var treeCanMatchPatternTests = ` @@ -136,7 +136,7 @@ var treeCanMatchPatternTests = ` ` func TestTreeCanMatchPattern(t *testing.T) { - testPatterns(t, "TreeCanMatchPattern", treeCanMatchPatternTests, func { pattern, name | return TreeCanMatchPattern(pattern)(name) }) + testPatterns(t, "TreeCanMatchPattern", treeCanMatchPatternTests, func { pattern, name -> return TreeCanMatchPattern(pattern)(name) }) } var hasPathPrefixTests = []stringPairTest{ diff --git a/src/cmd/internal/quoted/quoted_test.go b/src/cmd/internal/quoted/quoted_test.go index a578b147a0bdd..603bd756a2b68 100644 --- a/src/cmd/internal/quoted/quoted_test.go +++ b/src/cmd/internal/quoted/quoted_test.go @@ -33,7 +33,7 @@ func TestSplit(t *testing.T) { {name: "escape", value: `\'`, want: []string{`\'`}}, {name: "quote_unclosed", value: `'a`, wantErr: "unterminated ' string"}, } { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> got, err := Split(test.value) if err != nil { if test.wantErr == "" { @@ -67,7 +67,7 @@ func TestJoin(t *testing.T) { {name: "quote", args: []string{`'a `, "b"}, want: `"'a " b`}, {name: "unquoteable", args: []string{`'"`}, wantErr: "contains both single and double quotes and cannot be quoted"}, } { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> got, err := Join(test.args) if err != nil { if test.wantErr == "" { diff --git a/src/cmd/internal/telemetry/counter/counter.go b/src/cmd/internal/telemetry/counter/counter.go index 4878dc8043081..f60f3227c14b2 100644 --- a/src/cmd/internal/telemetry/counter/counter.go +++ b/src/cmd/internal/telemetry/counter/counter.go @@ -54,7 +54,7 @@ func CountFlagValue(prefix string, flagSet flag.FlagSet, flagName string) { // TODO(matloob): Maybe pass in a list of flagNames if we end up counting // values for more than one? // TODO(matloob): Add this to x/telemetry? - flagSet.Visit(func { f | if f.Name == flagName { + flagSet.Visit(func { f -> if f.Name == flagName { counter.New(prefix + f.Name + ":" + f.Value.String()).Inc() } }) } diff --git a/src/cmd/internal/test2json/test2json_test.go b/src/cmd/internal/test2json/test2json_test.go index 19f7a458e8c25..1e95d20a7ced4 100644 --- a/src/cmd/internal/test2json/test2json_test.go +++ b/src/cmd/internal/test2json/test2json_test.go @@ -27,7 +27,7 @@ func TestGolden(t *testing.T) { } for _, file := range files { name := strings.TrimSuffix(filepath.Base(file), ".test") - t.Run(name, func { t | + t.Run(name, func { t -> orig, err := os.ReadFile(file) if err != nil { t.Fatal(err) @@ -63,7 +63,7 @@ func TestGolden(t *testing.T) { } // Write entire input in bulk. - t.Run("bulk", func { t | + t.Run("bulk", func { t -> buf.Reset() c = NewConverter(&buf, "", 0) in = append([]byte{}, orig...) @@ -73,7 +73,7 @@ func TestGolden(t *testing.T) { }) // In bulk again with \r\n. - t.Run("crlf", func { t | + t.Run("crlf", func { t -> buf.Reset() c = NewConverter(&buf, "", 0) in = bytes.ReplaceAll(orig, []byte("\n"), []byte("\r\n")) @@ -83,7 +83,7 @@ func TestGolden(t *testing.T) { }) // Write 2 bytes at a time on even boundaries. - t.Run("even2", func { t | + t.Run("even2", func { t -> buf.Reset() c = NewConverter(&buf, "", 0) in = append([]byte{}, orig...) @@ -99,7 +99,7 @@ func TestGolden(t *testing.T) { }) // Write 2 bytes at a time on odd boundaries. - t.Run("odd2", func { t | + t.Run("odd2", func { t -> buf.Reset() c = NewConverter(&buf, "", 0) in = append([]byte{}, orig...) @@ -120,7 +120,7 @@ func TestGolden(t *testing.T) { // Test with very small output buffers, to check that // UTF8 sequences are not broken up. for b := 5; b <= 8; b++ { - t.Run(fmt.Sprintf("tiny%d", b), func { t | + t.Run(fmt.Sprintf("tiny%d", b), func { t -> oldIn := inBuffer oldOut := outBuffer defer func() { diff --git a/src/cmd/internal/testdir/testdir_test.go b/src/cmd/internal/testdir/testdir_test.go index ac8f640f26d06..52b3c75d00eca 100644 --- a/src/cmd/internal/testdir/testdir_test.go +++ b/src/cmd/internal/testdir/testdir_test.go @@ -133,7 +133,7 @@ func Test(t *testing.T) { for _, dir := range dirs { for _, goFile := range goFiles(t, dir) { test := test{testCommon: common, dir: dir, goFile: goFile} - t.Run(path.Join(dir, goFile), func { t | + t.Run(path.Join(dir, goFile), func { t -> t.Parallel() test.T = t testError := test.run() @@ -1410,7 +1410,7 @@ func (t test) wantedErrors(file, short string) (errs []wantedError) { t.Fatalf("%s:%d: invalid errchk line: %s", t.goFileName(), lineNum, line) } for _, m := range mm { - rx := lineRx.ReplaceAllStringFunc(m[1], func { m | + rx := lineRx.ReplaceAllStringFunc(m[1], func { m -> n := lineNum if strings.HasPrefix(m, "LINE+") { delta, _ := strconv.Atoi(m[5:]) @@ -1535,7 +1535,7 @@ func (a asmChecks) Envs() []buildEnv { for e := range a { envs = append(envs, e) } - sort.Slice(envs, func { i, j | return string(envs[i]) < string(envs[j]) }) + sort.Slice(envs, func { i, j -> return string(envs[i]) < string(envs[j]) }) return envs } @@ -1707,7 +1707,7 @@ func (t test) asmCheck(outStr string, fn string, env buildEnv, fullops map[strin lastFunction := -1 var errbuf bytes.Buffer fmt.Fprintln(&errbuf) - sort.Slice(failed, func { i, j | return failed[i].line < failed[j].line }) + sort.Slice(failed, func { i, j -> return failed[i].line < failed[j].line }) for _, o := range failed { // Dump the function in which this opcode check was supposed to // pass but failed. @@ -1790,7 +1790,7 @@ func overlayDir(dstRoot, srcRoot string) error { return err } - return filepath.WalkDir(srcRoot, func { srcPath, d, err | + return filepath.WalkDir(srcRoot, func { srcPath, d, err -> if err != nil || srcPath == srcRoot { return err } diff --git a/src/cmd/link/cgo_test.go b/src/cmd/link/cgo_test.go index 26fe3fe820712..b65a6c0ead6fa 100644 --- a/src/cmd/link/cgo_test.go +++ b/src/cmd/link/cgo_test.go @@ -37,7 +37,7 @@ func TestCGOLTO(t *testing.T) { cgoCflags := goEnv("CGO_CFLAGS") for test := 0; test < 2; test++ { - t.Run(strconv.Itoa(test), func { t | testCGOLTO(t, cc, cgoCflags, test) }) + t.Run(strconv.Itoa(test), func { t -> testCGOLTO(t, cc, cgoCflags, test) }) } } diff --git a/src/cmd/link/dwarf_test.go b/src/cmd/link/dwarf_test.go index c6eb8d6d23858..d1341c6c189c5 100644 --- a/src/cmd/link/dwarf_test.go +++ b/src/cmd/link/dwarf_test.go @@ -79,7 +79,7 @@ func testDWARF(t *testing.T, buildmode string, expectDWARF bool, env ...string) } } - t.Run(prog, func { t | + t.Run(prog, func { t -> t.Parallel() tmpDir := t.TempDir() @@ -196,7 +196,7 @@ func TestDWARF(t *testing.T) { if !platform.BuildModeSupported(runtime.Compiler, "c-archive", runtime.GOOS, runtime.GOARCH) { t.Skipf("skipping c-archive test on unsupported platform %s-%s", runtime.GOOS, runtime.GOARCH) } - t.Run("c-archive", func { t | testDWARF(t, "c-archive", true) }) + t.Run("c-archive", func { t -> testDWARF(t, "c-archive", true) }) } } @@ -222,7 +222,7 @@ func TestDWARFiOS(t *testing.T) { } cc := "CC=" + runtime.GOROOT() + "/misc/ios/clangwrap.sh" // iOS doesn't allow unmapped segments, so iOS executables don't have DWARF. - t.Run("exe", func { t | testDWARF(t, "", false, cc, "CGO_ENABLED=1", "GOOS=ios", "GOARCH=arm64") }) + t.Run("exe", func { t -> testDWARF(t, "", false, cc, "CGO_ENABLED=1", "GOOS=ios", "GOARCH=arm64") }) // However, c-archive iOS objects have embedded DWARF. - t.Run("c-archive", func { t | testDWARF(t, "c-archive", true, cc, "CGO_ENABLED=1", "GOOS=ios", "GOARCH=arm64") }) + t.Run("c-archive", func { t -> testDWARF(t, "c-archive", true, cc, "CGO_ENABLED=1", "GOOS=ios", "GOARCH=arm64") }) } diff --git a/src/cmd/link/elf_test.go b/src/cmd/link/elf_test.go index 3c106c0121070..37ecee8a4d9f2 100644 --- a/src/cmd/link/elf_test.go +++ b/src/cmd/link/elf_test.go @@ -350,7 +350,7 @@ func TestPIESize(t *testing.T) { } else { name += "internal" } - t.Run(name, func { t | + t.Run(name, func { t -> t.Parallel() dir := t.TempDir() diff --git a/src/cmd/link/internal/ld/asmb.go b/src/cmd/link/internal/ld/asmb.go index f40df3143fc24..80a9656f3fc41 100644 --- a/src/cmd/link/internal/ld/asmb.go +++ b/src/cmd/link/internal/ld/asmb.go @@ -192,7 +192,7 @@ func relocSectFn(ctxt *Link, relocSect func(*Link, *OutBuf, *sym.Section, []load if ctxt.Out.isMmapped() { // Write sections in parallel. sem = make(chan int, 2*runtime.GOMAXPROCS(0)) - fn = func { ctxt, sect, syms | + fn = func { ctxt, sect, syms -> wg.Add(1) sem <- 1 out, err := ctxt.Out.View(sect.Reloff) @@ -207,7 +207,7 @@ func relocSectFn(ctxt *Link, relocSect func(*Link, *OutBuf, *sym.Section, []load } } else { // We cannot Mmap. Write sequentially. - fn = func { ctxt, sect, syms | relocSect(ctxt, ctxt.Out, sect, syms) } + fn = func { ctxt, sect, syms -> relocSect(ctxt, ctxt.Out, sect, syms) } } return fn, &wg } diff --git a/src/cmd/link/internal/ld/data.go b/src/cmd/link/internal/ld/data.go index ce5c697743653..5a3ee786379b3 100644 --- a/src/cmd/link/internal/ld/data.go +++ b/src/cmd/link/internal/ld/data.go @@ -2058,7 +2058,7 @@ func (state *dodataState) allocateDataSections(ctxt *Link) { } if !ctxt.IsDarwin() { // We don't need the special names on darwin. - genrelrosecname = func { suffix | return ".data.rel.ro" + suffix } + genrelrosecname = func { suffix -> return ".data.rel.ro" + suffix } } relroReadOnly := []sym.SymKind{} @@ -2270,7 +2270,7 @@ func (state *dodataState) dodataSect(ctxt *Link, symn sym.SymKind, syms []loader // Perform the sort. if symn != sym.SPCLNTAB { - sort.Slice(sl, func { i, j | + sort.Slice(sl, func { i, j -> si, sj := sl[i].sym, sl[j].sym isz, jsz := sl[i].sz, sl[j].sz switch { @@ -2415,7 +2415,7 @@ func (ctxt *Link) textaddress() { i++ } textp = textp[i:] - r.Shuffle(len(textp), func { i, j | textp[i], textp[j] = textp[j], textp[i] }) + r.Shuffle(len(textp), func { i, j -> textp[i], textp[j] = textp[j], textp[i] }) } text := ctxt.xdefine("runtime.text", sym.STEXT, 0) diff --git a/src/cmd/link/internal/ld/deadcode_test.go b/src/cmd/link/internal/ld/deadcode_test.go index 7ddb99fb4291a..33620fb67ddd8 100644 --- a/src/cmd/link/internal/ld/deadcode_test.go +++ b/src/cmd/link/internal/ld/deadcode_test.go @@ -35,7 +35,7 @@ func TestDeadcode(t *testing.T) { } for _, test := range tests { test := test - t.Run(test.src, func { t | + t.Run(test.src, func { t -> t.Parallel() src := filepath.Join("testdata", "deadcode", test.src+".go") exe := filepath.Join(tmpdir, test.src+".exe") diff --git a/src/cmd/link/internal/ld/dwarf.go b/src/cmd/link/internal/ld/dwarf.go index 759c2f43f09b2..94a93ab8990d3 100644 --- a/src/cmd/link/internal/ld/dwarf.go +++ b/src/cmd/link/internal/ld/dwarf.go @@ -895,7 +895,7 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) { // Construct type to represent an array of BucketSize keys keyname := d.nameFromDIESym(keytype) - dwhks := d.mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]key", keyname, "", func { dwhk | + dwhks := d.mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]key", keyname, "", func { dwhk -> newattr(dwhk, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, abi.MapBucketCount*keysize, 0) t := keytype if indirectKey { @@ -909,7 +909,7 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) { // Construct type to represent an array of BucketSize values valname := d.nameFromDIESym(valtype) - dwhvs := d.mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]val", valname, "", func { dwhv | + dwhvs := d.mkinternaltype(ctxt, dwarf.DW_ABRV_ARRAYTYPE, "[]val", valname, "", func { dwhv -> newattr(dwhv, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, abi.MapBucketCount*valsize, 0) t := valtype if indirectVal { @@ -922,7 +922,7 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) { }) // Construct bucket - dwhbs := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "bucket", keyname, valname, func { dwhb | + dwhbs := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "bucket", keyname, valname, func { dwhb -> // Copy over all fields except the field "data" from the generic // bucket. "data" will be replaced with keys/values below. d.copychildrenexcept(ctxt, dwhb, bucket, findchild(bucket, "data")) @@ -946,7 +946,7 @@ func (d *dwctxt) synthesizemaptypes(ctxt *Link, die *dwarf.DWDie) { }) // Construct hash - dwhs := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "hash", keyname, valname, func { dwh | + dwhs := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "hash", keyname, valname, func { dwh -> d.copychildren(ctxt, dwh, hash) d.substitutetype(dwh, "buckets", d.defptrto(dwhbs)) d.substitutetype(dwh, "oldbuckets", d.defptrto(dwhbs)) @@ -978,14 +978,14 @@ func (d *dwctxt) synthesizechantypes(ctxt *Link, die *dwarf.DWDie) { elemtype := d.walksymtypedef(d.defgotype(d.lookupOrDiag(tname))) // sudog - dwss := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "sudog", elemname, "", func { dws | + dwss := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "sudog", elemname, "", func { dws -> d.copychildren(ctxt, dws, sudog) d.substitutetype(dws, "elem", d.defptrto(elemtype)) newattr(dws, dwarf.DW_AT_byte_size, dwarf.DW_CLS_CONSTANT, int64(sudogsize), nil) }) // waitq - dwws := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "waitq", elemname, "", func { dww | + dwws := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "waitq", elemname, "", func { dww -> d.copychildren(ctxt, dww, waitq) d.substitutetype(dww, "first", d.defptrto(dwss)) @@ -994,7 +994,7 @@ func (d *dwctxt) synthesizechantypes(ctxt *Link, die *dwarf.DWDie) { }) // hchan - dwhs := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "hchan", elemname, "", func { dwh | + dwhs := d.mkinternaltype(ctxt, dwarf.DW_ABRV_STRUCTTYPE, "hchan", elemname, "", func { dwh -> d.copychildren(ctxt, dwh, hchan) d.substitutetype(dwh, "recvq", dwws) d.substitutetype(dwh, "sendq", dwws) diff --git a/src/cmd/link/internal/ld/dwarf_test.go b/src/cmd/link/internal/ld/dwarf_test.go index e39c4cb77395d..e2e0ac522dfff 100644 --- a/src/cmd/link/internal/ld/dwarf_test.go +++ b/src/cmd/link/internal/ld/dwarf_test.go @@ -406,7 +406,7 @@ func main() {} } for _, tc := range tests { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() d, ex := gobuildAndExamine(t, tc.prog, NoOpt) @@ -471,7 +471,7 @@ func main() { } for _, tc := range tests { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() _, ex := gobuildAndExamine(t, tc.prog, NoOpt) @@ -553,7 +553,7 @@ func main() { } for _, tc := range tests { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() // Note: this is a build with "-l=4", as opposed to "-l -N". The @@ -2014,7 +2014,7 @@ func TestZeroSizedVariable(t *testing.T) { for _, opt := range []string{NoOpt, DefaultOpt} { opt := opt - t.Run(opt, func { t | + t.Run(opt, func { t -> _, ex := gobuildAndExamine(t, zeroSizedVarProg, opt) // Locate the main.zeroSizedVariable DIE diff --git a/src/cmd/link/internal/ld/elf_test.go b/src/cmd/link/internal/ld/elf_test.go index 324d98309f8e6..23f350ea50b66 100644 --- a/src/cmd/link/internal/ld/elf_test.go +++ b/src/cmd/link/internal/ld/elf_test.go @@ -282,7 +282,7 @@ func TestElfBindNow(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> if test.mustInternalLink { testenv.MustInternalLink(t, test.mustHaveCGO) } @@ -519,7 +519,7 @@ func TestRelroSectionOverlapIssue67261(t *testing.T) { } // Sort by address - sort.SliceStable(secs, func { i, j | return secs[i].Addr < secs[j].Addr }) + sort.SliceStable(secs, func { i, j -> return secs[i].Addr < secs[j].Addr }) // Check to make sure we don't have any overlaps. foundOverlap := false diff --git a/src/cmd/link/internal/ld/go_test.go b/src/cmd/link/internal/ld/go_test.go index 76cf2ac7a4db0..6ce77068d4828 100644 --- a/src/cmd/link/internal/ld/go_test.go +++ b/src/cmd/link/internal/ld/go_test.go @@ -66,7 +66,7 @@ func TestDedupLibrariesOpenBSD(t *testing.T) { } for _, test := range tests { - t.Run("dedup", func { t | + t.Run("dedup", func { t -> got := dedupLibraries(ctxt, test.libs) if !reflect.DeepEqual(got, test.want) { t.Errorf("dedupLibraries(%v) = %v, want %v", test.libs, got, test.want) diff --git a/src/cmd/link/internal/ld/inittask.go b/src/cmd/link/internal/ld/inittask.go index 1b17f4bea2d39..8e674459b061f 100644 --- a/src/cmd/link/internal/ld/inittask.go +++ b/src/cmd/link/internal/ld/inittask.go @@ -146,7 +146,7 @@ func (ctxt *Link) inittaskSym(rootNames []string, symName string) loader.Sym { } // Sort edges so we can look them up by edge destination. - sort.Slice(edges, func { i, j | return edges[i].to < edges[j].to }) + sort.Slice(edges, func { i, j -> return edges[i].to < edges[j].to }) // Figure out the schedule. sched := ldr.MakeSymbolBuilder(symName) @@ -165,8 +165,8 @@ func (ctxt *Link) inittaskSym(rootNames []string, symName string) loader.Sym { } // Find all incoming edges into s. - a := sort.Search(len(edges), func { i | return edges[i].to >= s }) - b := sort.Search(len(edges), func { i | return edges[i].to > s }) + a := sort.Search(len(edges), func { i -> return edges[i].to >= s }) + b := sort.Search(len(edges), func { i -> return edges[i].to > s }) // Decrement the import count for all packages that import s. // If the count reaches 0, that package is now ready to schedule. diff --git a/src/cmd/link/internal/ld/ld_test.go b/src/cmd/link/internal/ld/ld_test.go index 9732d5d7f474e..549bbb2892074 100644 --- a/src/cmd/link/internal/ld/ld_test.go +++ b/src/cmd/link/internal/ld/ld_test.go @@ -188,8 +188,8 @@ func TestWindowsBuildmodeCSharedASLR(t *testing.T) { testenv.MustHaveCGO(t) - t.Run("aslr", func { t | testWindowsBuildmodeCSharedASLR(t, true) }) - t.Run("no-aslr", func { t | testWindowsBuildmodeCSharedASLR(t, false) }) + t.Run("aslr", func { t -> testWindowsBuildmodeCSharedASLR(t, true) }) + t.Run("no-aslr", func { t -> testWindowsBuildmodeCSharedASLR(t, false) }) } func testWindowsBuildmodeCSharedASLR(t *testing.T, useASLR bool) { @@ -348,7 +348,7 @@ func main() { } for _, tt := range tests { tt := tt - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> t.Parallel() tempDir := t.TempDir() src := filepath.Join(tempDir, "x.go") diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index c2d0a2ade4457..c356035aad194 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -530,7 +530,7 @@ func (ctxt *Link) loadlib() { log.Fatalf("invalid -strictdups flag value %d", *FlagStrictDups) } ctxt.loader = loader.NewLoader(flags, &ctxt.ErrorReporter.ErrorReporter) - ctxt.ErrorReporter.SymName = func { s | return ctxt.loader.SymName(s) } + ctxt.ErrorReporter.SymName = func { s -> return ctxt.loader.SymName(s) } // ctxt.Library grows during the loop, so not a range loop. i := 0 @@ -1730,7 +1730,7 @@ func (ctxt *Link) hostlink() { argv = append(argv, "-rdynamic") } else { var exports []string - ctxt.loader.ForAllCgoExportDynamic(func { s | exports = append(exports, "-Wl,--export-dynamic-symbol="+ctxt.loader.SymExtname(s)) }) + ctxt.loader.ForAllCgoExportDynamic(func { s -> exports = append(exports, "-Wl,--export-dynamic-symbol="+ctxt.loader.SymExtname(s)) }) sort.Strings(exports) argv = append(argv, exports...) } @@ -2048,13 +2048,13 @@ func (ctxt *Link) hostlink() { // Skip combining if `dsymutil` didn't generate a file. See #11994. if _, err := os.Stat(dsym); err == nil { updateMachoOutFile("combining dwarf", - func { ctxt, exef, exem, outexe | return machoCombineDwarf(ctxt, exef, exem, dsym, outexe) }) + func { ctxt, exef, exem, outexe -> return machoCombineDwarf(ctxt, exef, exem, dsym, outexe) }) uuidUpdated = true } } if ctxt.IsDarwin() && !uuidUpdated && *flagBuildid != "" { updateMachoOutFile("rewriting uuid", - func { ctxt, exef, exem, outexe | return machoRewriteUuid(ctxt, exef, exem, outexe) }) + func { ctxt, exef, exem, outexe -> return machoRewriteUuid(ctxt, exef, exem, outexe) }) } if ctxt.NeedCodeSign() { err := machoCodeSign(ctxt, *flagOutfile) diff --git a/src/cmd/link/internal/ld/macho.go b/src/cmd/link/internal/ld/macho.go index 326d6a5ea064f..0c0ddad73d802 100644 --- a/src/cmd/link/internal/ld/macho.go +++ b/src/cmd/link/internal/ld/macho.go @@ -1022,7 +1022,7 @@ func machosymorder(ctxt *Link) { } } collectmachosyms(ctxt) - sort.Slice(sortsym[:nsortsym], func { i, j | + sort.Slice(sortsym[:nsortsym], func { i, j -> s1 := sortsym[i] s2 := sortsym[j] k1 := symkind(ldr, s1) diff --git a/src/cmd/link/internal/ld/main.go b/src/cmd/link/internal/ld/main.go index 0607c14ee0a29..068516f6ecc7a 100644 --- a/src/cmd/link/internal/ld/main.go +++ b/src/cmd/link/internal/ld/main.go @@ -197,9 +197,9 @@ func Main(arch *sys.Arch, theArch Arch) { flag.Var(&ctxt.LinkMode, "linkmode", "set link `mode`") flag.Var(&ctxt.BuildMode, "buildmode", "set build `mode`") flag.BoolVar(&ctxt.compressDWARF, "compressdwarf", true, "compress DWARF if possible") - objabi.Flagfn1("L", "add specified `directory` to library path", func { a | Lflag(ctxt, a) }) + objabi.Flagfn1("L", "add specified `directory` to library path", func { a -> Lflag(ctxt, a) }) objabi.AddVersionFlag() // -V - objabi.Flagfn1("X", "add string value `definition` of the form importpath.name=value", func { s | addstrdata1(ctxt, s) }) + objabi.Flagfn1("X", "add string value `definition` of the form importpath.name=value", func { s -> addstrdata1(ctxt, s) }) objabi.Flagcount("v", "print link trace", &ctxt.Debugvlog) objabi.Flagfn1("importcfg", "read import configuration from `file`", ctxt.readImportCfg) diff --git a/src/cmd/link/internal/ld/pcln.go b/src/cmd/link/internal/ld/pcln.go index 0089f5b71acc9..bbd3ed528f40b 100644 --- a/src/cmd/link/internal/ld/pcln.go +++ b/src/cmd/link/internal/ld/pcln.go @@ -311,7 +311,7 @@ func (state *pclntab) generateFuncnametab(ctxt *Link, funcs []loader.Sym) map[lo // Loop through the CUs, and calculate the size needed. var size int64 - walkFuncs(ctxt, funcs, func { s | + walkFuncs(ctxt, funcs, func { s -> nameOffsets[s] = uint32(size) size += int64(len(ctxt.loader.SymName(s)) + 1) // NULL terminate }) @@ -386,7 +386,7 @@ func (state *pclntab) generateFilenameTabs(ctxt *Link, compUnits []*sym.Compilat // file index we've seen per CU so we can calculate how large the // CU->global table needs to be. var fileSize int64 - walkFilenames(ctxt, funcs, func { cu, i | + walkFilenames(ctxt, funcs, func { cu, i -> // Note we use the raw filename for lookup, but use the expanded filename // when we save the size. filename := cu.FileTable[i] diff --git a/src/cmd/link/internal/ld/pe.go b/src/cmd/link/internal/ld/pe.go index 0a4be66597eb9..e049a2c6b1e3e 100644 --- a/src/cmd/link/internal/ld/pe.go +++ b/src/cmd/link/internal/ld/pe.go @@ -1396,7 +1396,7 @@ func initdynexport(ctxt *Link) { dexport = append(dexport, s) } - sort.Slice(dexport, func { i, j | return ldr.SymExtname(dexport[i]) < ldr.SymExtname(dexport[j]) }) + sort.Slice(dexport, func { i, j -> return ldr.SymExtname(dexport[i]) < ldr.SymExtname(dexport[j]) }) } func addexports(ctxt *Link) { diff --git a/src/cmd/link/internal/ld/stackcheck.go b/src/cmd/link/internal/ld/stackcheck.go index 1df93f51a2843..985b468c649ef 100644 --- a/src/cmd/link/internal/ld/stackcheck.go +++ b/src/cmd/link/internal/ld/stackcheck.go @@ -344,7 +344,7 @@ func (sc *stackCheck) findRoots() []loader.Sym { for k := range nodes { roots = append(roots, k) } - sort.Slice(roots, func { i, j | + sort.Slice(roots, func { i, j -> h1, h2 := sc.height[roots[i]], sc.height[roots[j]] if h1 != h2 { return h1 > h2 diff --git a/src/cmd/link/internal/ld/xcoff.go b/src/cmd/link/internal/ld/xcoff.go index 93b0bf244cb13..79fac77a32a5b 100644 --- a/src/cmd/link/internal/ld/xcoff.go +++ b/src/cmd/link/internal/ld/xcoff.go @@ -1405,7 +1405,7 @@ func (f *xcoffFile) writeLdrScn(ctxt *Link, globalOff uint64) { /* Reloc */ // Ensure deterministic order - sort.Slice(f.loaderReloc, func { i, j | + sort.Slice(f.loaderReloc, func { i, j -> r1, r2 := f.loaderReloc[i], f.loaderReloc[j] if r1.sym != r2.sym { return r1.sym < r2.sym @@ -1704,7 +1704,7 @@ func (f *xcoffFile) emitRelocations(ctxt *Link, fileoff int64) { for i := 0; i < relocs.Count(); i++ { sorted[i] = i } - sort.Slice(sorted, func { i, j | return relocs.At(sorted[i]).Off() < relocs.At(sorted[j]).Off() }) + sort.Slice(sorted, func { i, j -> return relocs.At(sorted[i]).Off() < relocs.At(sorted[j]).Off() }) for _, ri := range sorted { r := relocs.At(ri) diff --git a/src/cmd/link/internal/loader/loader.go b/src/cmd/link/internal/loader/loader.go index 29fb19c75479f..b765e43b67ecf 100644 --- a/src/cmd/link/internal/loader/loader.go +++ b/src/cmd/link/internal/loader/loader.go @@ -389,14 +389,14 @@ func (st *loadState) addSym(name string, ver int, r *oReader, li uint32, kind in s, existed := st.hashed64Syms[h64] return s, existed } - addToHashMap = func { ss | st.hashed64Syms[h64] = ss } + addToHashMap = func { ss -> st.hashed64Syms[h64] = ss } } else { checkHash = func { h = r.Hash(li - uint32(r.ndef+r.nhashed64def)) s, existed := st.hashedSyms[*h] return s, existed } - addToHashMap = func { ss | st.hashedSyms[*h] = ss } + addToHashMap = func { ss -> st.hashedSyms[*h] = ss } } siz := osym.Siz() if s, existed := checkHash(); existed { @@ -1513,7 +1513,7 @@ func (l *Loader) DynidSyms() []Sym { for s := range l.dynid { sl = append(sl, s) } - sort.Slice(sl, func { i, j | return sl[i] < sl[j] }) + sort.Slice(sl, func { i, j -> return sl[i] < sl[j] }) return sl } @@ -1842,7 +1842,7 @@ func (l *Loader) SortSub(s Sym) Sym { // SortSyms sorts a list of symbols by their value. func (l *Loader) SortSyms(ss []Sym) { - sort.SliceStable(ss, func { i, j | return l.SymValue(ss[i]) < l.SymValue(ss[j]) }) + sort.SliceStable(ss, func { i, j -> return l.SymValue(ss[i]) < l.SymValue(ss[j]) }) } // Insure that reachable bitmap and its siblings have enough size. diff --git a/src/cmd/link/internal/loadpe/seh.go b/src/cmd/link/internal/loadpe/seh.go index 480b4759deed3..f72eb739eeee3 100644 --- a/src/cmd/link/internal/loadpe/seh.go +++ b/src/cmd/link/internal/loadpe/seh.go @@ -92,7 +92,7 @@ func findHandlerInXDataAMD64(ldr *loader.Loader, xsym sym.LoaderSym, add int64) targetOff := add + unwStaticDataSize + unwCodeSize*int64(codes) xrels := ldr.Relocs(xsym) xrelsCount := xrels.Count() - idx := sort.Search(xrelsCount, func { i | return int64(xrels.At(i).Off()) >= targetOff }) + idx := sort.Search(xrelsCount, func { i -> return int64(xrels.At(i).Off()) >= targetOff }) if idx == xrelsCount { return 0 } diff --git a/src/cmd/link/internal/riscv64/asm.go b/src/cmd/link/internal/riscv64/asm.go index 9ee96ad1b4a03..035f700589a28 100644 --- a/src/cmd/link/internal/riscv64/asm.go +++ b/src/cmd/link/internal/riscv64/asm.go @@ -28,7 +28,7 @@ func findHI20Reloc(ldr *loader.Loader, s loader.Sym, val int64) *loader.Reloc { return nil } relocs := ldr.Relocs(outer) - start := sort.Search(relocs.Count(), func { i | return ldr.SymValue(outer)+int64(relocs.At(i).Off()) >= val }) + start := sort.Search(relocs.Count(), func { i -> return ldr.SymValue(outer)+int64(relocs.At(i).Off()) >= val }) for idx := start; idx < relocs.Count(); idx++ { r := relocs.At(idx) if ldr.SymValue(outer)+int64(r.Off()) != val { @@ -202,7 +202,7 @@ func genSymsLate(ctxt *ld.Link, ldr *loader.Loader) { } func findHI20Symbol(ctxt *ld.Link, ldr *loader.Loader, val int64) loader.Sym { - idx := sort.Search(len(ctxt.Textp), func { i | return ldr.SymValue(ctxt.Textp[i]) >= val }) + idx := sort.Search(len(ctxt.Textp), func { i -> return ldr.SymValue(ctxt.Textp[i]) >= val }) if idx >= len(ctxt.Textp) { return 0 } diff --git a/src/cmd/link/link_test.go b/src/cmd/link/link_test.go index cb39ffe209569..39be0296d1187 100644 --- a/src/cmd/link/link_test.go +++ b/src/cmd/link/link_test.go @@ -1444,7 +1444,7 @@ func TestCheckLinkname(t *testing.T) { } for _, test := range tests { test := test - t.Run(test.src, func { t | + t.Run(test.src, func { t -> t.Parallel() src := filepath.Join("testdata", "linkname", test.src) exe := filepath.Join(tmpdir, test.src+".exe") diff --git a/src/cmd/nm/nm.go b/src/cmd/nm/nm.go index b43b433fcce5f..dcd752829b96a 100644 --- a/src/cmd/nm/nm.go +++ b/src/cmd/nm/nm.go @@ -129,11 +129,11 @@ func nm(file string) { switch *sortOrder { case "address": - sort.Slice(syms, func { i, j | return syms[i].Addr < syms[j].Addr }) + sort.Slice(syms, func { i, j -> return syms[i].Addr < syms[j].Addr }) case "name": - sort.Slice(syms, func { i, j | return syms[i].Name < syms[j].Name }) + sort.Slice(syms, func { i, j -> return syms[i].Name < syms[j].Name }) case "size": - sort.Slice(syms, func { i, j | return syms[i].Size > syms[j].Size }) + sort.Slice(syms, func { i, j -> return syms[i].Size > syms[j].Size }) } for _, sym := range syms { diff --git a/src/cmd/pprof/pprof.go b/src/cmd/pprof/pprof.go index ddac6adb6502f..6b3bc6353c382 100644 --- a/src/cmd/pprof/pprof.go +++ b/src/cmd/pprof/pprof.go @@ -196,7 +196,7 @@ func (t *objTool) Disasm(file string, start, end uint64, intelSyntax bool) ([]dr return nil, err } var asm []driver.Inst - d.Decode(start, end, nil, false, func { pc, size, file, line, text | asm = append(asm, driver.Inst{Addr: pc, File: file, Line: line, Text: text}) }) + d.Decode(start, end, nil, false, func { pc, size, file, line, text -> asm = append(asm, driver.Inst{Addr: pc, File: file, Line: line, Text: text}) }) return asm, nil } diff --git a/src/cmd/trace/goroutinegen.go b/src/cmd/trace/goroutinegen.go index 3cda940b2e72d..222fb17593e66 100644 --- a/src/cmd/trace/goroutinegen.go +++ b/src/cmd/trace/goroutinegen.go @@ -34,7 +34,7 @@ func newGoroutineGenerator(ctx *traceContext, focus trace.GoID, filter map[trace // Enable a filter on the emitter. if filter != nil { - ctx.SetResourceFilter(func { resource | + ctx.SetResourceFilter(func { resource -> _, ok := filter[trace.GoID(resource)] return ok }) diff --git a/src/cmd/trace/goroutines.go b/src/cmd/trace/goroutines.go index 39e5196d603ef..ec73641c880c7 100644 --- a/src/cmd/trace/goroutines.go +++ b/src/cmd/trace/goroutines.go @@ -42,7 +42,7 @@ func GoroutinesHandlerFunc(summaries map[trace.GoID]*trace.GoroutineSummary) htt for _, group := range groupsByName { groups = append(groups, group) } - slices.SortFunc(groups, func { a, b | return cmp.Compare(b.ExecTime, a.ExecTime) }) + slices.SortFunc(groups, func { a, b -> return cmp.Compare(b.ExecTime, a.ExecTime) }) w.Header().Set("Content-Type", "text/html;charset=utf-8") if err := templGoroutines.Execute(w, groups); err != nil { log.Printf("failed to execute template: %v", err) @@ -147,10 +147,10 @@ func GoroutineHandler(summaries map[trace.GoID]*trace.GoroutineSummary) http.Han // Sort. sortBy := r.FormValue("sortby") if _, ok := validNonOverlappingStats[sortBy]; ok { - slices.SortFunc(goroutines, func { a, b | return cmp.Compare(b.NonOverlappingStats[sortBy], a.NonOverlappingStats[sortBy]) }) + slices.SortFunc(goroutines, func { a, b -> return cmp.Compare(b.NonOverlappingStats[sortBy], a.NonOverlappingStats[sortBy]) }) } else { // Sort by total time by default. - slices.SortFunc(goroutines, func { a, b | return cmp.Compare(b.TotalTime, a.TotalTime) }) + slices.SortFunc(goroutines, func { a, b -> return cmp.Compare(b.TotalTime, a.TotalTime) }) } // Write down all the non-overlapping stats and sort them. @@ -158,7 +158,7 @@ func GoroutineHandler(summaries map[trace.GoID]*trace.GoroutineSummary) http.Han for name := range validNonOverlappingStats { allNonOverlappingStats = append(allNonOverlappingStats, name) } - slices.SortFunc(allNonOverlappingStats, func { a, b | + slices.SortFunc(allNonOverlappingStats, func { a, b -> if a == b { return 0 } diff --git a/src/cmd/trace/gstate.go b/src/cmd/trace/gstate.go index c17322afd6a27..394b845ee6426 100644 --- a/src/cmd/trace/gstate.go +++ b/src/cmd/trace/gstate.go @@ -364,7 +364,7 @@ func (gs *gState[R]) rangeEnd(ts trace.Time, name string, stack trace.Stack, ctx func lastFunc(s trace.Stack) string { var last trace.StackFrame - s.Frames(func { f | + s.Frames(func { f -> last = f return true }) diff --git a/src/cmd/trace/jsontrace.go b/src/cmd/trace/jsontrace.go index a2998512aa57f..8be469fcf3e1d 100644 --- a/src/cmd/trace/jsontrace.go +++ b/src/cmd/trace/jsontrace.go @@ -18,7 +18,7 @@ import ( ) func JSONTraceHandler(parsed *parsedTrace) http.Handler { - return http.HandlerFunc(func { w, r | + return http.HandlerFunc(func { w, r -> opts := defaultGenOpts() switch r.FormValue("view") { @@ -177,7 +177,7 @@ func (opts *genOpts) setTask(parsed *parsedTrace, task *trace.UserTaskSummary) { opts.endTime = parsed.endTime().Sub(parsed.startTime()) } opts.tasks = task.Descendents() - slices.SortStableFunc(opts.tasks, func { a, b | + slices.SortStableFunc(opts.tasks, func { a, b -> aStart, bStart := parsed.startTime(), parsed.startTime() if a.Start != nil { aStart = a.Start.Time() diff --git a/src/cmd/trace/jsontrace_test.go b/src/cmd/trace/jsontrace_test.go index 1a82f9c91fa9f..eca951d5cc56c 100644 --- a/src/cmd/trace/jsontrace_test.go +++ b/src/cmd/trace/jsontrace_test.go @@ -28,7 +28,7 @@ func TestJSONTraceHandler(t *testing.T) { t.Fatalf("discovering tests: %v", err) } for _, testPath := range testPaths { - t.Run(filepath.Base(testPath), func { t | + t.Run(filepath.Base(testPath), func { t -> parsed := getTestTrace(t, testPath) data := recordJSONTraceHandlerResponse(t, parsed) // TODO(mknyszek): Check that there's one at most goroutine per proc at any given time. diff --git a/src/cmd/trace/pprof.go b/src/cmd/trace/pprof.go index 62d369ac2938b..40d726e42edf5 100644 --- a/src/cmd/trace/pprof.go +++ b/src/cmd/trace/pprof.go @@ -84,7 +84,7 @@ func pprofMatchingRegions(filter *regionFilter, t *parsedTrace) (map[trace.GoID] // consider only the outermost regions, // first, we sort based on the start time // and then scan through to select only the outermost regions. - slices.SortFunc(intervals, func { a, b | + slices.SortFunc(intervals, func { a, b -> if c := cmp.Compare(a.start, b.start); c != 0 { return c } @@ -111,13 +111,13 @@ type computePprofFunc func(gToIntervals map[trace.GoID][]interval, events []trac // computePprofIO returns a computePprofFunc that generates IO pprof-like profile (time spent in // IO wait, currently only network blocking event). func computePprofIO() computePprofFunc { - return makeComputePprofFunc(trace.GoWaiting, func { reason | return reason == "network" }) + return makeComputePprofFunc(trace.GoWaiting, func { reason -> return reason == "network" }) } // computePprofBlock returns a computePprofFunc that generates blocking pprof-like profile // (time spent blocked on synchronization primitives). func computePprofBlock() computePprofFunc { - return makeComputePprofFunc(trace.GoWaiting, func { reason | + return makeComputePprofFunc(trace.GoWaiting, func { reason -> return strings.Contains(reason, "chan") || strings.Contains(reason, "sync") || strings.Contains(reason, "select") }) } @@ -125,13 +125,13 @@ func computePprofBlock() computePprofFunc { // computePprofSyscall returns a computePprofFunc that generates a syscall pprof-like // profile (time spent in syscalls). func computePprofSyscall() computePprofFunc { - return makeComputePprofFunc(trace.GoSyscall, func { _ | return true }) + return makeComputePprofFunc(trace.GoSyscall, func { _ -> return true }) } // computePprofSched returns a computePprofFunc that generates a scheduler latency pprof-like profile // (time between a goroutine become runnable and actually scheduled for execution). func computePprofSched() computePprofFunc { - return makeComputePprofFunc(trace.GoRunnable, func { _ | return true }) + return makeComputePprofFunc(trace.GoRunnable, func { _ -> return true }) } // makeComputePprofFunc returns a computePprofFunc that generates a profile of time goroutines spend @@ -301,7 +301,7 @@ func (m *stackMap) profile() []traceviewer.ProfileRecord { for stack, record := range m.stacks { rec := *record i := 0 - stack.Frames(func { frame | + stack.Frames(func { frame -> rec.Stack = append(rec.Stack, &trace.Frame{ PC: frame.PC, Fn: frame.Func, @@ -321,7 +321,7 @@ func (m *stackMap) profile() []traceviewer.ProfileRecord { // pcsForStack extracts the first pprofMaxStack PCs from stack into pcs. func pcsForStack(stack trace.Stack, pcs *[pprofMaxStack]uint64) { i := 0 - stack.Frames(func { frame | + stack.Frames(func { frame -> pcs[i] = frame.PC i++ return i < len(pcs) diff --git a/src/cmd/trace/regions.go b/src/cmd/trace/regions.go index d838413d77eb9..651bab1328701 100644 --- a/src/cmd/trace/regions.go +++ b/src/cmd/trace/regions.go @@ -40,7 +40,7 @@ func UserRegionsHandlerFunc(t *parsedTrace) http.HandlerFunc { for _, stats := range summary { userRegions = append(userRegions, stats) } - slices.SortFunc(userRegions, func { a, b | + slices.SortFunc(userRegions, func { a, b -> if c := cmp.Compare(a.Type, b.Type); c != 0 { return c } @@ -72,7 +72,7 @@ func fingerprintRegion(r *trace.UserRegionSummary) regionFingerprint { func regionTopStackFrame(r *trace.UserRegionSummary) trace.StackFrame { var frame trace.StackFrame if r.Start != nil && r.Start.Stack() != trace.NoStack { - r.Start.Stack().Frames(func { f | + r.Start.Stack().Frames(func { f -> frame = f return false }) @@ -203,10 +203,10 @@ func UserRegionHandlerFunc(t *parsedTrace) http.HandlerFunc { // Sort. sortBy := r.FormValue("sortby") if _, ok := validNonOverlappingStats[sortBy]; ok { - slices.SortFunc(regions, func { a, b | return cmp.Compare(b.NonOverlappingStats[sortBy], a.NonOverlappingStats[sortBy]) }) + slices.SortFunc(regions, func { a, b -> return cmp.Compare(b.NonOverlappingStats[sortBy], a.NonOverlappingStats[sortBy]) }) } else { // Sort by total time by default. - slices.SortFunc(regions, func { a, b | return cmp.Compare(b.TotalTime, a.TotalTime) }) + slices.SortFunc(regions, func { a, b -> return cmp.Compare(b.TotalTime, a.TotalTime) }) } // Write down all the non-overlapping stats and sort them. @@ -214,7 +214,7 @@ func UserRegionHandlerFunc(t *parsedTrace) http.HandlerFunc { for name := range validNonOverlappingStats { allNonOverlappingStats = append(allNonOverlappingStats, name) } - slices.SortFunc(allNonOverlappingStats, func { a, b | + slices.SortFunc(allNonOverlappingStats, func { a, b -> if a == b { return 0 } @@ -472,24 +472,24 @@ func newRegionFilter(r *http.Request) (*regionFilter, error) { param := r.Form if typ, ok := param["type"]; ok && len(typ) > 0 { name = append(name, fmt.Sprintf("%q", typ[0])) - conditions = append(conditions, func { _, r | return r.Name == typ[0] }) + conditions = append(conditions, func { _, r -> return r.Name == typ[0] }) filterParams.Add("type", typ[0]) } if pc, err := strconv.ParseUint(r.FormValue("pc"), 16, 64); err == nil { encPC := fmt.Sprintf("0x%x", pc) name = append(name, "@ "+encPC) - conditions = append(conditions, func { _, r | return regionTopStackFrame(r).PC == pc }) + conditions = append(conditions, func { _, r -> return regionTopStackFrame(r).PC == pc }) filterParams.Add("pc", encPC) } if lat, err := time.ParseDuration(r.FormValue("latmin")); err == nil { name = append(name, fmt.Sprintf("(latency >= %s)", lat)) - conditions = append(conditions, func { t, r | return regionInterval(t, r).duration() >= lat }) + conditions = append(conditions, func { t, r -> return regionInterval(t, r).duration() >= lat }) filterParams.Add("latmin", lat.String()) } if lat, err := time.ParseDuration(r.FormValue("latmax")); err == nil { name = append(name, fmt.Sprintf("(latency <= %s)", lat)) - conditions = append(conditions, func { t, r | return regionInterval(t, r).duration() <= lat }) + conditions = append(conditions, func { t, r -> return regionInterval(t, r).duration() <= lat }) filterParams.Add("latmax", lat.String()) } diff --git a/src/cmd/trace/tasks.go b/src/cmd/trace/tasks.go index db899618c91ac..d068f7a73adaf 100644 --- a/src/cmd/trace/tasks.go +++ b/src/cmd/trace/tasks.go @@ -39,7 +39,7 @@ func UserTasksHandlerFunc(t *parsedTrace) http.HandlerFunc { for _, stats := range summary { userTasks = append(userTasks, stats) } - slices.SortFunc(userTasks, func { a, b | return cmp.Compare(a.Type, b.Type) }) + slices.SortFunc(userTasks, func { a, b -> return cmp.Compare(a.Type, b.Type) }) // Emit table. err := templUserTaskTypes.Execute(w, userTasks) @@ -161,7 +161,7 @@ func UserTaskHandlerFunc(t *parsedTrace) http.HandlerFunc { } // Sort them. - slices.SortStableFunc(rawEvents, func { a, b | return cmp.Compare(a.Time(), b.Time()) }) + slices.SortStableFunc(rawEvents, func { a, b -> return cmp.Compare(a.Time(), b.Time()) }) // Summarize them. var events []event @@ -195,7 +195,7 @@ func UserTaskHandlerFunc(t *parsedTrace) http.HandlerFunc { }) } // Sort the tasks by duration. - slices.SortFunc(tasks, func { a, b | return cmp.Compare(a.Duration, b.Duration) }) + slices.SortFunc(tasks, func { a, b -> return cmp.Compare(a.Duration, b.Duration) }) // Emit table. err = templUserTaskType.Execute(w, struct { @@ -329,26 +329,26 @@ func newTaskFilter(r *http.Request) (*taskFilter, error) { param := r.Form if typ, ok := param["type"]; ok && len(typ) > 0 { name = append(name, fmt.Sprintf("%q", typ[0])) - conditions = append(conditions, func { _, task | return task.Name == typ[0] }) + conditions = append(conditions, func { _, task -> return task.Name == typ[0] }) } if complete := r.FormValue("complete"); complete == "1" { name = append(name, "complete") - conditions = append(conditions, func { _, task | return task.Complete() }) + conditions = append(conditions, func { _, task -> return task.Complete() }) } else if complete == "0" { name = append(name, "incomplete") - conditions = append(conditions, func { _, task | return !task.Complete() }) + conditions = append(conditions, func { _, task -> return !task.Complete() }) } if lat, err := time.ParseDuration(r.FormValue("latmin")); err == nil { name = append(name, fmt.Sprintf("latency >= %s", lat)) - conditions = append(conditions, func { t, task | return task.Complete() && taskInterval(t, task).duration() >= lat }) + conditions = append(conditions, func { t, task -> return task.Complete() && taskInterval(t, task).duration() >= lat }) } if lat, err := time.ParseDuration(r.FormValue("latmax")); err == nil { name = append(name, fmt.Sprintf("latency <= %s", lat)) - conditions = append(conditions, func { t, task | return task.Complete() && taskInterval(t, task).duration() <= lat }) + conditions = append(conditions, func { t, task -> return task.Complete() && taskInterval(t, task).duration() <= lat }) } if text := r.FormValue("logtext"); text != "" { name = append(name, fmt.Sprintf("log contains %q", text)) - conditions = append(conditions, func { _, task | return taskMatches(task, text) }) + conditions = append(conditions, func { _, task -> return taskMatches(task, text) }) } return &taskFilter{name: strings.Join(name, ","), cond: conditions}, nil diff --git a/src/cmd/trace/viewer.go b/src/cmd/trace/viewer.go index 7cff235dbcf74..b300b088969c7 100644 --- a/src/cmd/trace/viewer.go +++ b/src/cmd/trace/viewer.go @@ -15,7 +15,7 @@ import ( // used to store the frames to reduce allocations. func viewerFrames(stk trace.Stack) []*trace.Frame { var frames []*trace.Frame - stk.Frames(func { f | + stk.Frames(func { f -> frames = append(frames, &trace.Frame{ PC: f.PC, Fn: f.Func, diff --git a/src/cmd/vendor/github.com/google/pprof/driver/driver.go b/src/cmd/vendor/github.com/google/pprof/driver/driver.go index 3a838ede86b86..43d712f57769f 100644 --- a/src/cmd/vendor/github.com/google/pprof/driver/driver.go +++ b/src/cmd/vendor/github.com/google/pprof/driver/driver.go @@ -44,7 +44,7 @@ func (o *Options) internalOptions() *plugin.Options { } var httpServer func(args *plugin.HTTPServerArgs) error if o.HTTPServer != nil { - httpServer = func { args | return o.HTTPServer(((*HTTPServerArgs)(args))) } + httpServer = func { args -> return o.HTTPServer(((*HTTPServerArgs)(args))) } } return &plugin.Options{ Writer: o.Writer, diff --git a/src/cmd/vendor/github.com/google/pprof/internal/binutils/binutils.go b/src/cmd/vendor/github.com/google/pprof/internal/binutils/binutils.go index 18544bca1b163..e2fbf14b6e00e 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/binutils/binutils.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/binutils/binutils.go @@ -119,7 +119,7 @@ func (bu *Binutils) String() string { // symbolization (using nm), which is much faster than addr2line but // provides only symbol name information (no file/line). func (bu *Binutils) SetFastSymbolization(fast bool) { - bu.update(func { r | r.fast = fast }) + bu.update(func { r -> r.fast = fast }) } // SetTools processes the contents of the tools option. It @@ -128,7 +128,7 @@ func (bu *Binutils) SetFastSymbolization(fast bool) { // tool named t. If t is not specified, the path is searched for all // tools. func (bu *Binutils) SetTools(config string) { - bu.update(func { r | initTools(r, config) }) + bu.update(func { r -> initTools(r, config) }) } func initTools(b *binrep, config string) { diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/settings.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/settings.go index 8a956230af2d6..7bddcaa99ba9f 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/settings.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/settings.go @@ -132,7 +132,7 @@ func setConfig(fname string, request url.URL) error { if err := cfg.applyURL(q); err != nil { return err } - return editSettings(fname, func { s | + return editSettings(fname, func { s -> for i, c := range s.Configs { if c.Name == name { s.Configs[i].config = cfg @@ -146,7 +146,7 @@ func setConfig(fname string, request url.URL) error { // removeConfig removes config from fname. func removeConfig(fname, config string) error { - return editSettings(fname, func { s | + return editSettings(fname, func { s -> for i, c := range s.Configs { if c.Name == config { s.Configs = append(s.Configs[:i], s.Configs[i+1:]...) diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/stacks.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/stacks.go index 4b7f581725a2e..234ed5b882db3 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/stacks.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/stacks.go @@ -26,7 +26,7 @@ import ( // stackView generates the flamegraph view. func (ui *webInterface) stackView(w http.ResponseWriter, req *http.Request) { // Get all data in a report. - rpt, errList := ui.makeReport(w, req, []string{"svg"}, func { cfg | + rpt, errList := ui.makeReport(w, req, []string{"svg"}, func { cfg -> cfg.CallTree = true cfg.Trim = false cfg.Granularity = "filefunctions" diff --git a/src/cmd/vendor/github.com/google/pprof/internal/driver/webui.go b/src/cmd/vendor/github.com/google/pprof/internal/driver/webui.go index 6da8f0309efa6..4e810d3b65b03 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/driver/webui.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/driver/webui.go @@ -134,7 +134,7 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, d "/flamegraphold": redirectWithQuery("flamegraph", http.StatusMovedPermanently), // Keep legacy URL working. "/saveconfig": http.HandlerFunc(ui.saveConfig), "/deleteconfig": http.HandlerFunc(ui.deleteConfig), - "/download": http.HandlerFunc(func { w, req | + "/download": http.HandlerFunc(func { w, req -> w.Header().Set("Content-Type", "application/vnd.google.protobuf+gzip") w.Header().Set("Content-Disposition", "attachment;filename=profile.pb.gz") p.Write(w) @@ -185,7 +185,7 @@ func defaultWebServer(args *plugin.HTTPServerArgs) error { return err } isLocal := isLocalhost(args.Host) - handler := http.HandlerFunc(func { w, req | + handler := http.HandlerFunc(func { w, req -> if isLocal { // Only allow local clients host, _, err := net.SplitHostPort(req.RemoteAddr) @@ -364,7 +364,7 @@ func dotToSvg(dot []byte) ([]byte, error) { } func (ui *webInterface) top(w http.ResponseWriter, req *http.Request) { - rpt, errList := ui.makeReport(w, req, []string{"top"}, func { cfg | cfg.NodeCount = 500 }) + rpt, errList := ui.makeReport(w, req, []string{"top"}, func { cfg -> cfg.NodeCount = 500 }) if rpt == nil { return // error already reported } @@ -428,7 +428,7 @@ func (ui *webInterface) source(w http.ResponseWriter, req *http.Request) { // peek generates a web page listing callers/callers. func (ui *webInterface) peek(w http.ResponseWriter, req *http.Request) { args := []string{"peek", req.URL.Query().Get("f")} - rpt, errList := ui.makeReport(w, req, args, func { cfg | cfg.Granularity = "lines" }) + rpt, errList := ui.makeReport(w, req, args, func { cfg -> cfg.Granularity = "lines" }) if rpt == nil { return // error already reported } diff --git a/src/cmd/vendor/github.com/google/pprof/internal/report/report.go b/src/cmd/vendor/github.com/google/pprof/internal/report/report.go index 1f25935b4a87c..257df30e8af26 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/report/report.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/report/report.go @@ -1277,7 +1277,7 @@ func NewDefault(prof *profile.Profile, options Options) *Report { } o.SampleType = prof.SampleType[index].Type o.SampleUnit = strings.ToLower(prof.SampleType[index].Unit) - o.SampleValue = func { v | return v[index] } + o.SampleValue = func { v -> return v[index] } return New(prof, o) } diff --git a/src/cmd/vendor/github.com/google/pprof/internal/report/source.go b/src/cmd/vendor/github.com/google/pprof/internal/report/source.go index 6904edce2a651..e57fcd143447a 100644 --- a/src/cmd/vendor/github.com/google/pprof/internal/report/source.go +++ b/src/cmd/vendor/github.com/google/pprof/internal/report/source.go @@ -375,7 +375,7 @@ func (sp *sourcePrinter) expandAddresses(rpt *Report, addrs map[uint64]addrInfo, // Trim ranges if there are too many. const maxRanges = 25 - sort.Slice(ranges, func { i, j | return ranges[i].score > ranges[j].score }) + sort.Slice(ranges, func { i, j -> return ranges[i].score > ranges[j].score }) if len(ranges) > maxRanges { ranges = ranges[:maxRanges] } @@ -551,7 +551,7 @@ func (sp *sourcePrinter) splitIntoRanges(prof *profile.Profile, addrMap map[uint unprocessed = append(unprocessed, addr) } } - sort.Slice(addrs, func { i, j | return addrs[i] < addrs[j] }) + sort.Slice(addrs, func { i, j -> return addrs[i] < addrs[j] }) const expand = 500 // How much to expand range to pick up nearby addresses. var result []addressRange @@ -630,7 +630,7 @@ func (sp *sourcePrinter) generate(maxFiles int, rpt *Report) WebListData { order := func(i, j int) bool { return files[i].flat > files[j].flat } if maxFiles < 0 { // Order by name for compatibility with old code. - order = func { i, j | return files[i].fname < files[j].fname } + order = func { i, j -> return files[i].fname < files[j].fname } maxFiles = len(files) } sort.Slice(files, order) diff --git a/src/cmd/vendor/github.com/ianlancetaylor/demangle/demangle.go b/src/cmd/vendor/github.com/ianlancetaylor/demangle/demangle.go index bddc9f2d2bc36..5d1a710f4236e 100644 --- a/src/cmd/vendor/github.com/ianlancetaylor/demangle/demangle.go +++ b/src/cmd/vendor/github.com/ianlancetaylor/demangle/demangle.go @@ -435,7 +435,7 @@ func (st *state) encoding(params bool, local forLocalNameType) AST { mwq, _ := a.(*MethodWithQualifiers) var findTemplate func(AST) *Template - findTemplate = func { check | + findTemplate = func { check -> switch check := check.(type) { case *Template: return check @@ -2288,7 +2288,7 @@ func (st *state) templateParam() AST { // cast operators. func (st *state) setTemplate(a AST, tmpl *Template) { seen := make(map[AST]bool) - a.Traverse(func { a | + a.Traverse(func { a -> switch a := a.(type) { case *TemplateParam: if a.Template != nil { @@ -3659,7 +3659,7 @@ func simplifyOne(a AST) AST { func (st *state) findArgumentPack(a AST) *ArgumentPack { seen := make(map[AST]bool) var ret *ArgumentPack - a.Traverse(func { a | + a.Traverse(func { a -> if ret != nil { return false } diff --git a/src/cmd/vendor/golang.org/x/build/relnote/relnote.go b/src/cmd/vendor/golang.org/x/build/relnote/relnote.go index edb761644f3d5..3186fccefa037 100644 --- a/src/cmd/vendor/golang.org/x/build/relnote/relnote.go +++ b/src/cmd/vendor/golang.org/x/build/relnote/relnote.go @@ -248,7 +248,7 @@ func removeEmptySections(bs []md.Block) []md.Block { func sortedMarkdownFilenames(fsys fs.FS) ([]string, error) { var filenames []string - err := fs.WalkDir(fsys, ".", func { path, d, err | + err := fs.WalkDir(fsys, ".", func { path, d, err -> if err != nil { return err } diff --git a/src/cmd/vendor/golang.org/x/mod/modfile/rule.go b/src/cmd/vendor/golang.org/x/mod/modfile/rule.go index b7d8d6dc5c6f2..47cf08fe27ba3 100644 --- a/src/cmd/vendor/golang.org/x/mod/modfile/rule.go +++ b/src/cmd/vendor/golang.org/x/mod/modfile/rule.go @@ -1587,7 +1587,7 @@ func (f *File) SortBlocks() { } else if block.Token[0] == "retract" { less = lineRetractLess } - sort.SliceStable(block.Line, func { i, j | return less(block.Line[i], block.Line[j]) }) + sort.SliceStable(block.Line, func { i, j -> return less(block.Line[i], block.Line[j]) }) } } diff --git a/src/cmd/vendor/golang.org/x/mod/modfile/work.go b/src/cmd/vendor/golang.org/x/mod/modfile/work.go index 229fad23547f6..b4e156053a8a7 100644 --- a/src/cmd/vendor/golang.org/x/mod/modfile/work.go +++ b/src/cmd/vendor/golang.org/x/mod/modfile/work.go @@ -315,7 +315,7 @@ func (f *WorkFile) SortBlocks() { if !ok { continue } - sort.SliceStable(block.Line, func { i, j | return lineLess(block.Line[i], block.Line[j]) }) + sort.SliceStable(block.Line, func { i, j -> return lineLess(block.Line[i], block.Line[j]) }) } } diff --git a/src/cmd/vendor/golang.org/x/mod/module/module.go b/src/cmd/vendor/golang.org/x/mod/module/module.go index e0fccf815f085..18926455a1005 100644 --- a/src/cmd/vendor/golang.org/x/mod/module/module.go +++ b/src/cmd/vendor/golang.org/x/mod/module/module.go @@ -657,7 +657,7 @@ func CanonicalVersion(v string) string { // optionally followed by a tie-breaking suffix introduced by a slash character, // like in "v0.0.1/go.mod". func Sort(list []Version) { - sort.Slice(list, func { i, j | + sort.Slice(list, func { i, j -> mi := list[i] mj := list[j] if mi.Path != mj.Path { diff --git a/src/cmd/vendor/golang.org/x/mod/sumdb/dirhash/hash.go b/src/cmd/vendor/golang.org/x/mod/sumdb/dirhash/hash.go index ce42f00a5d3c8..1a157833297a9 100644 --- a/src/cmd/vendor/golang.org/x/mod/sumdb/dirhash/hash.go +++ b/src/cmd/vendor/golang.org/x/mod/sumdb/dirhash/hash.go @@ -84,7 +84,7 @@ func HashDir(dir, prefix string, hash Hash) (string, error) { func DirFiles(dir, prefix string) ([]string, error) { var files []string dir = filepath.Clean(dir) - err := filepath.Walk(dir, func { file, info, err | + err := filepath.Walk(dir, func { file, info, err -> if err != nil { return err } diff --git a/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go b/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go index 368d8b8a51949..24ee4c875b3a5 100644 --- a/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go +++ b/src/cmd/vendor/golang.org/x/mod/sumdb/note/note.go @@ -265,7 +265,7 @@ func NewVerifier(vkey string) (Verifier, error) { if len(key) != 32 { return nil, errVerifierID } - v.verify = func { msg, sig | return ed25519.Verify(key, msg, sig) } + v.verify = func { msg, sig -> return ed25519.Verify(key, msg, sig) } } return v, nil @@ -326,7 +326,7 @@ func NewSigner(skey string) (Signer, error) { } key = ed25519.NewKeyFromSeed(key) pubkey = append([]byte{algEd25519}, key[32:]...) - s.sign = func { msg | return ed25519.Sign(key, msg), nil } + s.sign = func { msg -> return ed25519.Sign(key, msg), nil } } if uint32(hash) != keyHash(name, pubkey) { diff --git a/src/cmd/vendor/golang.org/x/mod/zip/zip.go b/src/cmd/vendor/golang.org/x/mod/zip/zip.go index 9594ac1dcda57..dc7df7293ecac 100644 --- a/src/cmd/vendor/golang.org/x/mod/zip/zip.go +++ b/src/cmd/vendor/golang.org/x/mod/zip/zip.go @@ -892,7 +892,7 @@ func (cc collisionChecker) check(p string, isDir bool) error { // files, as well as a list of directories and files that were skipped (for // example, nested modules and symbolic links). func listFilesInDir(dir string) (files []File, omitted []FileError, err error) { - err = filepath.Walk(dir, func { filePath, info, err | + err = filepath.Walk(dir, func { filePath, info, err -> if err != nil { return err } diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_openbsd.go index 303cbc0cfeb63..2b90c1aff2d17 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -38,7 +38,7 @@ func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno) func nametomib(name string) (mib []_C_int, err error) { - i := sort.Search(len(sysctlMib), func { i | return sysctlMib[i].ctlname >= name }) + i := sort.Search(len(sysctlMib), func { i -> return sysctlMib[i].ctlname >= name }) if i < len(sysctlMib) && sysctlMib[i].ctlname == name { return sysctlMib[i].ctloid, nil } diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_unix.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_unix.go index 3965d27eba17e..1af0ef592badd 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_unix.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_unix.go @@ -51,7 +51,7 @@ func errnoErr(e syscall.Errno) error { // ErrnoName returns the error name for error number e. func ErrnoName(e syscall.Errno) string { - i := sort.Search(len(errorList), func { i | return errorList[i].num >= e }) + i := sort.Search(len(errorList), func { i -> return errorList[i].num >= e }) if i < len(errorList) && errorList[i].num == e { return errorList[i].name } @@ -60,7 +60,7 @@ func ErrnoName(e syscall.Errno) string { // SignalName returns the signal name for signal number s. func SignalName(s syscall.Signal) string { - i := sort.Search(len(signalList), func { i | return signalList[i].num >= s }) + i := sort.Search(len(signalList), func { i -> return signalList[i].num >= s }) if i < len(signalList) && signalList[i].num == s { return signalList[i].name } diff --git a/src/cmd/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go b/src/cmd/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go index be3bcfc9b8baf..93f8aa2c05467 100644 --- a/src/cmd/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go +++ b/src/cmd/vendor/golang.org/x/sys/unix/syscall_zos_s390x.go @@ -2363,7 +2363,7 @@ func errnoErr2(e Errno, e2 uintptr) error { // ErrnoName returns the error name for error number e. func ErrnoName(e Errno) string { - i := sort.Search(len(errorList), func { i | return errorList[i].num >= e }) + i := sort.Search(len(errorList), func { i -> return errorList[i].num >= e }) if i < len(errorList) && errorList[i].num == e { return errorList[i].name } @@ -2372,7 +2372,7 @@ func ErrnoName(e Errno) string { // SignalName returns the signal name for signal number s. func SignalName(s syscall.Signal) string { - i := sort.Search(len(signalList), func { i | return signalList[i].num >= s }) + i := sort.Search(len(signalList), func { i -> return signalList[i].num >= s }) if i < len(signalList) && signalList[i].num == s { return signalList[i].name } diff --git a/src/cmd/vendor/golang.org/x/telemetry/counter/counter.go b/src/cmd/vendor/golang.org/x/telemetry/counter/counter.go index eeb66d9945a1d..e800d65666c36 100644 --- a/src/cmd/vendor/golang.org/x/telemetry/counter/counter.go +++ b/src/cmd/vendor/golang.org/x/telemetry/counter/counter.go @@ -119,7 +119,7 @@ func OpenDir(telemetryDir string) { // // For instance, CountFlags("gopls/flag:", *flag.CommandLine) func CountFlags(prefix string, fs flag.FlagSet) { - fs.Visit(func { f | New(prefix + f.Name).Inc() }) + fs.Visit(func { f -> New(prefix + f.Name).Inc() }) } // CountCommandLineFlags creates a counter for every flag diff --git a/src/cmd/vendor/golang.org/x/telemetry/internal/crashmonitor/crash_go123.go b/src/cmd/vendor/golang.org/x/telemetry/internal/crashmonitor/crash_go123.go index a4fcb48d5596c..cadab440eaa99 100644 --- a/src/cmd/vendor/golang.org/x/telemetry/internal/crashmonitor/crash_go123.go +++ b/src/cmd/vendor/golang.org/x/telemetry/internal/crashmonitor/crash_go123.go @@ -13,5 +13,5 @@ import ( ) func init() { - setCrashOutput = func { f | return debug.SetCrashOutput(f, debug.CrashOptions{}) } + setCrashOutput = func { f -> return debug.SetCrashOutput(f, debug.CrashOptions{}) } } diff --git a/src/cmd/vendor/golang.org/x/text/internal/language/compact/compact.go b/src/cmd/vendor/golang.org/x/text/internal/language/compact/compact.go index bdc5729e7fdbe..793cafba7d7fb 100644 --- a/src/cmd/vendor/golang.org/x/text/internal/language/compact/compact.go +++ b/src/cmd/vendor/golang.org/x/text/internal/language/compact/compact.go @@ -28,7 +28,7 @@ func getCoreIndex(t language.Tag) (id ID, ok bool) { if !ok { return 0, false } - i := sort.Search(len(coreTags), func { i | return cci <= coreTags[i] }) + i := sort.Search(len(coreTags), func { i -> return cci <= coreTags[i] }) if i == len(coreTags) || coreTags[i] != cci { return 0, false } diff --git a/src/cmd/vendor/golang.org/x/text/internal/language/lookup.go b/src/cmd/vendor/golang.org/x/text/internal/language/lookup.go index aa83fc1ba64e3..3b7e78ad63b43 100644 --- a/src/cmd/vendor/golang.org/x/text/internal/language/lookup.go +++ b/src/cmd/vendor/golang.org/x/text/internal/language/lookup.go @@ -27,7 +27,7 @@ func findIndex(idx tag.Index, key []byte, form string) (index int, err error) { } func searchUint(imap []uint16, key uint16) int { - return sort.Search(len(imap), func { i | return imap[i] >= key }) + return sort.Search(len(imap), func { i -> return imap[i] >= key }) } type Language uint16 @@ -50,7 +50,7 @@ func (id Language) Canonicalize() (Language, AliasType) { // normLang returns the mapped langID of id according to mapping m. func normLang(id Language) (Language, AliasType) { - k := sort.Search(len(AliasMap), func { i | return AliasMap[i].From >= uint16(id) }) + k := sort.Search(len(AliasMap), func { i -> return AliasMap[i].From >= uint16(id) }) if k < len(AliasMap) && AliasMap[k].From == uint16(id) { return Language(AliasMap[k].To), AliasTypes[k] } @@ -244,7 +244,7 @@ func getRegionM49(n int) (Region, error) { idx := n >> searchBits buf := fromM49[m49Index[idx]:m49Index[idx+1]] val := uint16(n) << regionBits // we rely on bits shifting out - i := sort.Search(len(buf), func { i | return buf[i] >= val }) + i := sort.Search(len(buf), func { i -> return buf[i] >= val }) if r := fromM49[int(m49Index[idx])+i]; r&^regionMask == val { return Region(r & regionMask), nil } @@ -259,7 +259,7 @@ func getRegionM49(n int) (Region, error) { // TODO: consider mapping split up regions to new most populous one (like CLDR). func normRegion(r Region) Region { m := regionOldMap - k := sort.Search(len(m), func { i | return m[i].From >= uint16(r) }) + k := sort.Search(len(m), func { i -> return m[i].From >= uint16(r) }) if k < len(m) && m[k].From == uint16(r) { return Region(m[k].To) } diff --git a/src/cmd/vendor/golang.org/x/text/internal/tag/tag.go b/src/cmd/vendor/golang.org/x/text/internal/tag/tag.go index c64984525a19c..1966d73756a71 100644 --- a/src/cmd/vendor/golang.org/x/text/internal/tag/tag.go +++ b/src/cmd/vendor/golang.org/x/text/internal/tag/tag.go @@ -25,7 +25,7 @@ func (s Index) Index(key []byte) int { n := len(key) // search the index of the first entry with an equal or higher value than // key in s. - index := sort.Search(len(s)/4, func { i | return cmp(s[i*4:i*4+n], key) != -1 }) + index := sort.Search(len(s)/4, func { i -> return cmp(s[i*4:i*4+n], key) != -1 }) i := index * 4 if cmp(s[i:i+len(key)], key) != 0 { return -1 diff --git a/src/cmd/vendor/golang.org/x/text/unicode/norm/normalize.go b/src/cmd/vendor/golang.org/x/text/unicode/norm/normalize.go index cbfbc461b0e32..89691bee7711e 100644 --- a/src/cmd/vendor/golang.org/x/text/unicode/norm/normalize.go +++ b/src/cmd/vendor/golang.org/x/text/unicode/norm/normalize.go @@ -117,7 +117,7 @@ func (f Form) IsNormalString(s string) bool { return true } rb := reorderBuffer{f: *ft, src: src, nsrc: len(s)} - rb.setFlusher(nil, func { rb | + rb.setFlusher(nil, func { rb -> for i := 0; i < rb.nrune; i++ { info := rb.rune[i] if bp+int(info.size) > len(s) { diff --git a/src/cmd/vendor/golang.org/x/tools/cmd/bisect/main.go b/src/cmd/vendor/golang.org/x/tools/cmd/bisect/main.go index 6e8df3afa969c..bf6ffd476a1c7 100644 --- a/src/cmd/vendor/golang.org/x/tools/cmd/bisect/main.go +++ b/src/cmd/vendor/golang.org/x/tools/cmd/bisect/main.go @@ -172,7 +172,7 @@ func main() { env := "" envFlag := "" - flag.Func("compile", "bisect source locations affected by Go compiler `rewrite` (fma, loopvar, ...)", func { value | + flag.Func("compile", "bisect source locations affected by Go compiler `rewrite` (fma, loopvar, ...)", func { value -> if envFlag != "" { return fmt.Errorf("cannot use -%s and -compile", envFlag) } @@ -180,7 +180,7 @@ func main() { env = "GOCOMPILEDEBUG=" + value + "hash=PATTERN" return nil }) - flag.Func("godebug", "bisect call stacks affected by GODEBUG setting `name=value`", func { value | + flag.Func("godebug", "bisect call stacks affected by GODEBUG setting `name=value`", func { value -> if envFlag != "" { return fmt.Errorf("cannot use -%s and -godebug", envFlag) } @@ -448,8 +448,8 @@ func skipHexDigits(idY, idN []uint64) int { all = append(all, x) } } - sort.Slice(all, func { i, j | return bits.Reverse64(all[i]) < bits.Reverse64(all[j]) }) - digits := sort.Search(64/4, func { digits | + sort.Slice(all, func { i, j -> return bits.Reverse64(all[i]) < bits.Reverse64(all[j]) }) + digits := sort.Search(64/4, func { digits -> mask := uint64(1)<<(4*digits) - 1 for i := 0; i+1 < len(all); i++ { if all[i]&mask == all[i+1]&mask { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go index 1833fb36b7428..f5cf26b37fcde 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/flags.go @@ -56,7 +56,7 @@ func Parse(analyzers []*analysis.Analyzer, multi bool) []*analysis.Analyzer { enabled[a] = enable } - a.Flags.VisitAll(func { f | + a.Flags.VisitAll(func { f -> if !multi && flag.Lookup(f.Name) != nil { log.Printf("%s flag -%s would conflict with driver; skipping", a.Name, f.Name) return @@ -146,7 +146,7 @@ func Parse(analyzers []*analysis.Analyzer, multi bool) []*analysis.Analyzer { func expand(analyzers []*analysis.Analyzer) map[*analysis.Analyzer]bool { seen := make(map[*analysis.Analyzer]bool) var visitAll func([]*analysis.Analyzer) - visitAll = func { analyzers | + visitAll = func { analyzers -> for _, a := range analyzers { if !seen[a] { seen[a] = true @@ -165,7 +165,7 @@ func printFlags() { Usage string } var flags []jsonFlag = nil - flag.VisitAll(func { f | + flag.VisitAll(func { f -> // Don't report {single,multi}checker debugging // flags or fix as these have no effect on unitchecker // (as invoked by 'go vet'). diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/help.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/help.go index 52af504dd0051..8f073cda31f83 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/help.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags/help.go @@ -32,7 +32,7 @@ func Help(progname string, analyzers []*analysis.Analyzer, args []string) { fmt.Println(strings.Replace(help, "PROGNAME", progname, -1)) fmt.Println("Registered analyzers:") fmt.Println() - sort.Slice(analyzers, func { i, j | return analyzers[i].Name < analyzers[j].Name }) + sort.Slice(analyzers, func { i, j -> return analyzers[i].Name < analyzers[j].Name }) for _, a := range analyzers { title := strings.Split(a.Doc, "\n\n")[0] fmt.Printf(" %-12s %s\n", a.Name, title) @@ -45,7 +45,7 @@ func Help(progname string, analyzers []*analysis.Analyzer, args []string) { fmt.Println("\nCore flags:") fmt.Println() fs := flag.NewFlagSet("", flag.ExitOnError) - flag.VisitAll(func { f | if !strings.Contains(f.Name, ".") { + flag.VisitAll(func { f -> if !strings.Contains(f.Name, ".") { fs.Var(f.Value, f.Name, f.Usage) } }) fs.SetOutput(os.Stdout) @@ -69,7 +69,7 @@ outer: // properly prefixed. first := true fs := flag.NewFlagSet(a.Name, flag.ExitOnError) - a.Flags.VisitAll(func { f | + a.Flags.VisitAll(func { f -> if first { first = false fmt.Println("\nAnalyzer flags:") diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/appends/appends.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/appends/appends.go index a788077c5a745..771055f3fa68d 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/appends/appends.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/appends/appends.go @@ -35,7 +35,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.CallExpr)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> call := n.(*ast.CallExpr) b, ok := typeutil.Callee(pass.TypesInfo, call).(*types.Builtin) if ok && b.Name() == "append" && len(call.Args) == 1 { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/assign/assign.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/assign/assign.go index b12fa40964c01..5809cfcdc4feb 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/assign/assign.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/assign/assign.go @@ -39,7 +39,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.AssignStmt)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> stmt := n.(*ast.AssignStmt) if stmt.Tok != token.ASSIGN { return // ignore := diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/atomic/atomic.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/atomic/atomic.go index 341f7a2d89c58..99edfb0dc8e8c 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/atomic/atomic.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/atomic/atomic.go @@ -38,7 +38,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.AssignStmt)(nil), } - inspect.Preorder(nodeFilter, func { node | + inspect.Preorder(nodeFilter, func { node -> n := node.(*ast.AssignStmt) if len(n.Lhs) != len(n.Rhs) { return diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/bools/bools.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/bools/bools.go index af64c77d0be61..76f2473fd7032 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/bools/bools.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/bools/bools.go @@ -35,7 +35,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.BinaryExpr)(nil), } seen := make(map[*ast.BinaryExpr]bool) - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> e := n.(*ast.BinaryExpr) if seen[e] { // Already processed as a subexpression of an earlier node. diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go index 3d0b07aa87f60..9272b978002b2 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/cgocall/cgocall.go @@ -57,7 +57,7 @@ func run(pass *analysis.Pass) (interface{}, error) { } func checkCgo(fset *token.FileSet, f *ast.File, info *types.Info, reportf func(token.Pos, string, ...interface{})) { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> call, ok := n.(*ast.CallExpr) if !ok { return true @@ -266,7 +266,7 @@ func typeCheckCgoSourceFiles(fset *token.FileSet, pkg *types.Package, files []*a // Type-check the synthetic files. tc := &types.Config{ FakeImportC: true, - Importer: importerFunc(func { path | return importMap[path], nil }), + Importer: importerFunc(func { path -> return importMap[path], nil }), Sizes: sizes, Error: func(error) {}, // ignore errors (e.g. unused import) } diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go index cf0cf4b04eab0..d9ecdf80f95e1 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/composite/composite.go @@ -58,7 +58,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.CompositeLit)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> cl := n.(*ast.CompositeLit) typ := pass.TypesInfo.Types[cl].Type diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go index 53ca4826192f0..9ae0c4c901d2f 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock/copylock.go @@ -50,7 +50,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.RangeStmt)(nil), (*ast.ReturnStmt)(nil), } - inspect.Preorder(nodeFilter, func { node | + inspect.Preorder(nodeFilter, func { node -> switch node := node.(type) { case *ast.RangeStmt: checkCopyLocksRange(pass, node) diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go index c3b9a5ceb0ad1..509bdf476e97b 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow/ctrlflow.go @@ -100,7 +100,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.FuncDecl)(nil), (*ast.FuncLit)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> switch n := n.(type) { case *ast.FuncDecl: // Type information may be incomplete. diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/defers/defers.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/defers/defers.go index e8860379d1295..4321edf0695a5 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/defers/defers.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/defers/defers.go @@ -50,7 +50,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.DeferStmt)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> d := n.(*ast.DeferStmt) ast.Inspect(d.Call, checkDeferCall) }) diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/errorsas/errorsas.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/errorsas/errorsas.go index a9e51da105245..16771d0815fc3 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/errorsas/errorsas.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/errorsas/errorsas.go @@ -48,7 +48,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.CallExpr)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> call := n.(*ast.CallExpr) fn := typeutil.StaticCallee(pass.TypesInfo, call) if !analysisutil.IsFunctionNamed(fn, "errors", "As") { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go index 393bbcd2c30f7..d8e404c802f86 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse/httpresponse.go @@ -54,7 +54,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.CallExpr)(nil), } - inspect.WithStack(nodeFilter, func { n, push, stack | + inspect.WithStack(nodeFilter, func { n, push, stack -> if !push { return true } diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert/ifaceassert.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert/ifaceassert.go index 8a8eab994beca..ca0b60832f0e6 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert/ifaceassert.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/ifaceassert/ifaceassert.go @@ -59,7 +59,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.TypeSwitchStmt)(nil), } var free typeparams.Free - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> var ( assert *ast.TypeAssertExpr // v.(T) expression targets []ast.Expr // interfaces T in v.(T) diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go index 917afac499b54..6f6943e356e2f 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil/util.go @@ -29,7 +29,7 @@ func Format(fset *token.FileSet, x ast.Expr) string { // HasSideEffects reports whether evaluation of e has side effects. func HasSideEffects(info *types.Info, e ast.Expr) bool { safe := true - ast.Inspect(e, func { node | + ast.Inspect(e, func { node -> switch n := node.(type) { case *ast.CallExpr: typVal := info.Types[n.Fun] diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go index 6dc2ea325b3a5..e5a8f1c1a8653 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/loopclosure/loopclosure.go @@ -37,7 +37,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.RangeStmt)(nil), (*ast.ForStmt)(nil), } - inspect.Nodes(nodeFilter, func { n, push | + inspect.Nodes(nodeFilter, func { n, push -> if !push { // inspect.Nodes is slightly suboptimal as we only use push=true. return true @@ -90,7 +90,7 @@ func run(pass *analysis.Pass) (interface{}, error) { // so that that checker could, for example, conclude that a go statement is // followed by an if statement made of only trivial statements and trivial expressions, // and hence the go statement could still be checked. - forEachLastStmt(body.List, func { last | + forEachLastStmt(body.List, func { last -> var stmts []ast.Stmt switch s := last.(type) { case *ast.GoStmt: @@ -134,7 +134,7 @@ func run(pass *analysis.Pass) (interface{}, error) { // references to vars. vars is expected to be variables updated by a loop statement, // and checkStmt is expected to be a statements from the body of a func literal in the loop. func reportCaptured(pass *analysis.Pass, vars []types.Object, checkStmt ast.Stmt) { - ast.Inspect(checkStmt, func { n | + ast.Inspect(checkStmt, func { n -> id, ok := n.(*ast.Ident) if !ok { return true diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go index 88fc31580c7ae..f3dafac5a5525 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/lostcancel/lostcancel.go @@ -58,7 +58,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.FuncLit)(nil), (*ast.FuncDecl)(nil), } - inspect.Preorder(nodeTypes, func { n | runFunc(pass, n) }) + inspect.Preorder(nodeTypes, func { n -> runFunc(pass, n) }) return nil, nil } @@ -81,7 +81,7 @@ func runFunc(pass *analysis.Pass, node ast.Node) { // Find the set of cancel vars to analyze. stack := make([]ast.Node, 0, 32) - ast.Inspect(node, func { n | + ast.Inspect(node, func { n -> switch n.(type) { case *ast.FuncLit: if len(stack) > 0 { @@ -222,7 +222,7 @@ func lostCancelPath(pass *analysis.Pass, g *cfg.CFG, v *types.Var, stmt ast.Node uses := func(pass *analysis.Pass, v *types.Var, stmts []ast.Node) bool { found := false for _, stmt := range stmts { - ast.Inspect(stmt, func { n | + ast.Inspect(stmt, func { n -> switch n := n.(type) { case *ast.Ident: if pass.TypesInfo.Uses[n] == v { @@ -284,7 +284,7 @@ outer: // return block, in which v is never "used". seen := make(map[*cfg.Block]bool) var search func(blocks []*cfg.Block) *ast.ReturnStmt - search = func { blocks | + search = func { blocks -> for _, b := range blocks { if seen[b] { continue diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go index 34818079462fd..caf5f0fe39c77 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/nilfunc/nilfunc.go @@ -36,7 +36,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.BinaryExpr)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> e := n.(*ast.BinaryExpr) // Only want == or != comparisons. diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go index 07f381dc512aa..3e87c2ef4119d 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/printf/printf.go @@ -200,7 +200,7 @@ func findPrintfLike(pass *analysis.Pass, res *Result) (interface{}, error) { // Walk the graph to figure out which are really printf wrappers. for _, w := range wrappers { // Scan function for calls that could be to other printf-like functions. - ast.Inspect(w.fdecl.Body, func { n | + ast.Inspect(w.fdecl.Body, func { n -> if w.failed { return false } @@ -450,7 +450,7 @@ func checkCall(pass *analysis.Pass) { nodeFilter := []ast.Node{ (*ast.CallExpr)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> call := n.(*ast.CallExpr) fn, kind := printfNameAndKind(pass, call) switch kind { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/shift/dead.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/shift/dead.go index 7b3ba19e01357..2ec9dbe49af5c 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/shift/dead.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/shift/dead.go @@ -22,7 +22,7 @@ func updateDead(info *types.Info, dead map[ast.Node]bool, node ast.Node) { // setDead marks the node and all the children as dead. setDead := func(n ast.Node) { - ast.Inspect(n, func { node | + ast.Inspect(n, func { node -> if node != nil { dead[node] = true } diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/shift/shift.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/shift/shift.go index 5c3a21d469114..fa8b67dffdc7f 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/shift/shift.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/shift/shift.go @@ -44,7 +44,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.IfStmt)(nil), (*ast.SwitchStmt)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> // TODO(adonovan): move updateDead into this file. updateDead(pass.TypesInfo, dead, n) }) @@ -52,7 +52,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.AssignStmt)(nil), (*ast.BinaryExpr)(nil), } - inspect.Preorder(nodeFilter, func { node | + inspect.Preorder(nodeFilter, func { node -> if dead[node] { // Skip shift checks on unreachable nodes. return diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go index 442d2b1ba8b91..58b8d74ed19a4 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/sigchanyzer/sigchanyzer.go @@ -42,7 +42,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.CallExpr)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> call := n.(*ast.CallExpr) if !isSignalNotify(pass.TypesInfo, call) { return diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/slog/slog.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/slog/slog.go index b07194919140b..a144b53ae441a 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/slog/slog.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/slog/slog.go @@ -54,7 +54,7 @@ func run(pass *analysis.Pass) (any, error) { nodeFilter := []ast.Node{ (*ast.CallExpr)(nil), } - inspect.Preorder(nodeFilter, func { node | + inspect.Preorder(nodeFilter, func { node -> call := node.(*ast.CallExpr) fn := typeutil.StaticCallee(pass.TypesInfo, call) if fn == nil { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go index ae638ee4f5a98..e088442984723 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods/stdmethods.go @@ -73,7 +73,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.FuncDecl)(nil), (*ast.InterfaceType)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> switch n := n.(type) { case *ast.FuncDecl: if n.Recv != nil { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdversion/stdversion.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdversion/stdversion.go index 302916aa8de76..67a59ce86d52a 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdversion/stdversion.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stdversion/stdversion.go @@ -85,7 +85,7 @@ func run(pass *analysis.Pass) (any, error) { (*ast.Ident)(nil), } var fileVersion string // "" => no check - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> switch n := n.(type) { case *ast.File: if isGenerated(n) { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stringintconv/string.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stringintconv/string.go index 2aeba4c960127..d10bfabe38e7b 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stringintconv/string.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/stringintconv/string.go @@ -78,7 +78,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.CallExpr)(nil), } var file *ast.File - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> if n, ok := n.(*ast.File); ok { file = n return diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go index c8388fb41d878..3a97f09eb56cb 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag/structtag.go @@ -40,7 +40,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.StructType)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> styp, ok := pass.TypesInfo.Types[n.(*ast.StructType)].Type.(*types.Struct) // Type information may be incomplete. if !ok { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine/testinggoroutine.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine/testinggoroutine.go index b7d1c1aac7505..260d07a3479d8 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine/testinggoroutine.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/testinggoroutine/testinggoroutine.go @@ -67,7 +67,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.FuncDecl)(nil), (*ast.GoStmt)(nil), (*ast.CallExpr)(nil), - }, func { node, push | + }, func { node, push -> if !push { return false } @@ -91,7 +91,7 @@ func run(pass *analysis.Pass) (interface{}, error) { // // Also considers a special case when r is a go t.Forbidden() call. for _, region := range regions { - ast.Inspect(region, func { n | + ast.Inspect(region, func { n -> if n == region { return true // always descend into the region itself. } else if asyncs[n] != nil { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/tests/tests.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/tests/tests.go index 4882e3dda1f07..fa66481a99b22 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/tests/tests.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/tests/tests.go @@ -96,7 +96,7 @@ func checkFuzz(pass *analysis.Pass, fn *ast.FuncDecl) { // // Returns the list of parameters to the fuzz function, if they are valid fuzz parameters. func checkFuzzCall(pass *analysis.Pass, fn *ast.FuncDecl) (params *types.Tuple) { - ast.Inspect(fn, func { n | + ast.Inspect(fn, func { n -> call, ok := n.(*ast.CallExpr) if ok { if !isFuzzTargetDotFuzz(pass, call) { @@ -133,7 +133,7 @@ func checkFuzzCall(pass *analysis.Pass, fn *ast.FuncDecl) (params *types.Tuple) } // Inspect the function that was passed as an argument to make sure that // there are no calls to *F methods, except for Name and Failed. - ast.Inspect(expr, func { n | + ast.Inspect(expr, func { n -> if call, ok := n.(*ast.CallExpr); ok { if !isFuzzTargetDot(pass, call, "") { return true @@ -156,7 +156,7 @@ func checkFuzzCall(pass *analysis.Pass, fn *ast.FuncDecl) (params *types.Tuple) // checkAddCalls checks that the arguments of f.Add calls have the same number and type of arguments as // the signature of the function passed to (*testing.F).Fuzz func checkAddCalls(pass *analysis.Pass, fn *ast.FuncDecl, params *types.Tuple) { - ast.Inspect(fn, func { n | + ast.Inspect(fn, func { n -> call, ok := n.(*ast.CallExpr) if ok { if !isFuzzTargetDotAdd(pass, call) { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/timeformat/timeformat.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/timeformat/timeformat.go index 9b8e7e8988292..daa78a88e01aa 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/timeformat/timeformat.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/timeformat/timeformat.go @@ -46,7 +46,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.CallExpr)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> call := n.(*ast.CallExpr) fn, ok := typeutil.Callee(pass.TypesInfo, call).(*types.Func) if !ok { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal.go index 8e99530ca9436..4091d9b19028b 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal/unmarshal.go @@ -47,7 +47,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.CallExpr)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> call := n.(*ast.CallExpr) fn := typeutil.StaticCallee(pass.TypesInfo, call) if fn == nil { diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go index 6b12f3cc491c2..2678232a111cc 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable/unreachable.go @@ -37,7 +37,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.FuncDecl)(nil), (*ast.FuncLit)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> var body *ast.BlockStmt switch n := n.(type) { case *ast.FuncDecl: diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go index ddb31a2aead93..268df62657f0b 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr/unsafeptr.go @@ -39,7 +39,7 @@ func run(pass *analysis.Pass) (interface{}, error) { (*ast.StarExpr)(nil), (*ast.UnaryExpr)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> switch x := n.(type) { case *ast.CallExpr: if len(x.Args) == 1 && diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go index dafe7b68f51e0..0c923b313fd63 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/passes/unusedresult/unusedresult.go @@ -100,7 +100,7 @@ func run(pass *analysis.Pass) (interface{}, error) { nodeFilter := []ast.Node{ (*ast.ExprStmt)(nil), } - inspect.Preorder(nodeFilter, func { n | + inspect.Preorder(nodeFilter, func { n -> call, ok := astutil.Unparen(n.(*ast.ExprStmt).X).(*ast.CallExpr) if !ok { return // not a call statement diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go index 58dfb89bce8d5..029873f9f6b30 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/unitchecker/unitchecker.go @@ -194,7 +194,7 @@ type factImporter = func(pkgPath string) ([]byte, error) // The defaults honor a Config in a manner compatible with 'go vet'. var ( makeTypesImporter = func(cfg *Config, fset *token.FileSet) types.Importer { - compilerImporter := importer.ForCompiler(fset, cfg.Compiler, func { path | + compilerImporter := importer.ForCompiler(fset, cfg.Compiler, func { path -> // path is a resolved package path, not an import path. file, ok := cfg.PackageFile[path] if !ok { @@ -205,7 +205,7 @@ var ( } return os.Open(file) }) - return importerFunc(func { importPath | + return importerFunc(func { importPath -> path, ok := cfg.ImportMap[importPath] // resolve vendoring, etc if !ok { return nil, fmt.Errorf("can't resolve import %q", path) @@ -293,7 +293,7 @@ func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]re } actions := make(map[*analysis.Analyzer]*action) var registerFacts func(a *analysis.Analyzer) bool - registerFacts = func { a | + registerFacts = func { a -> act, ok := actions[a] if !ok { act = new(action) @@ -329,7 +329,7 @@ func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]re // In parallel, execute the DAG of analyzers. var exec func(a *analysis.Analyzer) *action var execAll func(analyzers []*analysis.Analyzer) - exec = func { a | + exec = func { a -> act := actions[a] act.once.Do(func() { execAll(a.Requires) // prefetch dependencies in parallel @@ -398,7 +398,7 @@ func run(fset *token.FileSet, cfg *Config, analyzers []*analysis.Analyzer) ([]re }) return act } - execAll = func { analyzers | + execAll = func { analyzers -> var wg sync.WaitGroup for _, a := range analyzers { wg.Add(1) diff --git a/src/cmd/vendor/golang.org/x/tools/go/analysis/validate.go b/src/cmd/vendor/golang.org/x/tools/go/analysis/validate.go index bba6c802b6b4f..e2e6d4584a5fc 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/analysis/validate.go +++ b/src/cmd/vendor/golang.org/x/tools/go/analysis/validate.go @@ -34,7 +34,7 @@ func Validate(analyzers []*Analyzer) error { ) color := make(map[*Analyzer]uint8) var visit func(a *Analyzer) error - visit = func { a | + visit = func { a -> if a == nil { return fmt.Errorf("nil *Analyzer") } diff --git a/src/cmd/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go b/src/cmd/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go index 7c9887a09c0d0..27b707d648389 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go +++ b/src/cmd/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go @@ -62,7 +62,7 @@ func PathEnclosingInterval(root *ast.File, start, end token.Pos) (path []ast.Nod // Precondition: node.[Pos..End) and adjoining whitespace contain [start, end). var visit func(node ast.Node) bool - visit = func { node | + visit = func { node -> path = append(path, node) nodePos := node.Pos() @@ -184,7 +184,7 @@ func childrenOf(n ast.Node) []ast.Node { var children []ast.Node // First add nodes for all true subtrees. - ast.Inspect(n, func { node | + ast.Inspect(n, func { node -> if node == n { // push n return true // recur } diff --git a/src/cmd/vendor/golang.org/x/tools/go/ast/astutil/imports.go b/src/cmd/vendor/golang.org/x/tools/go/ast/astutil/imports.go index 4cb81360812dc..c515c26a96644 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/ast/astutil/imports.go +++ b/src/cmd/vendor/golang.org/x/tools/go/ast/astutil/imports.go @@ -366,7 +366,7 @@ func UsesImport(f *ast.File, path string) (used bool) { return true } - ast.Walk(visitFn(func { n | + ast.Walk(visitFn(func { n -> sel, ok := n.(*ast.SelectorExpr) if ok && isTopName(sel.X, name) { used = true diff --git a/src/cmd/vendor/golang.org/x/tools/go/ast/inspector/inspector.go b/src/cmd/vendor/golang.org/x/tools/go/ast/inspector/inspector.go index 8355064a67756..28ff88de9c0b4 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/ast/inspector/inspector.go +++ b/src/cmd/vendor/golang.org/x/tools/go/ast/inspector/inspector.go @@ -187,7 +187,7 @@ func traverse(files []*ast.File) []event { var stack []event stack = append(stack, event{}) // include an extra event so file nodes have a parent for _, f := range files { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> if n != nil { // push ev := event{ diff --git a/src/cmd/vendor/golang.org/x/tools/go/types/typeutil/imports.go b/src/cmd/vendor/golang.org/x/tools/go/types/typeutil/imports.go index 03b119a86262f..cb36d146e29db 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/types/typeutil/imports.go +++ b/src/cmd/vendor/golang.org/x/tools/go/types/typeutil/imports.go @@ -16,7 +16,7 @@ func Dependencies(pkgs ...*types.Package) []*types.Package { var result []*types.Package seen := make(map[*types.Package]bool) var visit func(pkgs []*types.Package) - visit = func { pkgs | + visit = func { pkgs -> for _, p := range pkgs { if !seen[p] { seen[p] = true diff --git a/src/cmd/vendor/golang.org/x/tools/go/types/typeutil/map.go b/src/cmd/vendor/golang.org/x/tools/go/types/typeutil/map.go index 4e83f8f98b0eb..ddbf72ec8c25c 100644 --- a/src/cmd/vendor/golang.org/x/tools/go/types/typeutil/map.go +++ b/src/cmd/vendor/golang.org/x/tools/go/types/typeutil/map.go @@ -158,7 +158,7 @@ func (m *Map) Iterate(f func(key types.Type, value any)) { // The order is unspecified. func (m *Map) Keys() []types.Type { keys := make([]types.Type, 0, m.Len()) - m.Iterate(func { key, _ | keys = append(keys, key) }) + m.Iterate(func { key, _ -> keys = append(keys, key) }) return keys } @@ -169,7 +169,7 @@ func (m *Map) toString(values bool) string { var buf bytes.Buffer fmt.Fprint(&buf, "{") sep := "" - m.Iterate(func { key, value | + m.Iterate(func { key, value -> fmt.Fprint(&buf, sep) sep = ", " fmt.Fprint(&buf, key) diff --git a/src/cmd/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go b/src/cmd/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go index a99b465b9bd13..289b90a705c5a 100644 --- a/src/cmd/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go +++ b/src/cmd/vendor/golang.org/x/tools/internal/analysisinternal/analysis.go @@ -325,7 +325,7 @@ func MatchingIdents(typs []types.Type, node ast.Node, pos token.Pos, info *types } seen := map[types.Object]struct{}{} - ast.Inspect(node, func { n | + ast.Inspect(node, func { n -> if n == nil { return false } diff --git a/src/cmd/vendor/golang.org/x/tools/internal/facts/facts.go b/src/cmd/vendor/golang.org/x/tools/internal/facts/facts.go index 08ada137be08b..31688aed7cd71 100644 --- a/src/cmd/vendor/golang.org/x/tools/internal/facts/facts.go +++ b/src/cmd/vendor/golang.org/x/tools/internal/facts/facts.go @@ -329,7 +329,7 @@ func (s *Set) Encode() []byte { s.mu.Unlock() // Sort facts by (package, object, type) for determinism. - sort.Slice(gobFacts, func { i, j | + sort.Slice(gobFacts, func { i, j -> x, y := gobFacts[i], gobFacts[j] if x.PkgPath != y.PkgPath { return x.PkgPath < y.PkgPath diff --git a/src/cmd/vendor/golang.org/x/tools/internal/facts/imports.go b/src/cmd/vendor/golang.org/x/tools/internal/facts/imports.go index 52dccb64303e9..4e846401b7ac2 100644 --- a/src/cmd/vendor/golang.org/x/tools/internal/facts/imports.go +++ b/src/cmd/vendor/golang.org/x/tools/internal/facts/imports.go @@ -35,7 +35,7 @@ func importMap(imports []*types.Package) map[string]*types.Package { var addObj func(obj types.Object) var addType func(T types.Type) - addObj = func { obj | + addObj = func { obj -> if !objects[obj] { objects[obj] = true addType(obj.Type()) @@ -45,7 +45,7 @@ func importMap(imports []*types.Package) map[string]*types.Package { } } - addType = func { T | + addType = func { T -> switch T := T.(type) { case *aliases.Alias: addType(aliases.Unalias(T)) diff --git a/src/cmd/vet/vet_test.go b/src/cmd/vet/vet_test.go index 494019739f281..319399f2ca82a 100644 --- a/src/cmd/vet/vet_test.go +++ b/src/cmd/vet/vet_test.go @@ -88,7 +88,7 @@ func TestVet(t *testing.T) { "unused", } { pkg := pkg - t.Run(pkg, func { t | + t.Run(pkg, func { t -> t.Parallel() // Skip cgo test on platforms without cgo. @@ -125,7 +125,7 @@ func TestVet(t *testing.T) { // go.mod file in the rangeloop directory to "downgrade". // // TOOD(adonovan): delete when go1.21 goes away. - t.Run("loopclosure", func { t | + t.Run("loopclosure", func { t -> cmd := testenv.Command(t, testenv.GoToolPath(t), "vet", "-vettool="+vetPath(t), ".") cmd.Env = append(os.Environ(), "GOWORK=off") cmd.Dir = "testdata/rangeloop" @@ -156,7 +156,7 @@ func TestVet(t *testing.T) { // The stdversion analyzer requires a lower-than-tip go // version in its go.mod file for it to report anything. // So again we use a testdata go.mod file to "downgrade". - t.Run("stdversion", func { t | + t.Run("stdversion", func { t -> cmd := testenv.Command(t, testenv.GoToolPath(t), "vet", "-vettool="+vetPath(t), ".") cmd.Env = append(os.Environ(), "GOWORK=off") cmd.Dir = "testdata/stdversion" @@ -221,7 +221,7 @@ func TestTags(t *testing.T) { "othertag": 2, } { tag, wantFile := tag, wantFile - t.Run(tag, func { t | + t.Run(tag, func { t -> t.Parallel() t.Logf("-tags=%s", tag) cmd := vetCmd(t, "-tags="+tag, "tagtest") @@ -423,7 +423,7 @@ func wantedErrors(file, short string) (errs []wantedError) { } for _, m := range mm { replacedOnce := false - rx := lineRx.ReplaceAllStringFunc(m[1], func { m | + rx := lineRx.ReplaceAllStringFunc(m[1], func { m -> if replacedOnce { return m } diff --git a/src/cmp/cmp_test.go b/src/cmp/cmp_test.go index c439fb3a92cca..8b06ed2caf798 100644 --- a/src/cmp/cmp_test.go +++ b/src/cmp/cmp_test.go @@ -157,7 +157,7 @@ func ExampleOr_sort() { {"foo", "bob", 4.00}, } // Sort by customer first, product second, and last by higher price - slices.SortFunc(orders, func { a, b | + slices.SortFunc(orders, func { a, b -> return cmp.Or( strings.Compare(a.Customer, b.Customer), strings.Compare(a.Product, b.Product), diff --git a/src/compress/bzip2/huffman.go b/src/compress/bzip2/huffman.go index 9aec69c1eba47..cf34f14ea2c27 100644 --- a/src/compress/bzip2/huffman.go +++ b/src/compress/bzip2/huffman.go @@ -103,7 +103,7 @@ func newHuffmanTree(lengths []uint8) (huffmanTree, error) { pairs[i].length = length } - slices.SortFunc(pairs, func { a, b | + slices.SortFunc(pairs, func { a, b -> if c := cmp.Compare(a.length, b.length); c != 0 { return c } @@ -132,7 +132,7 @@ func newHuffmanTree(lengths []uint8) (huffmanTree, error) { // Now we can sort by the code so that the left half of each branch are // grouped together, recursively. - slices.SortFunc(codes, func { a, b | return cmp.Compare(a.code, b.code) }) + slices.SortFunc(codes, func { a, b -> return cmp.Compare(a.code, b.code) }) t.nodes = make([]huffmanNode, len(codes)) _, err := buildHuffmanNode(&t, codes, 0) diff --git a/src/compress/flate/deflate_test.go b/src/compress/flate/deflate_test.go index a2e8e19ca6e8b..2515deabec8c7 100644 --- a/src/compress/flate/deflate_test.go +++ b/src/compress/flate/deflate_test.go @@ -550,12 +550,12 @@ func TestWriterReset(t *testing.T) { levels := []int{0, 1, 2, 5, 9} for _, level := range levels { - t.Run(fmt.Sprint(level), func { t | testResetOutput(t, level, nil) }) + t.Run(fmt.Sprint(level), func { t -> testResetOutput(t, level, nil) }) } - t.Run("dict", func { t | + t.Run("dict", func { t -> for _, level := range levels { - t.Run(fmt.Sprint(level), func { t | testResetOutput(t, level, nil) }) + t.Run(fmt.Sprint(level), func { t -> testResetOutput(t, level, nil) }) } }) } diff --git a/src/compress/flate/inflate_test.go b/src/compress/flate/inflate_test.go index f15e5dbb51f2e..d2335575fb7f0 100644 --- a/src/compress/flate/inflate_test.go +++ b/src/compress/flate/inflate_test.go @@ -101,7 +101,7 @@ func TestReaderReusesReaderBuffer(t *testing.T) { encodedReader := bytes.NewReader([]byte{}) encodedNotByteReader := struct{ io.Reader }{encodedReader} - t.Run("BufferIsReused", func { t | + t.Run("BufferIsReused", func { t -> f := NewReader(encodedNotByteReader).(*decompressor) bufioR, ok := f.r.(*bufio.Reader) if !ok { @@ -112,7 +112,7 @@ func TestReaderReusesReaderBuffer(t *testing.T) { t.Fatalf("bufio.Reader was not reused") } }) - t.Run("BufferIsNotReusedWhenGotByteReader", func { t | + t.Run("BufferIsNotReusedWhenGotByteReader", func { t -> f := NewReader(encodedNotByteReader).(*decompressor) if _, ok := f.r.(*bufio.Reader); !ok { t.Fatalf("bufio.Reader should be created") @@ -122,7 +122,7 @@ func TestReaderReusesReaderBuffer(t *testing.T) { t.Fatalf("provided io.ByteReader should be used directly") } }) - t.Run("BufferIsCreatedAfterByteReader", func { t | + t.Run("BufferIsCreatedAfterByteReader", func { t -> for i, r := range []io.Reader{encodedReader, bufio.NewReader(encodedReader)} { f := NewReader(r).(*decompressor) if f.r != r { diff --git a/src/compress/flate/reader_test.go b/src/compress/flate/reader_test.go index 1b32fc4dc9af0..e43c32af396ed 100644 --- a/src/compress/flate/reader_test.go +++ b/src/compress/flate/reader_test.go @@ -32,7 +32,7 @@ var suites = []struct{ name, file string }{ } func BenchmarkDecode(b *testing.B) { - doBench(b, func { b, buf0, level, n | + doBench(b, func { b, buf0, level, n -> b.ReportAllocs() b.StopTimer() b.SetBytes(int64(n)) @@ -89,7 +89,7 @@ func doBench(b *testing.B, f func(b *testing.B, buf []byte, level, n int)) { } for _, l := range levelTests { for _, s := range sizes { - b.Run(suite.name+"/"+l.name+"/"+s.name, func { b | f(b, buf, l.level, s.n) }) + b.Run(suite.name+"/"+l.name+"/"+s.name, func { b -> f(b, buf, l.level, s.n) }) } } } diff --git a/src/compress/flate/writer_test.go b/src/compress/flate/writer_test.go index 78383263a15a8..22082ef2c0066 100644 --- a/src/compress/flate/writer_test.go +++ b/src/compress/flate/writer_test.go @@ -14,7 +14,7 @@ import ( ) func BenchmarkEncode(b *testing.B) { - doBench(b, func { b, buf0, level, n | + doBench(b, func { b, buf0, level, n -> b.StopTimer() b.SetBytes(int64(n)) @@ -115,9 +115,9 @@ func TestWriteError(t *testing.T) { func TestDeterministic(t *testing.T) { t.Parallel() for i := 0; i <= 9; i++ { - t.Run(fmt.Sprint("L", i), func { t | testDeterministic(i, t) }) + t.Run(fmt.Sprint("L", i), func { t -> testDeterministic(i, t) }) } - t.Run("LM2", func { t | testDeterministic(-2, t) }) + t.Run("LM2", func { t -> testDeterministic(-2, t) }) } func testDeterministic(i int, t *testing.T) { diff --git a/src/compress/gzip/example_test.go b/src/compress/gzip/example_test.go index a41fb0f847ca8..74b1c35fd4a07 100644 --- a/src/compress/gzip/example_test.go +++ b/src/compress/gzip/example_test.go @@ -137,7 +137,7 @@ func Example_compressingReader() { const testdata = "the data to be compressed" // This HTTP handler is just for testing purposes. - handler := http.HandlerFunc(func { rw, req | + handler := http.HandlerFunc(func { rw, req -> zr, err := gzip.NewReader(req.Body) if err != nil { log.Fatal(err) diff --git a/src/compress/gzip/fuzz_test.go b/src/compress/gzip/fuzz_test.go index 7234b8feafd63..41a6bc8910626 100644 --- a/src/compress/gzip/fuzz_test.go +++ b/src/compress/gzip/fuzz_test.go @@ -53,7 +53,7 @@ func FuzzReader(f *testing.F) { f.Add(b) } - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> for _, multistream := range []bool{true, false} { r, err := NewReader(bytes.NewBuffer(b)) if err != nil { diff --git a/src/compress/gzip/issue14937_test.go b/src/compress/gzip/issue14937_test.go index 5d1de852fca2c..2bd91569e9615 100644 --- a/src/compress/gzip/issue14937_test.go +++ b/src/compress/gzip/issue14937_test.go @@ -39,7 +39,7 @@ func TestGZIPFilesHaveZeroMTimes(t *testing.T) { t.Fatal("error evaluating GOROOT: ", err) } var files []string - err = filepath.WalkDir(goroot, func { path, info, err | + err = filepath.WalkDir(goroot, func { path, info, err -> if err != nil { return err } diff --git a/src/compress/lzw/reader_test.go b/src/compress/lzw/reader_test.go index a81f355fb8a21..41175a466895c 100644 --- a/src/compress/lzw/reader_test.go +++ b/src/compress/lzw/reader_test.go @@ -286,7 +286,7 @@ func BenchmarkDecoder(b *testing.B) { for e := 4; e <= 6; e++ { n := int(math.Pow10(e)) - b.Run(fmt.Sprint("1e", e), func { b | + b.Run(fmt.Sprint("1e", e), func { b -> b.StopTimer() b.SetBytes(int64(n)) buf1 := getInputBuf(buf, n) @@ -296,7 +296,7 @@ func BenchmarkDecoder(b *testing.B) { io.Copy(io.Discard, NewReader(bytes.NewReader(buf1), LSB, 8)) } }) - b.Run(fmt.Sprint("1e-Reuse", e), func { b | + b.Run(fmt.Sprint("1e-Reuse", e), func { b -> b.StopTimer() b.SetBytes(int64(n)) buf1 := getInputBuf(buf, n) diff --git a/src/compress/lzw/writer_test.go b/src/compress/lzw/writer_test.go index c5424185e74fe..e232391bf64b5 100644 --- a/src/compress/lzw/writer_test.go +++ b/src/compress/lzw/writer_test.go @@ -108,9 +108,9 @@ func TestWriter(t *testing.T) { func TestWriterReset(t *testing.T) { for _, order := range [...]Order{LSB, MSB} { - t.Run(fmt.Sprintf("Order %d", order), func { t | + t.Run(fmt.Sprintf("Order %d", order), func { t -> for litWidth := 6; litWidth <= 8; litWidth++ { - t.Run(fmt.Sprintf("LitWidth %d", litWidth), func { t | + t.Run(fmt.Sprintf("LitWidth %d", litWidth), func { t -> var data []byte if litWidth == 6 { data = []byte{1, 2, 3} @@ -217,7 +217,7 @@ func BenchmarkEncoder(b *testing.B) { } buf0 = nil runtime.GC() - b.Run(fmt.Sprint("1e", e), func { b | + b.Run(fmt.Sprint("1e", e), func { b -> b.SetBytes(int64(n)) for i := 0; i < b.N; i++ { w := NewWriter(io.Discard, LSB, 8) @@ -225,7 +225,7 @@ func BenchmarkEncoder(b *testing.B) { w.Close() } }) - b.Run(fmt.Sprint("1e-Reuse", e), func { b | + b.Run(fmt.Sprint("1e-Reuse", e), func { b -> b.SetBytes(int64(n)) w := NewWriter(io.Discard, LSB, 8) for i := 0; i < b.N; i++ { diff --git a/src/container/ring/example_test.go b/src/container/ring/example_test.go index 222cc5ae6a176..5a198aa7b3c77 100644 --- a/src/container/ring/example_test.go +++ b/src/container/ring/example_test.go @@ -88,7 +88,7 @@ func ExampleRing_Do() { } // Iterate through the ring and print its contents - r.Do(func { p | fmt.Println(p.(int)) }) + r.Do(func { p -> fmt.Println(p.(int)) }) // Output: // 0 @@ -115,7 +115,7 @@ func ExampleRing_Move() { r = r.Move(3) // Iterate through the ring and print its contents - r.Do(func { p | fmt.Println(p.(int)) }) + r.Do(func { p -> fmt.Println(p.(int)) }) // Output: // 3 @@ -150,7 +150,7 @@ func ExampleRing_Link() { rs := r.Link(s) // Iterate through the combined ring and print its contents - rs.Do(func { p | fmt.Println(p.(int)) }) + rs.Do(func { p -> fmt.Println(p.(int)) }) // Output: // 0 @@ -176,7 +176,7 @@ func ExampleRing_Unlink() { r.Unlink(3) // Iterate through the remaining ring and print its contents - r.Do(func { p | fmt.Println(p.(int)) }) + r.Do(func { p -> fmt.Println(p.(int)) }) // Output: // 0 diff --git a/src/container/ring/ring_test.go b/src/container/ring/ring_test.go index a5faa6de84890..82263882f35ac 100644 --- a/src/container/ring/ring_test.go +++ b/src/container/ring/ring_test.go @@ -33,7 +33,7 @@ func verify(t *testing.T, r *Ring, N int, sum int) { // iteration n = 0 s := 0 - r.Do(func { p | + r.Do(func { p -> n++ if p != nil { s += p.(int) diff --git a/src/context/benchmark_test.go b/src/context/benchmark_test.go index 17ca1f8063cef..71373ec217652 100644 --- a/src/context/benchmark_test.go +++ b/src/context/benchmark_test.go @@ -19,7 +19,7 @@ func BenchmarkCommonParentCancel(b *testing.B) { defer sharedcancel() b.ResetTimer() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> x := 0 for pb.Next() { ctx, cancel := WithCancel(shared) @@ -40,7 +40,7 @@ func BenchmarkCommonParentCancel(b *testing.B) { func BenchmarkWithTimeout(b *testing.B) { for concurrency := 40; concurrency <= 4e5; concurrency *= 100 { name := fmt.Sprintf("concurrency=%d", concurrency) - b.Run(name, func { b | benchmarkWithTimeout(b, concurrency) }) + b.Run(name, func { b -> benchmarkWithTimeout(b, concurrency) }) } } @@ -66,7 +66,7 @@ func benchmarkWithTimeout(b *testing.B, concurrentContexts int) { wg.Wait() b.ResetTimer() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> wcf := make([]CancelFunc, 10) for pb.Next() { for i := range wcf { @@ -89,18 +89,18 @@ func benchmarkWithTimeout(b *testing.B, concurrentContexts int) { func BenchmarkCancelTree(b *testing.B) { depths := []int{1, 10, 100, 1000} for _, d := range depths { - b.Run(fmt.Sprintf("depth=%d", d), func { b | - b.Run("Root=Background", func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("depth=%d", d), func { b -> + b.Run("Root=Background", func { b -> for i := 0; i < b.N; i++ { buildContextTree(Background(), d) } }) - b.Run("Root=OpenCanceler", func { b | + b.Run("Root=OpenCanceler", func { b -> for i := 0; i < b.N; i++ { ctx, cancel := WithCancel(Background()) buildContextTree(ctx, d) cancel() } }) - b.Run("Root=ClosedCanceler", func { b | + b.Run("Root=ClosedCanceler", func { b -> for i := 0; i < b.N; i++ { ctx, cancel := WithCancel(Background()) cancel() @@ -120,10 +120,10 @@ func buildContextTree(root Context, depth int) { func BenchmarkCheckCanceled(b *testing.B) { ctx, cancel := WithCancel(Background()) cancel() - b.Run("Err", func { b | for i := 0; i < b.N; i++ { + b.Run("Err", func { b -> for i := 0; i < b.N; i++ { ctx.Err() } }) - b.Run("Done", func { b | for i := 0; i < b.N; i++ { + b.Run("Done", func { b -> for i := 0; i < b.N; i++ { select { case <-ctx.Done(): default: @@ -135,7 +135,7 @@ func BenchmarkContextCancelDone(b *testing.B) { ctx, cancel := WithCancel(Background()) defer cancel() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { select { case <-ctx.Done(): default: @@ -150,7 +150,7 @@ func BenchmarkDeepValueNewGoRoutine(b *testing.B) { ctx = WithValue(ctx, i, i) } - b.Run(fmt.Sprintf("depth=%d", depth), func { b | + b.Run(fmt.Sprintf("depth=%d", depth), func { b -> for i := 0; i < b.N; i++ { var wg sync.WaitGroup wg.Add(1) @@ -171,7 +171,7 @@ func BenchmarkDeepValueSameGoRoutine(b *testing.B) { ctx = WithValue(ctx, i, i) } - b.Run(fmt.Sprintf("depth=%d", depth), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("depth=%d", depth), func { b -> for i := 0; i < b.N; i++ { ctx.Value(-1) } }) } diff --git a/src/context/x_test.go b/src/context/x_test.go index 2ac93af7e3460..b935945f147bb 100644 --- a/src/context/x_test.go +++ b/src/context/x_test.go @@ -796,7 +796,7 @@ func TestCause(t *testing.T) { }, } { test := test - t.Run(test.name, func { t | + t.Run(test.name, func { t -> t.Parallel() ctx := test.ctx() if got, want := ctx.Err(), test.err; want != got { diff --git a/src/crypto/aes/aes_test.go b/src/crypto/aes/aes_test.go index f505426cc3682..f6804251f3949 100644 --- a/src/crypto/aes/aes_test.go +++ b/src/crypto/aes/aes_test.go @@ -345,9 +345,9 @@ func mustPanic(t *testing.T, msg string, f func()) { } func BenchmarkEncrypt(b *testing.B) { - b.Run("AES-128", func { b | benchmarkEncrypt(b, encryptTests[1]) }) - b.Run("AES-192", func { b | benchmarkEncrypt(b, encryptTests[2]) }) - b.Run("AES-256", func { b | benchmarkEncrypt(b, encryptTests[3]) }) + b.Run("AES-128", func { b -> benchmarkEncrypt(b, encryptTests[1]) }) + b.Run("AES-192", func { b -> benchmarkEncrypt(b, encryptTests[2]) }) + b.Run("AES-256", func { b -> benchmarkEncrypt(b, encryptTests[3]) }) } func benchmarkEncrypt(b *testing.B, tt CryptTest) { @@ -364,9 +364,9 @@ func benchmarkEncrypt(b *testing.B, tt CryptTest) { } func BenchmarkDecrypt(b *testing.B) { - b.Run("AES-128", func { b | benchmarkDecrypt(b, encryptTests[1]) }) - b.Run("AES-192", func { b | benchmarkDecrypt(b, encryptTests[2]) }) - b.Run("AES-256", func { b | benchmarkDecrypt(b, encryptTests[3]) }) + b.Run("AES-128", func { b -> benchmarkDecrypt(b, encryptTests[1]) }) + b.Run("AES-192", func { b -> benchmarkDecrypt(b, encryptTests[2]) }) + b.Run("AES-256", func { b -> benchmarkDecrypt(b, encryptTests[3]) }) } func benchmarkDecrypt(b *testing.B, tt CryptTest) { @@ -383,9 +383,9 @@ func benchmarkDecrypt(b *testing.B, tt CryptTest) { } func BenchmarkExpand(b *testing.B) { - b.Run("AES-128", func { b | benchmarkExpand(b, encryptTests[1]) }) - b.Run("AES-192", func { b | benchmarkExpand(b, encryptTests[2]) }) - b.Run("AES-256", func { b | benchmarkExpand(b, encryptTests[3]) }) + b.Run("AES-128", func { b -> benchmarkExpand(b, encryptTests[1]) }) + b.Run("AES-192", func { b -> benchmarkExpand(b, encryptTests[2]) }) + b.Run("AES-256", func { b -> benchmarkExpand(b, encryptTests[3]) }) } func benchmarkExpand(b *testing.B, tt CryptTest) { @@ -397,9 +397,9 @@ func benchmarkExpand(b *testing.B, tt CryptTest) { } func BenchmarkCreateCipher(b *testing.B) { - b.Run("AES-128", func { b | benchmarkCreateCipher(b, encryptTests[1]) }) - b.Run("AES-192", func { b | benchmarkCreateCipher(b, encryptTests[2]) }) - b.Run("AES-256", func { b | benchmarkCreateCipher(b, encryptTests[3]) }) + b.Run("AES-128", func { b -> benchmarkCreateCipher(b, encryptTests[1]) }) + b.Run("AES-192", func { b -> benchmarkCreateCipher(b, encryptTests[2]) }) + b.Run("AES-256", func { b -> benchmarkCreateCipher(b, encryptTests[3]) }) } func benchmarkCreateCipher(b *testing.B, tt CryptTest) { diff --git a/src/crypto/cipher/benchmark_test.go b/src/crypto/cipher/benchmark_test.go index acd44f4cc48bf..f0d30ae855a25 100644 --- a/src/crypto/cipher/benchmark_test.go +++ b/src/crypto/cipher/benchmark_test.go @@ -49,11 +49,11 @@ func benchmarkAESGCMOpen(b *testing.B, buf []byte, keySize int) { func BenchmarkAESGCM(b *testing.B) { for _, length := range []int{64, 1350, 8 * 1024} { - b.Run("Open-128-"+strconv.Itoa(length), func { b | benchmarkAESGCMOpen(b, make([]byte, length), 128/8) }) - b.Run("Seal-128-"+strconv.Itoa(length), func { b | benchmarkAESGCMSeal(b, make([]byte, length), 128/8) }) + b.Run("Open-128-"+strconv.Itoa(length), func { b -> benchmarkAESGCMOpen(b, make([]byte, length), 128/8) }) + b.Run("Seal-128-"+strconv.Itoa(length), func { b -> benchmarkAESGCMSeal(b, make([]byte, length), 128/8) }) - b.Run("Open-256-"+strconv.Itoa(length), func { b | benchmarkAESGCMOpen(b, make([]byte, length), 256/8) }) - b.Run("Seal-256-"+strconv.Itoa(length), func { b | benchmarkAESGCMSeal(b, make([]byte, length), 256/8) }) + b.Run("Open-256-"+strconv.Itoa(length), func { b -> benchmarkAESGCMOpen(b, make([]byte, length), 256/8) }) + b.Run("Seal-256-"+strconv.Itoa(length), func { b -> benchmarkAESGCMSeal(b, make([]byte, length), 256/8) }) } } diff --git a/src/crypto/ecdh/ecdh_test.go b/src/crypto/ecdh/ecdh_test.go index 17a75d6bf399f..3a6517ed564a7 100644 --- a/src/crypto/ecdh/ecdh_test.go +++ b/src/crypto/ecdh/ecdh_test.go @@ -36,7 +36,7 @@ var _ interface { } = &ecdh.PrivateKey{} func TestECDH(t *testing.T) { - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> aliceKey, err := curve.GenerateKey(rand.Reader) if err != nil { t.Fatal(err) @@ -95,7 +95,7 @@ func (r *countingReader) Read(p []byte) (int, error) { } func TestGenerateKey(t *testing.T) { - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> r := &countingReader{r: rand.Reader} k, err := curve.GenerateKey(r) if err != nil { @@ -156,7 +156,7 @@ var vectors = map[ecdh.Curve]struct { } func TestVectors(t *testing.T) { - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> v := vectors[curve] key, err := curve.NewPrivateKey(hexDecode(t, v.PrivateKey)) if err != nil { @@ -189,7 +189,7 @@ func hexDecode(t *testing.T, s string) []byte { } func TestString(t *testing.T) { - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> s := fmt.Sprintf("%s", curve) if s[:1] != "P" && s[:1] != "X" { t.Errorf("unexpected Curve string encoding: %q", s) @@ -203,8 +203,8 @@ func TestX25519Failure(t *testing.T) { randomScalar := make([]byte, 32) rand.Read(randomScalar) - t.Run("identity point", func { t | testX25519Failure(t, randomScalar, identity) }) - t.Run("low order point", func { t | testX25519Failure(t, randomScalar, lowOrderPoint) }) + t.Run("identity point", func { t -> testX25519Failure(t, randomScalar, identity) }) + t.Run("low order point", func { t -> testX25519Failure(t, randomScalar, lowOrderPoint) }) } func testX25519Failure(t *testing.T, private, public []byte) { @@ -280,7 +280,7 @@ var invalidPrivateKeys = map[ecdh.Curve][]string{ } func TestNewPrivateKey(t *testing.T) { - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> for _, input := range invalidPrivateKeys[curve] { k, err := curve.NewPrivateKey(hexDecode(t, input)) if err == nil { @@ -341,7 +341,7 @@ var invalidPublicKeys = map[ecdh.Curve][]string{ } func TestNewPublicKey(t *testing.T) { - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> for _, input := range invalidPublicKeys[curve] { k, err := curve.NewPublicKey(hexDecode(t, input)) if err == nil { @@ -356,14 +356,14 @@ func TestNewPublicKey(t *testing.T) { } func testAllCurves(t *testing.T, f func(t *testing.T, curve ecdh.Curve)) { - t.Run("P256", func { t | f(t, ecdh.P256()) }) - t.Run("P384", func { t | f(t, ecdh.P384()) }) - t.Run("P521", func { t | f(t, ecdh.P521()) }) - t.Run("X25519", func { t | f(t, ecdh.X25519()) }) + t.Run("P256", func { t -> f(t, ecdh.P256()) }) + t.Run("P384", func { t -> f(t, ecdh.P384()) }) + t.Run("P521", func { t -> f(t, ecdh.P521()) }) + t.Run("X25519", func { t -> f(t, ecdh.X25519()) }) } func BenchmarkECDH(b *testing.B) { - benchmarkAllCurves(b, func { b, curve | + benchmarkAllCurves(b, func { b, curve -> c, err := chacha20.NewUnauthenticatedCipher(make([]byte, 32), make([]byte, 12)) if err != nil { b.Fatal(err) @@ -402,10 +402,10 @@ func BenchmarkECDH(b *testing.B) { } func benchmarkAllCurves(b *testing.B, f func(b *testing.B, curve ecdh.Curve)) { - b.Run("P256", func { b | f(b, ecdh.P256()) }) - b.Run("P384", func { b | f(b, ecdh.P384()) }) - b.Run("P521", func { b | f(b, ecdh.P521()) }) - b.Run("X25519", func { b | f(b, ecdh.X25519()) }) + b.Run("P256", func { b -> f(b, ecdh.P256()) }) + b.Run("P384", func { b -> f(b, ecdh.P384()) }) + b.Run("P521", func { b -> f(b, ecdh.P521()) }) + b.Run("X25519", func { b -> f(b, ecdh.X25519()) }) } type zr struct{} @@ -507,7 +507,7 @@ func TestMismatchedCurves(t *testing.T) { if privCurve == pubCurve { continue } - t.Run(fmt.Sprintf("%s/%s", privCurve.name, pubCurve.name), func { t | + t.Run(fmt.Sprintf("%s/%s", privCurve.name, pubCurve.name), func { t -> pub, err := pubCurve.curve.GenerateKey(rand.Reader) if err != nil { t.Fatalf("failed to generate test key: %s", err) diff --git a/src/crypto/ecdsa/ecdsa.go b/src/crypto/ecdsa/ecdsa.go index 59df1346eff79..2f7921e5d5b75 100644 --- a/src/crypto/ecdsa/ecdsa.go +++ b/src/crypto/ecdsa/ecdsa.go @@ -341,7 +341,7 @@ func signNISTEC[Point nistPoint[Point]](c *nistCurve[Point], priv *PrivateKey, c func encodeSignature(r, s []byte) ([]byte, error) { var b cryptobyte.Builder - b.AddASN1(asn1.SEQUENCE, func { b | + b.AddASN1(asn1.SEQUENCE, func { b -> addASN1IntBytes(b, r) addASN1IntBytes(b, s) }) @@ -358,7 +358,7 @@ func addASN1IntBytes(b *cryptobyte.Builder, bytes []byte) { b.SetError(errors.New("invalid integer")) return } - b.AddASN1(asn1.INTEGER, func { c | + b.AddASN1(asn1.INTEGER, func { c -> if bytes[0]&0x80 != 0 { c.AddUint8(0) } diff --git a/src/crypto/ecdsa/ecdsa_s390x_test.go b/src/crypto/ecdsa/ecdsa_s390x_test.go index 6c5f06ff683a9..1b7676c2b6cdb 100644 --- a/src/crypto/ecdsa/ecdsa_s390x_test.go +++ b/src/crypto/ecdsa/ecdsa_s390x_test.go @@ -23,10 +23,10 @@ func TestNoAsm(t *testing.T) { for _, curve := range curves { name := curve.Params().Name - t.Run(name, func { t | testKeyGeneration(t, curve) }) - t.Run(name, func { t | testSignAndVerify(t, curve) }) - t.Run(name, func { t | testNonceSafety(t, curve) }) - t.Run(name, func { t | testINDCCA(t, curve) }) - t.Run(name, func { t | testNegativeInputs(t, curve) }) + t.Run(name, func { t -> testKeyGeneration(t, curve) }) + t.Run(name, func { t -> testSignAndVerify(t, curve) }) + t.Run(name, func { t -> testNonceSafety(t, curve) }) + t.Run(name, func { t -> testINDCCA(t, curve) }) + t.Run(name, func { t -> testNegativeInputs(t, curve) }) } } diff --git a/src/crypto/ecdsa/ecdsa_test.go b/src/crypto/ecdsa/ecdsa_test.go index 73dc145827a50..56fe97a651ddf 100644 --- a/src/crypto/ecdsa/ecdsa_test.go +++ b/src/crypto/ecdsa/ecdsa_test.go @@ -39,7 +39,7 @@ func testAllCurves(t *testing.T, f func(*testing.T, elliptic.Curve)) { } for _, test := range tests { curve := test.curve - t.Run(test.name, func { t | + t.Run(test.name, func { t -> t.Parallel() f(t, curve) }) @@ -340,10 +340,10 @@ func testZeroHashSignature(t *testing.T, curve elliptic.Curve) { } func TestRandomPoint(t *testing.T) { - t.Run("P-224", func { t | testRandomPoint(t, p224()) }) - t.Run("P-256", func { t | testRandomPoint(t, p256()) }) - t.Run("P-384", func { t | testRandomPoint(t, p384()) }) - t.Run("P-521", func { t | testRandomPoint(t, p521()) }) + t.Run("P-224", func { t -> testRandomPoint(t, p224()) }) + t.Run("P-256", func { t -> testRandomPoint(t, p256()) }) + t.Run("P-384", func { t -> testRandomPoint(t, p384()) }) + t.Run("P-521", func { t -> testRandomPoint(t, p521()) }) } func testRandomPoint[Point nistPoint[Point]](t *testing.T, c *nistCurve[Point]) { @@ -400,10 +400,10 @@ func testRandomPoint[Point nistPoint[Point]](t *testing.T, c *nistCurve[Point]) } func TestHashToNat(t *testing.T) { - t.Run("P-224", func { t | testHashToNat(t, p224()) }) - t.Run("P-256", func { t | testHashToNat(t, p256()) }) - t.Run("P-384", func { t | testHashToNat(t, p384()) }) - t.Run("P-521", func { t | testHashToNat(t, p521()) }) + t.Run("P-224", func { t -> testHashToNat(t, p224()) }) + t.Run("P-256", func { t -> testHashToNat(t, p256()) }) + t.Run("P-384", func { t -> testHashToNat(t, p384()) }) + t.Run("P-521", func { t -> testHashToNat(t, p521()) }) } func testHashToNat[Point nistPoint[Point]](t *testing.T, c *nistCurve[Point]) { @@ -524,12 +524,12 @@ func benchmarkAllCurves(b *testing.B, f func(*testing.B, elliptic.Curve)) { } for _, test := range tests { curve := test.curve - b.Run(test.name, func { b | f(b, curve) }) + b.Run(test.name, func { b -> f(b, curve) }) } } func BenchmarkSign(b *testing.B) { - benchmarkAllCurves(b, func { b, curve | + benchmarkAllCurves(b, func { b, curve -> r := bufio.NewReaderSize(rand.Reader, 1<<15) priv, err := GenerateKey(curve, r) if err != nil { @@ -551,7 +551,7 @@ func BenchmarkSign(b *testing.B) { } func BenchmarkVerify(b *testing.B) { - benchmarkAllCurves(b, func { b, curve | + benchmarkAllCurves(b, func { b, curve -> r := bufio.NewReaderSize(rand.Reader, 1<<15) priv, err := GenerateKey(curve, r) if err != nil { @@ -574,7 +574,7 @@ func BenchmarkVerify(b *testing.B) { } func BenchmarkGenerateKey(b *testing.B) { - benchmarkAllCurves(b, func { b, curve | + benchmarkAllCurves(b, func { b, curve -> r := bufio.NewReaderSize(rand.Reader, 1<<15) b.ReportAllocs() b.ResetTimer() diff --git a/src/crypto/ecdsa/equal_test.go b/src/crypto/ecdsa/equal_test.go index 310d2f7588948..d0d19bf00c428 100644 --- a/src/crypto/ecdsa/equal_test.go +++ b/src/crypto/ecdsa/equal_test.go @@ -65,11 +65,11 @@ func testEqual(t *testing.T, c elliptic.Curve) { } func TestEqual(t *testing.T) { - t.Run("P224", func { t | testEqual(t, elliptic.P224()) }) + t.Run("P224", func { t -> testEqual(t, elliptic.P224()) }) if testing.Short() { return } - t.Run("P256", func { t | testEqual(t, elliptic.P256()) }) - t.Run("P384", func { t | testEqual(t, elliptic.P384()) }) - t.Run("P521", func { t | testEqual(t, elliptic.P521()) }) + t.Run("P256", func { t -> testEqual(t, elliptic.P256()) }) + t.Run("P384", func { t -> testEqual(t, elliptic.P384()) }) + t.Run("P521", func { t -> testEqual(t, elliptic.P521()) }) } diff --git a/src/crypto/elliptic/elliptic_test.go b/src/crypto/elliptic/elliptic_test.go index 826bc9cb4c84c..89ac5ed753539 100644 --- a/src/crypto/elliptic/elliptic_test.go +++ b/src/crypto/elliptic/elliptic_test.go @@ -40,7 +40,7 @@ func testAllCurves(t *testing.T, f func(*testing.T, Curve)) { } for _, test := range tests { curve := test.curve - t.Run(test.name, func { t | + t.Run(test.name, func { t -> t.Parallel() f(t, curve) }) @@ -49,7 +49,7 @@ func testAllCurves(t *testing.T, f func(*testing.T, Curve)) { func TestOnCurve(t *testing.T) { t.Parallel() - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> if !curve.IsOnCurve(curve.Params().Gx, curve.Params().Gy) { t.Error("basepoint is not on the curve") } @@ -58,7 +58,7 @@ func TestOnCurve(t *testing.T) { func TestOffCurve(t *testing.T) { t.Parallel() - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> x, y := new(big.Int).SetInt64(1), new(big.Int).SetInt64(1) if curve.IsOnCurve(x, y) { t.Errorf("point off curve is claimed to be on the curve") @@ -154,7 +154,7 @@ func testInfinity(t *testing.T, curve Curve) { func TestMarshal(t *testing.T) { t.Parallel() - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> _, x, y, err := GenerateKey(curve, rand.Reader) if err != nil { t.Fatal(err) @@ -275,20 +275,20 @@ func testInvalidCoordinates(t *testing.T, curve Curve) { func TestMarshalCompressed(t *testing.T) { t.Parallel() - t.Run("P-256/03", func { t | + t.Run("P-256/03", func { t -> data, _ := hex.DecodeString("031e3987d9f9ea9d7dd7155a56a86b2009e1e0ab332f962d10d8beb6406ab1ad79") x, _ := new(big.Int).SetString("13671033352574878777044637384712060483119675368076128232297328793087057702265", 10) y, _ := new(big.Int).SetString("66200849279091436748794323380043701364391950689352563629885086590854940586447", 10) testMarshalCompressed(t, P256(), x, y, data) }) - t.Run("P-256/02", func { t | + t.Run("P-256/02", func { t -> data, _ := hex.DecodeString("021e3987d9f9ea9d7dd7155a56a86b2009e1e0ab332f962d10d8beb6406ab1ad79") x, _ := new(big.Int).SetString("13671033352574878777044637384712060483119675368076128232297328793087057702265", 10) y, _ := new(big.Int).SetString("49591239931264812013903123569363872165694192725937750565648544718012157267504", 10) testMarshalCompressed(t, P256(), x, y, data) }) - t.Run("Invalid", func { t | + t.Run("Invalid", func { t -> data, _ := hex.DecodeString("02fd4bf61763b46581fd9174d623516cf3c81edd40e29ffa2777fb6cb0ae3ce535") X, Y := UnmarshalCompressed(P256(), data) if X != nil || Y != nil { @@ -300,7 +300,7 @@ func TestMarshalCompressed(t *testing.T) { t.Skip("skipping other curves on short test") } - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> _, x, y, err := GenerateKey(curve, rand.Reader) if err != nil { t.Fatal(err) @@ -334,7 +334,7 @@ func testMarshalCompressed(t *testing.T, curve Curve, x, y *big.Int, want []byte func TestLargeIsOnCurve(t *testing.T) { t.Parallel() - testAllCurves(t, func { t, curve | + testAllCurves(t, func { t, curve -> large := big.NewInt(1) large.Lsh(large, 1000) if curve.IsOnCurve(large, large) { @@ -355,12 +355,12 @@ func benchmarkAllCurves(b *testing.B, f func(*testing.B, Curve)) { } for _, test := range tests { curve := test.curve - b.Run(test.name, func { b | f(b, curve) }) + b.Run(test.name, func { b -> f(b, curve) }) } } func BenchmarkScalarBaseMult(b *testing.B) { - benchmarkAllCurves(b, func { b, curve | + benchmarkAllCurves(b, func { b, curve -> priv, _, _, _ := GenerateKey(curve, rand.Reader) b.ReportAllocs() b.ResetTimer() @@ -373,7 +373,7 @@ func BenchmarkScalarBaseMult(b *testing.B) { } func BenchmarkScalarMult(b *testing.B) { - benchmarkAllCurves(b, func { b, curve | + benchmarkAllCurves(b, func { b, curve -> _, x, y, _ := GenerateKey(curve, rand.Reader) priv, _, _, _ := GenerateKey(curve, rand.Reader) b.ReportAllocs() @@ -385,9 +385,9 @@ func BenchmarkScalarMult(b *testing.B) { } func BenchmarkMarshalUnmarshal(b *testing.B) { - benchmarkAllCurves(b, func { b, curve | + benchmarkAllCurves(b, func { b, curve -> _, x, y, _ := GenerateKey(curve, rand.Reader) - b.Run("Uncompressed", func { b | + b.Run("Uncompressed", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { buf := Marshal(curve, x, y) @@ -397,7 +397,7 @@ func BenchmarkMarshalUnmarshal(b *testing.B) { } } }) - b.Run("Compressed", func { b | + b.Run("Compressed", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { buf := MarshalCompressed(curve, x, y) diff --git a/src/crypto/hmac/hmac_test.go b/src/crypto/hmac/hmac_test.go index 0b73fe04cae27..453192a0a49bc 100644 --- a/src/crypto/hmac/hmac_test.go +++ b/src/crypto/hmac/hmac_test.go @@ -626,7 +626,7 @@ func TestHMACHash(t *testing.T) { baseHash := test.hash key := test.key - t.Run(fmt.Sprintf("test-%d", i), func { t | cryptotest.TestHash(t, func { return New(baseHash, key) }) }) + t.Run(fmt.Sprintf("test-%d", i), func { t -> cryptotest.TestHash(t, func { return New(baseHash, key) }) }) } } diff --git a/src/crypto/internal/bigmod/nat_test.go b/src/crypto/internal/bigmod/nat_test.go index 7080da437ff66..7b97f44ed2707 100644 --- a/src/crypto/internal/bigmod/nat_test.go +++ b/src/crypto/internal/bigmod/nat_test.go @@ -65,7 +65,7 @@ func TestModSubThenAddIdentity(t *testing.T) { } func TestMontgomeryRoundtrip(t *testing.T) { - err := quick.Check(func { a | + err := quick.Check(func { a -> one := &Nat{make([]uint, len(a.limbs))} one.limbs[0] = 1 aPlusOne := new(big.Int).SetBytes(natBytes(a)) diff --git a/src/crypto/internal/boring/rsa.go b/src/crypto/internal/boring/rsa.go index 0113332e90d2f..1ace3f4d9dcae 100644 --- a/src/crypto/internal/boring/rsa.go +++ b/src/crypto/internal/boring/rsa.go @@ -128,7 +128,7 @@ func setupRSA(withKey func(func(*C.GO_RSA) C.int) C.int, if pkey == nil { return pkey, ctx, fail("EVP_PKEY_new") } - if withKey(func { key | return C._goboringcrypto_EVP_PKEY_set1_RSA(pkey, key) }) == 0 { + if withKey(func { key -> return C._goboringcrypto_EVP_PKEY_set1_RSA(pkey, key) }) == 0 { return pkey, ctx, fail("EVP_PKEY_set1_RSA") } ctx = C._goboringcrypto_EVP_PKEY_CTX_new(pkey, nil) @@ -274,7 +274,7 @@ func SignRSAPSS(priv *PrivateKeyRSA, h crypto.Hash, hashed []byte, saltLen int) var out []byte var outLen C.size_t - if priv.withKey(func { key | + if priv.withKey(func { key -> out = make([]byte, C._goboringcrypto_RSA_size(key)) return C._goboringcrypto_RSA_sign_pss_mgf1(key, &outLen, base(out), C.size_t(len(out)), base(hashed), C.size_t(len(hashed)), md, nil, C.int(saltLen)) @@ -305,7 +305,7 @@ func VerifyRSAPSS(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte, saltLen saltLen = -2 } - if pub.withKey(func { key | + if pub.withKey(func { key -> return C._goboringcrypto_RSA_verify_pss_mgf1(key, base(hashed), C.size_t(len(hashed)), md, nil, C.int(saltLen), base(sig), C.size_t(len(sig))) }) == 0 { @@ -319,7 +319,7 @@ func SignRSAPKCS1v15(priv *PrivateKeyRSA, h crypto.Hash, hashed []byte) ([]byte, // No hashing. var out []byte var outLen C.size_t - if priv.withKey(func { key | + if priv.withKey(func { key -> out = make([]byte, C._goboringcrypto_RSA_size(key)) return C._goboringcrypto_RSA_sign_raw(key, &outLen, base(out), C.size_t(len(out)), base(hashed), C.size_t(len(hashed)), C.GO_RSA_PKCS1_PADDING) @@ -336,7 +336,7 @@ func SignRSAPKCS1v15(priv *PrivateKeyRSA, h crypto.Hash, hashed []byte) ([]byte, nid := C._goboringcrypto_EVP_MD_type(md) var out []byte var outLen C.uint - if priv.withKey(func { key | + if priv.withKey(func { key -> out = make([]byte, C._goboringcrypto_RSA_size(key)) return C._goboringcrypto_RSA_sign(nid, base(hashed), C.uint(len(hashed)), base(out), &outLen, key) @@ -350,7 +350,7 @@ func VerifyRSAPKCS1v15(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte) err if h == 0 { var out []byte var outLen C.size_t - if pub.withKey(func { key | + if pub.withKey(func { key -> out = make([]byte, C._goboringcrypto_RSA_size(key)) return C._goboringcrypto_RSA_verify_raw(key, &outLen, base(out), C.size_t(len(out)), base(sig), C.size_t(len(sig)), C.GO_RSA_PKCS1_PADDING) @@ -367,7 +367,7 @@ func VerifyRSAPKCS1v15(pub *PublicKeyRSA, h crypto.Hash, hashed, sig []byte) err return errors.New("crypto/rsa: unsupported hash function") } nid := C._goboringcrypto_EVP_MD_type(md) - if pub.withKey(func { key | + if pub.withKey(func { key -> return C._goboringcrypto_RSA_verify(nid, base(hashed), C.size_t(len(hashed)), base(sig), C.size_t(len(sig)), key) }) == 0 { diff --git a/src/crypto/internal/cryptotest/hash.go b/src/crypto/internal/cryptotest/hash.go index 6afc817a7d023..bd5d2ba0d350c 100644 --- a/src/crypto/internal/cryptotest/hash.go +++ b/src/crypto/internal/cryptotest/hash.go @@ -20,7 +20,7 @@ type MakeHash func() hash.Hash func TestHash(t *testing.T, mh MakeHash) { // Test that Sum returns an appended digest matching output of Size - t.Run("SumAppend", func { t | + t.Run("SumAppend", func { t -> h := mh() rng := newRandReader(t) @@ -56,7 +56,7 @@ func TestHash(t *testing.T, mh MakeHash) { }) // Test that Hash.Write never returns error. - t.Run("WriteWithoutError", func { t | + t.Run("WriteWithoutError", func { t -> h := mh() rng := newRandReader(t) @@ -73,7 +73,7 @@ func TestHash(t *testing.T, mh MakeHash) { } }) - t.Run("ResetState", func { t | + t.Run("ResetState", func { t -> h := mh() rng := newRandReader(t) @@ -92,7 +92,7 @@ func TestHash(t *testing.T, mh MakeHash) { }) // Check that Write isn't reading from beyond input slice's bounds - t.Run("OutOfBoundsRead", func { t | + t.Run("OutOfBoundsRead", func { t -> h := mh() blockSize := h.BlockSize() rng := newRandReader(t) @@ -121,7 +121,7 @@ func TestHash(t *testing.T, mh MakeHash) { }) // Test that multiple calls to Write is stateful - t.Run("StatefulWrite", func { t | + t.Run("StatefulWrite", func { t -> h := mh() rng := newRandReader(t) diff --git a/src/crypto/internal/edwards25519/edwards25519_test.go b/src/crypto/internal/edwards25519/edwards25519_test.go index 21652f1b58984..82e548f796434 100644 --- a/src/crypto/internal/edwards25519/edwards25519_test.go +++ b/src/crypto/internal/edwards25519/edwards25519_test.go @@ -257,7 +257,7 @@ func TestNonCanonicalPoints(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> p1, err := new(Point).SetBytes(decodeHex(tt.encoding)) if err != nil { t.Fatalf("error decoding non-canonical point: %v", err) diff --git a/src/crypto/internal/edwards25519/scalar_alias_test.go b/src/crypto/internal/edwards25519/scalar_alias_test.go index 1462fc04a4d32..57aded5097d6b 100644 --- a/src/crypto/internal/edwards25519/scalar_alias_test.go +++ b/src/crypto/internal/edwards25519/scalar_alias_test.go @@ -85,13 +85,13 @@ func TestScalarAliasing(t *testing.T) { return checkAliasingTwoArgs((*Scalar).Subtract, v, x, y) }, "MultiplyAdd1": func(v, x, y, fixed Scalar) bool { - return checkAliasingTwoArgs(func { v, x, y | return v.MultiplyAdd(&fixed, x, y) }, v, x, y) + return checkAliasingTwoArgs(func { v, x, y -> return v.MultiplyAdd(&fixed, x, y) }, v, x, y) }, "MultiplyAdd2": func(v, x, y, fixed Scalar) bool { - return checkAliasingTwoArgs(func { v, x, y | return v.MultiplyAdd(x, &fixed, y) }, v, x, y) + return checkAliasingTwoArgs(func { v, x, y -> return v.MultiplyAdd(x, &fixed, y) }, v, x, y) }, "MultiplyAdd3": func(v, x, y, fixed Scalar) bool { - return checkAliasingTwoArgs(func { v, x, y | return v.MultiplyAdd(x, y, &fixed) }, v, x, y) + return checkAliasingTwoArgs(func { v, x, y -> return v.MultiplyAdd(x, y, &fixed) }, v, x, y) }, } { err := quick.Check(f, quickCheckConfig(32)) diff --git a/src/crypto/internal/hpke/hpke_test.go b/src/crypto/internal/hpke/hpke_test.go index aeaab6a88c4be..28799628de218 100644 --- a/src/crypto/internal/hpke/hpke_test.go +++ b/src/crypto/internal/hpke/hpke_test.go @@ -64,7 +64,7 @@ func TestRFC9180Vectors(t *testing.T) { } for _, vector := range vectors { - t.Run(vector.Name, func { t | + t.Run(vector.Name, func { t -> setup := parseVectorSetup(vector.Setup) kemID, err := strconv.Atoi(setup["kem_id"]) @@ -134,7 +134,7 @@ func TestRFC9180Vectors(t *testing.T) { } for _, enc := range parseVectorEncryptions(vector.Encryptions) { - t.Run("seq num "+enc["sequence number"], func { t | + t.Run("seq num "+enc["sequence number"], func { t -> seqNum, err := strconv.Atoi(enc["sequence number"]) if err != nil { t.Fatal(err) diff --git a/src/crypto/internal/mlkem768/mlkem768_test.go b/src/crypto/internal/mlkem768/mlkem768_test.go index e450a769206b3..ce41c5f6b27ad 100644 --- a/src/crypto/internal/mlkem768/mlkem768_test.go +++ b/src/crypto/internal/mlkem768/mlkem768_test.go @@ -439,7 +439,7 @@ func BenchmarkRoundTrip(b *testing.B) { if err != nil { b.Fatal(err) } - b.Run("Alice", func { b | + b.Run("Alice", func { b -> for i := 0; i < b.N; i++ { dkS, err := GenerateKey() if err != nil { @@ -455,7 +455,7 @@ func BenchmarkRoundTrip(b *testing.B) { sink ^= Ks[0] } }) - b.Run("Bob", func { b | + b.Run("Bob", func { b -> for i := 0; i < b.N; i++ { cS, Ks, err := Encapsulate(ek) if err != nil { diff --git a/src/crypto/internal/nistec/fiat/fiat_test.go b/src/crypto/internal/nistec/fiat/fiat_test.go index 1520d86d443d1..dbeb4f81a383f 100644 --- a/src/crypto/internal/nistec/fiat/fiat_test.go +++ b/src/crypto/internal/nistec/fiat/fiat_test.go @@ -10,7 +10,7 @@ import ( ) func BenchmarkMul(b *testing.B) { - b.Run("P224", func { b | + b.Run("P224", func { b -> v := new(fiat.P224Element).One() b.ReportAllocs() b.ResetTimer() @@ -18,7 +18,7 @@ func BenchmarkMul(b *testing.B) { v.Mul(v, v) } }) - b.Run("P384", func { b | + b.Run("P384", func { b -> v := new(fiat.P384Element).One() b.ReportAllocs() b.ResetTimer() @@ -26,7 +26,7 @@ func BenchmarkMul(b *testing.B) { v.Mul(v, v) } }) - b.Run("P521", func { b | + b.Run("P521", func { b -> v := new(fiat.P521Element).One() b.ReportAllocs() b.ResetTimer() @@ -37,7 +37,7 @@ func BenchmarkMul(b *testing.B) { } func BenchmarkSquare(b *testing.B) { - b.Run("P224", func { b | + b.Run("P224", func { b -> v := new(fiat.P224Element).One() b.ReportAllocs() b.ResetTimer() @@ -45,7 +45,7 @@ func BenchmarkSquare(b *testing.B) { v.Square(v) } }) - b.Run("P384", func { b | + b.Run("P384", func { b -> v := new(fiat.P384Element).One() b.ReportAllocs() b.ResetTimer() @@ -53,7 +53,7 @@ func BenchmarkSquare(b *testing.B) { v.Square(v) } }) - b.Run("P521", func { b | + b.Run("P521", func { b -> v := new(fiat.P521Element).One() b.ReportAllocs() b.ResetTimer() diff --git a/src/crypto/internal/nistec/nistec_test.go b/src/crypto/internal/nistec/nistec_test.go index 901749e1bef88..1a34f7f38246d 100644 --- a/src/crypto/internal/nistec/nistec_test.go +++ b/src/crypto/internal/nistec/nistec_test.go @@ -18,7 +18,7 @@ import ( func TestAllocations(t *testing.T) { testenv.SkipIfOptimizationOff(t) - t.Run("P224", func { t | + t.Run("P224", func { t -> if allocs := testing.AllocsPerRun(10, func() { p := nistec.NewP224Point().SetGenerator() scalar := make([]byte, 28) @@ -37,7 +37,7 @@ func TestAllocations(t *testing.T) { t.Errorf("expected zero allocations, got %0.1f", allocs) } }) - t.Run("P256", func { t | + t.Run("P256", func { t -> if allocs := testing.AllocsPerRun(10, func() { p := nistec.NewP256Point().SetGenerator() scalar := make([]byte, 32) @@ -56,7 +56,7 @@ func TestAllocations(t *testing.T) { t.Errorf("expected zero allocations, got %0.1f", allocs) } }) - t.Run("P384", func { t | + t.Run("P384", func { t -> if allocs := testing.AllocsPerRun(10, func() { p := nistec.NewP384Point().SetGenerator() scalar := make([]byte, 48) @@ -75,7 +75,7 @@ func TestAllocations(t *testing.T) { t.Errorf("expected zero allocations, got %0.1f", allocs) } }) - t.Run("P521", func { t | + t.Run("P521", func { t -> if allocs := testing.AllocsPerRun(10, func() { p := nistec.NewP521Point().SetGenerator() scalar := make([]byte, 66) @@ -107,10 +107,10 @@ type nistPoint[T any] interface { } func TestEquivalents(t *testing.T) { - t.Run("P224", func { t | testEquivalents(t, nistec.NewP224Point, elliptic.P224()) }) - t.Run("P256", func { t | testEquivalents(t, nistec.NewP256Point, elliptic.P256()) }) - t.Run("P384", func { t | testEquivalents(t, nistec.NewP384Point, elliptic.P384()) }) - t.Run("P521", func { t | testEquivalents(t, nistec.NewP521Point, elliptic.P521()) }) + t.Run("P224", func { t -> testEquivalents(t, nistec.NewP224Point, elliptic.P224()) }) + t.Run("P256", func { t -> testEquivalents(t, nistec.NewP256Point, elliptic.P256()) }) + t.Run("P384", func { t -> testEquivalents(t, nistec.NewP384Point, elliptic.P384()) }) + t.Run("P521", func { t -> testEquivalents(t, nistec.NewP521Point, elliptic.P521()) }) } func testEquivalents[P nistPoint[P]](t *testing.T, newPoint func() P, c elliptic.Curve) { @@ -151,10 +151,10 @@ func testEquivalents[P nistPoint[P]](t *testing.T, newPoint func() P, c elliptic } func TestScalarMult(t *testing.T) { - t.Run("P224", func { t | testScalarMult(t, nistec.NewP224Point, elliptic.P224()) }) - t.Run("P256", func { t | testScalarMult(t, nistec.NewP256Point, elliptic.P256()) }) - t.Run("P384", func { t | testScalarMult(t, nistec.NewP384Point, elliptic.P384()) }) - t.Run("P521", func { t | testScalarMult(t, nistec.NewP521Point, elliptic.P521()) }) + t.Run("P224", func { t -> testScalarMult(t, nistec.NewP224Point, elliptic.P224()) }) + t.Run("P256", func { t -> testScalarMult(t, nistec.NewP256Point, elliptic.P256()) }) + t.Run("P384", func { t -> testScalarMult(t, nistec.NewP384Point, elliptic.P384()) }) + t.Run("P521", func { t -> testScalarMult(t, nistec.NewP521Point, elliptic.P521()) }) } func testScalarMult[P nistPoint[P]](t *testing.T, newPoint func() P, c elliptic.Curve) { @@ -198,12 +198,12 @@ func testScalarMult[P nistPoint[P]](t *testing.T, newPoint func() P, c elliptic. byteLen := len(c.Params().N.Bytes()) bitLen := c.Params().N.BitLen() - t.Run("0", func { t | checkScalar(t, make([]byte, byteLen)) }) - t.Run("1", func { t | checkScalar(t, big.NewInt(1).FillBytes(make([]byte, byteLen))) }) - t.Run("N-1", func { t | checkScalar(t, new(big.Int).Sub(c.Params().N, big.NewInt(1)).Bytes()) }) - t.Run("N", func { t | checkScalar(t, c.Params().N.Bytes()) }) - t.Run("N+1", func { t | checkScalar(t, new(big.Int).Add(c.Params().N, big.NewInt(1)).Bytes()) }) - t.Run("all1s", func { t | + t.Run("0", func { t -> checkScalar(t, make([]byte, byteLen)) }) + t.Run("1", func { t -> checkScalar(t, big.NewInt(1).FillBytes(make([]byte, byteLen))) }) + t.Run("N-1", func { t -> checkScalar(t, new(big.Int).Sub(c.Params().N, big.NewInt(1)).Bytes()) }) + t.Run("N", func { t -> checkScalar(t, c.Params().N.Bytes()) }) + t.Run("N+1", func { t -> checkScalar(t, new(big.Int).Add(c.Params().N, big.NewInt(1)).Bytes()) }) + t.Run("all1s", func { t -> s := new(big.Int).Lsh(big.NewInt(1), uint(bitLen)) s.Sub(s, big.NewInt(1)) checkScalar(t, s.Bytes()) @@ -212,18 +212,18 @@ func testScalarMult[P nistPoint[P]](t *testing.T, newPoint func() P, c elliptic. return } for i := 0; i < bitLen; i++ { - t.Run(fmt.Sprintf("1<<%d", i), func { t | + t.Run(fmt.Sprintf("1<<%d", i), func { t -> s := new(big.Int).Lsh(big.NewInt(1), uint(i)) checkScalar(t, s.FillBytes(make([]byte, byteLen))) }) } for i := 0; i <= 64; i++ { - t.Run(fmt.Sprintf("%d", i), func { t | checkScalar(t, big.NewInt(int64(i)).FillBytes(make([]byte, byteLen))) }) + t.Run(fmt.Sprintf("%d", i), func { t -> checkScalar(t, big.NewInt(int64(i)).FillBytes(make([]byte, byteLen))) }) } // Test N-64...N+64 since they risk overlapping with precomputed table values // in the final additions. for i := int64(-64); i <= 64; i++ { - t.Run(fmt.Sprintf("N%+d", i), func { t | checkScalar(t, new(big.Int).Add(c.Params().N, big.NewInt(i)).Bytes()) }) + t.Run(fmt.Sprintf("N%+d", i), func { t -> checkScalar(t, new(big.Int).Add(c.Params().N, big.NewInt(i)).Bytes()) }) } } @@ -235,10 +235,10 @@ func fatalIfErr(t *testing.T, err error) { } func BenchmarkScalarMult(b *testing.B) { - b.Run("P224", func { b | benchmarkScalarMult(b, nistec.NewP224Point().SetGenerator(), 28) }) - b.Run("P256", func { b | benchmarkScalarMult(b, nistec.NewP256Point().SetGenerator(), 32) }) - b.Run("P384", func { b | benchmarkScalarMult(b, nistec.NewP384Point().SetGenerator(), 48) }) - b.Run("P521", func { b | benchmarkScalarMult(b, nistec.NewP521Point().SetGenerator(), 66) }) + b.Run("P224", func { b -> benchmarkScalarMult(b, nistec.NewP224Point().SetGenerator(), 28) }) + b.Run("P256", func { b -> benchmarkScalarMult(b, nistec.NewP256Point().SetGenerator(), 32) }) + b.Run("P384", func { b -> benchmarkScalarMult(b, nistec.NewP384Point().SetGenerator(), 48) }) + b.Run("P521", func { b -> benchmarkScalarMult(b, nistec.NewP521Point().SetGenerator(), 66) }) } func benchmarkScalarMult[P nistPoint[P]](b *testing.B, p P, scalarSize int) { @@ -252,10 +252,10 @@ func benchmarkScalarMult[P nistPoint[P]](b *testing.B, p P, scalarSize int) { } func BenchmarkScalarBaseMult(b *testing.B) { - b.Run("P224", func { b | benchmarkScalarBaseMult(b, nistec.NewP224Point().SetGenerator(), 28) }) - b.Run("P256", func { b | benchmarkScalarBaseMult(b, nistec.NewP256Point().SetGenerator(), 32) }) - b.Run("P384", func { b | benchmarkScalarBaseMult(b, nistec.NewP384Point().SetGenerator(), 48) }) - b.Run("P521", func { b | benchmarkScalarBaseMult(b, nistec.NewP521Point().SetGenerator(), 66) }) + b.Run("P224", func { b -> benchmarkScalarBaseMult(b, nistec.NewP224Point().SetGenerator(), 28) }) + b.Run("P256", func { b -> benchmarkScalarBaseMult(b, nistec.NewP256Point().SetGenerator(), 32) }) + b.Run("P384", func { b -> benchmarkScalarBaseMult(b, nistec.NewP384Point().SetGenerator(), 48) }) + b.Run("P521", func { b -> benchmarkScalarBaseMult(b, nistec.NewP521Point().SetGenerator(), 66) }) } func benchmarkScalarBaseMult[P nistPoint[P]](b *testing.B, p P, scalarSize int) { diff --git a/src/crypto/internal/nistec/p256_asm_table_test.go b/src/crypto/internal/nistec/p256_asm_table_test.go index 590fc3877d0e1..9a6c368f1fa2e 100644 --- a/src/crypto/internal/nistec/p256_asm_table_test.go +++ b/src/crypto/internal/nistec/p256_asm_table_test.go @@ -15,7 +15,7 @@ func TestP256PrecomputedTable(t *testing.T) { base := NewP256Point().SetGenerator() for i := 0; i < 43; i++ { - t.Run(fmt.Sprintf("table[%d]", i), func { t | testP256AffineTable(t, base, &p256Precomputed[i]) }) + t.Run(fmt.Sprintf("table[%d]", i), func { t -> testP256AffineTable(t, base, &p256Precomputed[i]) }) for k := 0; k < 6; k++ { base.Double(base) diff --git a/src/crypto/rand/rand_batched_test.go b/src/crypto/rand/rand_batched_test.go index 724be6f9cf642..d4adff8ada813 100644 --- a/src/crypto/rand/rand_batched_test.go +++ b/src/crypto/rand/rand_batched_test.go @@ -14,7 +14,7 @@ import ( ) func TestBatched(t *testing.T) { - fillBatched := batched(func { p | + fillBatched := batched(func { p -> for i := range p { p[i] = byte(i) } @@ -38,7 +38,7 @@ func TestBatchedBuffering(t *testing.T) { output := make([]byte, len(backingStore)) outputMarker := output[:] - fillBatched := batched(func { p | + fillBatched := batched(func { p -> n := copy(p, backingMarker) backingMarker = backingMarker[n:] return nil @@ -61,14 +61,14 @@ func TestBatchedBuffering(t *testing.T) { } func TestBatchedError(t *testing.T) { - b := batched(func { p | return errors.New("failure") }, 5) + b := batched(func { p -> return errors.New("failure") }, 5) if b(make([]byte, 13)) == nil { t.Fatal("batched function should have returned an error") } } func TestBatchedEmpty(t *testing.T) { - b := batched(func { p | return errors.New("failure") }, 5) + b := batched(func { p -> return errors.New("failure") }, 5) if b(make([]byte, 0)) != nil { t.Fatal("empty slice should always return successful") } diff --git a/src/crypto/rand/rand_darwin.go b/src/crypto/rand/rand_darwin.go index 4fb319cdd36c3..b9293c62b3b6b 100644 --- a/src/crypto/rand/rand_darwin.go +++ b/src/crypto/rand/rand_darwin.go @@ -15,7 +15,7 @@ func init() { // // Note that despite its legacy name, it uses a secure CSPRNG (not RC4) in // all supported macOS versions. - altGetRandom = func { b | + altGetRandom = func { b -> unix.ARC4Random(b) return nil } diff --git a/src/crypto/rand/rand_test.go b/src/crypto/rand/rand_test.go index 56e5bc580c5ed..45280f6e5868e 100644 --- a/src/crypto/rand/rand_test.go +++ b/src/crypto/rand/rand_test.go @@ -43,8 +43,8 @@ func TestReadEmpty(t *testing.T) { } func BenchmarkRead(b *testing.B) { - b.Run("32", func { b | benchmarkRead(b, 32) }) - b.Run("4K", func { b | benchmarkRead(b, 4<<10) }) + b.Run("32", func { b -> benchmarkRead(b, 32) }) + b.Run("4K", func { b -> benchmarkRead(b, 4<<10) }) } func benchmarkRead(b *testing.B, size int) { diff --git a/src/crypto/rand/util_test.go b/src/crypto/rand/util_test.go index a6d9e8de2427b..197da96b3df2a 100644 --- a/src/crypto/rand/util_test.go +++ b/src/crypto/rand/util_test.go @@ -83,7 +83,7 @@ func (r *countingReader) Read(p []byte) (n int, err error) { func TestIntReads(t *testing.T) { for i := 0; i < 32; i++ { max := int64(1 << uint64(i)) - t.Run(fmt.Sprintf("max=%d", max), func { t | + t.Run(fmt.Sprintf("max=%d", max), func { t -> reader := &countingReader{r: rand.Reader} _, err := rand.Int(reader, big.NewInt(max)) @@ -101,7 +101,7 @@ func TestIntReads(t *testing.T) { // Test that Int does not mask out valid return values func TestIntMask(t *testing.T) { for max := 1; max <= 256; max++ { - t.Run(fmt.Sprintf("max=%d", max), func { t | + t.Run(fmt.Sprintf("max=%d", max), func { t -> for i := 0; i < max; i++ { if testing.Short() && i == 0 { i = max - 1 diff --git a/src/crypto/rsa/rsa_test.go b/src/crypto/rsa/rsa_test.go index 02fedea2e524a..b9396c62ad399 100644 --- a/src/crypto/rsa/rsa_test.go +++ b/src/crypto/rsa/rsa_test.go @@ -169,7 +169,7 @@ func TestEverything(t *testing.T) { } for size := min; size <= max; size++ { size := size - t.Run(fmt.Sprintf("%d", size), func { t | + t.Run(fmt.Sprintf("%d", size), func { t -> t.Parallel() priv, err := GenerateKey(rand.Reader, size) if err != nil { @@ -468,9 +468,9 @@ Axreud3rJ0rekUp6rI1joG717Wls -----END TESTING KEY-----`)) func BenchmarkDecryptPKCS1v15(b *testing.B) { - b.Run("2048", func { b | benchmarkDecryptPKCS1v15(b, test2048Key) }) - b.Run("3072", func { b | benchmarkDecryptPKCS1v15(b, test3072Key) }) - b.Run("4096", func { b | benchmarkDecryptPKCS1v15(b, test4096Key) }) + b.Run("2048", func { b -> benchmarkDecryptPKCS1v15(b, test2048Key) }) + b.Run("3072", func { b -> benchmarkDecryptPKCS1v15(b, test3072Key) }) + b.Run("4096", func { b -> benchmarkDecryptPKCS1v15(b, test4096Key) }) } func benchmarkDecryptPKCS1v15(b *testing.B, k *PrivateKey) { @@ -497,7 +497,7 @@ func benchmarkDecryptPKCS1v15(b *testing.B, k *PrivateKey) { } func BenchmarkEncryptPKCS1v15(b *testing.B) { - b.Run("2048", func { b | + b.Run("2048", func { b -> r := bufio.NewReaderSize(rand.Reader, 1<<15) m := []byte("Hello Gophers") @@ -513,7 +513,7 @@ func BenchmarkEncryptPKCS1v15(b *testing.B) { } func BenchmarkDecryptOAEP(b *testing.B) { - b.Run("2048", func { b | + b.Run("2048", func { b -> r := bufio.NewReaderSize(rand.Reader, 1<<15) m := []byte("Hello Gophers") @@ -538,7 +538,7 @@ func BenchmarkDecryptOAEP(b *testing.B) { } func BenchmarkEncryptOAEP(b *testing.B) { - b.Run("2048", func { b | + b.Run("2048", func { b -> r := bufio.NewReaderSize(rand.Reader, 1<<15) m := []byte("Hello Gophers") @@ -554,7 +554,7 @@ func BenchmarkEncryptOAEP(b *testing.B) { } func BenchmarkSignPKCS1v15(b *testing.B) { - b.Run("2048", func { b | + b.Run("2048", func { b -> hashed := sha256.Sum256([]byte("testing")) var sink byte @@ -570,7 +570,7 @@ func BenchmarkSignPKCS1v15(b *testing.B) { } func BenchmarkVerifyPKCS1v15(b *testing.B) { - b.Run("2048", func { b | + b.Run("2048", func { b -> hashed := sha256.Sum256([]byte("testing")) s, err := SignPKCS1v15(rand.Reader, test2048Key, crypto.SHA256, hashed[:]) if err != nil { @@ -588,7 +588,7 @@ func BenchmarkVerifyPKCS1v15(b *testing.B) { } func BenchmarkSignPSS(b *testing.B) { - b.Run("2048", func { b | + b.Run("2048", func { b -> hashed := sha256.Sum256([]byte("testing")) var sink byte @@ -604,7 +604,7 @@ func BenchmarkSignPSS(b *testing.B) { } func BenchmarkVerifyPSS(b *testing.B) { - b.Run("2048", func { b | + b.Run("2048", func { b -> hashed := sha256.Sum256([]byte("testing")) s, err := SignPSS(rand.Reader, test2048Key, crypto.SHA256, hashed[:], nil) if err != nil { diff --git a/src/crypto/sha1/sha1_test.go b/src/crypto/sha1/sha1_test.go index 0b3e96eff47d2..cca472d87bd45 100644 --- a/src/crypto/sha1/sha1_test.go +++ b/src/crypto/sha1/sha1_test.go @@ -244,7 +244,7 @@ var buf = make([]byte, 8192) func benchmarkSize(b *testing.B, size int) { sum := make([]byte, bench.Size()) - b.Run("New", func { b | + b.Run("New", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { @@ -253,7 +253,7 @@ func benchmarkSize(b *testing.B, size int) { bench.Sum(sum[:0]) } }) - b.Run("Sum", func { b | + b.Run("Sum", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { diff --git a/src/crypto/sha256/sha256_test.go b/src/crypto/sha256/sha256_test.go index 4e88b6bd97ba2..256a84fdae130 100644 --- a/src/crypto/sha256/sha256_test.go +++ b/src/crypto/sha256/sha256_test.go @@ -150,7 +150,7 @@ func TestGoldenMarshal(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> for _, g := range tt.gold { h := tt.newHash() h2 := tt.newHash() @@ -327,8 +327,8 @@ func TestCgo(t *testing.T) { } func TestSHA256Hash(t *testing.T) { - t.Run("SHA-224", func { t | cryptotest.TestHash(t, New224) }) - t.Run("SHA-256", func { t | cryptotest.TestHash(t, New) }) + t.Run("SHA-224", func { t -> cryptotest.TestHash(t, New224) }) + t.Run("SHA-256", func { t -> cryptotest.TestHash(t, New) }) } var bench = New() @@ -336,7 +336,7 @@ var buf = make([]byte, 8192) func benchmarkSize(b *testing.B, size int) { sum := make([]byte, bench.Size()) - b.Run("New", func { b | + b.Run("New", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { @@ -345,14 +345,14 @@ func benchmarkSize(b *testing.B, size int) { bench.Sum(sum[:0]) } }) - b.Run("Sum224", func { b | + b.Run("Sum224", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { Sum224(buf[:size]) } }) - b.Run("Sum256", func { b | + b.Run("Sum256", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { diff --git a/src/crypto/sha512/sha512_test.go b/src/crypto/sha512/sha512_test.go index cdf67dee68d48..008d9c33ec25c 100644 --- a/src/crypto/sha512/sha512_test.go +++ b/src/crypto/sha512/sha512_test.go @@ -732,7 +732,7 @@ func TestGoldenMarshal(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> for _, test := range tt.golden { h := tt.newHash() h2 := tt.newHash() @@ -911,10 +911,10 @@ func TestAllocations(t *testing.T) { } func TestSHA512Hash(t *testing.T) { - t.Run("SHA-384", func { t | cryptotest.TestHash(t, New384) }) - t.Run("SHA-512/224", func { t | cryptotest.TestHash(t, New512_224) }) - t.Run("SHA-512/256", func { t | cryptotest.TestHash(t, New512_256) }) - t.Run("SHA-512", func { t | cryptotest.TestHash(t, New) }) + t.Run("SHA-384", func { t -> cryptotest.TestHash(t, New384) }) + t.Run("SHA-512/224", func { t -> cryptotest.TestHash(t, New512_224) }) + t.Run("SHA-512/256", func { t -> cryptotest.TestHash(t, New512_256) }) + t.Run("SHA-512", func { t -> cryptotest.TestHash(t, New) }) } var bench = New() @@ -922,7 +922,7 @@ var buf = make([]byte, 8192) func benchmarkSize(b *testing.B, size int) { sum := make([]byte, bench.Size()) - b.Run("New", func { b | + b.Run("New", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { @@ -931,14 +931,14 @@ func benchmarkSize(b *testing.B, size int) { bench.Sum(sum[:0]) } }) - b.Run("Sum384", func { b | + b.Run("Sum384", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { Sum384(buf[:size]) } }) - b.Run("Sum512", func { b | + b.Run("Sum512", func { b -> b.ReportAllocs() b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { diff --git a/src/crypto/subtle/xor_test.go b/src/crypto/subtle/xor_test.go index 16de4fd6fd247..4c37a6ce4b741 100644 --- a/src/crypto/subtle/xor_test.go +++ b/src/crypto/subtle/xor_test.go @@ -69,7 +69,7 @@ func BenchmarkXORBytes(b *testing.B) { data1 := make([]byte, 1<<15) sizes := []int64{1 << 3, 1 << 7, 1 << 11, 1 << 15} for _, size := range sizes { - b.Run(fmt.Sprintf("%dBytes", size), func { b | + b.Run(fmt.Sprintf("%dBytes", size), func { b -> s0 := data0[:size] s1 := data1[:size] b.SetBytes(int64(size)) diff --git a/src/crypto/tls/bogo_shim_test.go b/src/crypto/tls/bogo_shim_test.go index 5eee47a529e15..c6dce5916a4da 100644 --- a/src/crypto/tls/bogo_shim_test.go +++ b/src/crypto/tls/bogo_shim_test.go @@ -431,7 +431,7 @@ func TestBogoSuite(t *testing.T) { for name, result := range results.Tests { // This is not really the intended way to do this... but... it works? - t.Run(name, func { t | + t.Run(name, func { t -> if result.Actual == "FAIL" && result.IsUnexpected { t.Fatal(result.Error) } @@ -447,7 +447,7 @@ func TestBogoSuite(t *testing.T) { if *bogoFilter == "" { // Anything still in assertResults did not show up in the results, so we should fail for name, expectedResult := range assertResults { - t.Run(name, func { t | + t.Run(name, func { t -> t.Fatalf("expected test to run with result %s, but it was not present in the test results", expectedResult) }) } diff --git a/src/crypto/tls/boring_test.go b/src/crypto/tls/boring_test.go index 452454c67b939..066d6c58c85e1 100644 --- a/src/crypto/tls/boring_test.go +++ b/src/crypto/tls/boring_test.go @@ -27,7 +27,7 @@ import ( func TestBoringServerProtocolVersion(t *testing.T) { test := func(t *testing.T, name string, v uint16, msg string) { - t.Run(name, func { t | + t.Run(name, func { t -> serverConfig := testConfig.Clone() serverConfig.MinVersion = VersionSSL30 clientConfig := testConfig.Clone() @@ -54,7 +54,7 @@ func TestBoringServerProtocolVersion(t *testing.T) { test(t, "VersionTLS12", VersionTLS12, "") test(t, "VersionTLS13", VersionTLS13, "") - t.Run("fipstls", func { t | + t.Run("fipstls", func { t -> fipstls.Force() defer fipstls.Abandon() test(t, "VersionTLS10", VersionTLS10, "supported versions") @@ -130,7 +130,7 @@ func TestBoringServerCipherSuites(t *testing.T) { serverConfig.Certificates[0].PrivateKey = testRSAPrivateKey } serverConfig.BuildNameToCertificate() - t.Run(fmt.Sprintf("suite=%#x", id), func { t | + t.Run(fmt.Sprintf("suite=%#x", id), func { t -> clientHello := &clientHelloMsg{ vers: VersionTLS12, random: make([]byte, 32), @@ -141,7 +141,7 @@ func TestBoringServerCipherSuites(t *testing.T) { } testClientHello(t, serverConfig, clientHello) - t.Run("fipstls", func { t | + t.Run("fipstls", func { t -> fipstls.Force() defer fipstls.Abandon() msg := "" @@ -162,7 +162,7 @@ func TestBoringServerCurves(t *testing.T) { serverConfig.BuildNameToCertificate() for _, curveid := range defaultCurvePreferences() { - t.Run(fmt.Sprintf("curve=%d", curveid), func { t | + t.Run(fmt.Sprintf("curve=%d", curveid), func { t -> clientConfig := testConfig.Clone() clientConfig.CurvePreferences = []CurveID{curveid} if curveid == x25519Kyber768Draft00 { @@ -174,7 +174,7 @@ func TestBoringServerCurves(t *testing.T) { } // With fipstls forced, bad curves should be rejected. - t.Run("fipstls", func { t | + t.Run("fipstls", func { t -> fipstls.Force() defer fipstls.Abandon() _, _, err := testHandshake(t, clientConfig, serverConfig) @@ -209,7 +209,7 @@ func TestBoringServerSignatureAndHash(t *testing.T) { }() for _, sigHash := range defaultSupportedSignatureAlgorithms { - t.Run(fmt.Sprintf("%v", sigHash), func { t | + t.Run(fmt.Sprintf("%v", sigHash), func { t -> serverConfig := testConfig.Clone() serverConfig.Certificates = make([]Certificate, 1) @@ -241,7 +241,7 @@ func TestBoringServerSignatureAndHash(t *testing.T) { } // With fipstls forced, bad curves should be rejected. - t.Run("fipstls", func { t | + t.Run("fipstls", func { t -> fipstls.Force() defer fipstls.Abandon() clientErr, _ := boringHandshake(t, testConfig, serverConfig) diff --git a/src/crypto/tls/cache.go b/src/crypto/tls/cache.go index 13f19a179770c..468d3be2f74b8 100644 --- a/src/crypto/tls/cache.go +++ b/src/crypto/tls/cache.go @@ -60,7 +60,7 @@ type activeCert struct { func (cc *certCache) active(e *cacheEntry) *activeCert { e.refs.Add(1) a := &activeCert{e.cert} - runtime.SetFinalizer(a, func { _ | if e.refs.Add(-1) == 0 { + runtime.SetFinalizer(a, func { _ -> if e.refs.Add(-1) == 0 { cc.evict(e) } }) return a diff --git a/src/crypto/tls/cache_test.go b/src/crypto/tls/cache_test.go index 01005f015612d..47047a0225892 100644 --- a/src/crypto/tls/cache_test.go +++ b/src/crypto/tls/cache_test.go @@ -92,7 +92,7 @@ func BenchmarkCertCache(b *testing.B) { // We expect that calling newCert additional times after // the initial call should not cause additional allocations. for extra := 0; extra < 4; extra++ { - b.Run(fmt.Sprint(extra), func { b | + b.Run(fmt.Sprint(extra), func { b -> actives := make([]*activeCert, extra+1) b.ResetTimer() for i := 0; i < b.N; i++ { diff --git a/src/crypto/tls/common.go b/src/crypto/tls/common.go index 6ac0f4a861726..9a90b3f61b690 100644 --- a/src/crypto/tls/common.go +++ b/src/crypto/tls/common.go @@ -1064,7 +1064,7 @@ func (c *Config) cipherSuites() []uint16 { } if needFIPS() { cipherSuites := slices.Clone(c.CipherSuites) - return slices.DeleteFunc(cipherSuites, func { id | return !slices.Contains(defaultCipherSuitesFIPS, id) }) + return slices.DeleteFunc(cipherSuites, func { id -> return !slices.Contains(defaultCipherSuitesFIPS, id) }) } return c.CipherSuites } @@ -1135,7 +1135,7 @@ func (c *Config) curvePreferences(version uint16) []CurveID { if c != nil && len(c.CurvePreferences) != 0 { curvePreferences = slices.Clone(c.CurvePreferences) if needFIPS() { - return slices.DeleteFunc(curvePreferences, func { c | return !slices.Contains(defaultCurvePreferencesFIPS, c) }) + return slices.DeleteFunc(curvePreferences, func { c -> return !slices.Contains(defaultCurvePreferencesFIPS, c) }) } } else if needFIPS() { curvePreferences = slices.Clone(defaultCurvePreferencesFIPS) @@ -1143,7 +1143,7 @@ func (c *Config) curvePreferences(version uint16) []CurveID { curvePreferences = defaultCurvePreferences() } if version < VersionTLS13 { - return slices.DeleteFunc(curvePreferences, func { c | return c == x25519Kyber768Draft00 }) + return slices.DeleteFunc(curvePreferences, func { c -> return c == x25519Kyber768Draft00 }) } return curvePreferences } @@ -1286,7 +1286,7 @@ func (chi *ClientHelloInfo) SupportsCertificate(c *Certificate) error { } // Finally, there needs to be a mutual cipher suite that uses the static // RSA key exchange instead of ECDHE. - rsaCipherSuite := selectCipherSuite(chi.CipherSuites, config.cipherSuites(), func { c | + rsaCipherSuite := selectCipherSuite(chi.CipherSuites, config.cipherSuites(), func { c -> if c.flags&suiteECDHE != 0 { return false } @@ -1363,7 +1363,7 @@ func (chi *ClientHelloInfo) SupportsCertificate(c *Certificate) error { // Make sure that there is a mutually supported cipher suite that works with // this certificate. Cipher suite selection will then apply the logic in // reverse to pick it. See also serverHandshakeState.cipherSuiteOk. - cipherSuite := selectCipherSuite(chi.CipherSuites, config.cipherSuites(), func { c | + cipherSuite := selectCipherSuite(chi.CipherSuites, config.cipherSuites(), func { c -> if c.flags&suiteECDHE == 0 { return false } diff --git a/src/crypto/tls/conn.go b/src/crypto/tls/conn.go index b9a8951fa8c00..af9643e9d4dc8 100644 --- a/src/crypto/tls/conn.go +++ b/src/crypto/tls/conn.go @@ -1643,7 +1643,7 @@ func (c *Conn) connectionStateLocked() ConnectionState { if c.config.Renegotiation != RenegotiateNever { state.ekm = noEKMBecauseRenegotiation } else if c.vers != VersionTLS13 && !c.extMasterSecret { - state.ekm = func { label, context, length | + state.ekm = func { label, context, length -> if tlsunsafeekm.Value() == "1" { tlsunsafeekm.IncNonDefault() return c.ekm(label, context, length) diff --git a/src/crypto/tls/defaults.go b/src/crypto/tls/defaults.go index 9840405f1b6b5..2a27561be32a7 100644 --- a/src/crypto/tls/defaults.go +++ b/src/crypto/tls/defaults.go @@ -47,7 +47,7 @@ var tls3des = godebug.New("tls3des") func defaultCipherSuites() []uint16 { suites := slices.Clone(cipherSuitesPreferenceOrder) - return slices.DeleteFunc(suites, func { c | + return slices.DeleteFunc(suites, func { c -> return disabledCipherSuites[c] || tlsrsakex.Value() != "1" && rsaKexCiphers[c] || tls3des.Value() != "1" && tdesCiphers[c] diff --git a/src/crypto/tls/ech.go b/src/crypto/tls/ech.go index 2d40c23f2ae8b..b00f3bd97e54e 100644 --- a/src/crypto/tls/ech.go +++ b/src/crypto/tls/ech.go @@ -201,8 +201,8 @@ func generateOuterECHExt(id uint8, kdfID, aeadID uint16, encodedKey []byte, payl b.AddUint16(kdfID) b.AddUint16(aeadID) b.AddUint8(id) - b.AddUint16LengthPrefixed(func { b | b.AddBytes(encodedKey) }) - b.AddUint16LengthPrefixed(func { b | b.AddBytes(payload) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(encodedKey) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(payload) }) return b.Bytes() } diff --git a/src/crypto/tls/example_test.go b/src/crypto/tls/example_test.go index 0e0ae347ff989..6391a4f9fdc27 100644 --- a/src/crypto/tls/example_test.go +++ b/src/crypto/tls/example_test.go @@ -76,7 +76,7 @@ func ExampleConfig_keyLogWriter() { // Dummy test HTTP server for the example with insecure random so output is // reproducible. - server := httptest.NewUnstartedServer(http.HandlerFunc(func { w, r | })) + server := httptest.NewUnstartedServer(http.HandlerFunc(func { w, r -> })) server.TLS = &tls.Config{ Rand: zeroSource{}, // for example only; don't do this. } diff --git a/src/crypto/tls/handshake_client_test.go b/src/crypto/tls/handshake_client_test.go index de014c900c26e..aec6a21c9fe2c 100644 --- a/src/crypto/tls/handshake_client_test.go +++ b/src/crypto/tls/handshake_client_test.go @@ -840,8 +840,8 @@ func TestClientKeyUpdate(t *testing.T) { } func TestResumption(t *testing.T) { - t.Run("TLSv12", func { t | testResumption(t, VersionTLS12) }) - t.Run("TLSv13", func { t | testResumption(t, VersionTLS13) }) + t.Run("TLSv12", func { t -> testResumption(t, VersionTLS12) }) + t.Run("TLSv13", func { t -> testResumption(t, VersionTLS13) }) } func testResumption(t *testing.T, version uint16) { @@ -1556,8 +1556,8 @@ func TestServerSelectingUnconfiguredCipherSuite(t *testing.T) { } func TestVerifyConnection(t *testing.T) { - t.Run("TLSv12", func { t | testVerifyConnection(t, VersionTLS12) }) - t.Run("TLSv13", func { t | testVerifyConnection(t, VersionTLS13) }) + t.Run("TLSv12", func { t -> testVerifyConnection(t, VersionTLS12) }) + t.Run("TLSv13", func { t -> testVerifyConnection(t, VersionTLS13) }) } func testVerifyConnection(t *testing.T, version uint16) { @@ -1596,7 +1596,7 @@ func testVerifyConnection(t *testing.T, version uint16) { name: "RequireAndVerifyClientCert", configureServer: func(config *Config, called *int) { config.ClientAuth = RequireAndVerifyClientCert - config.VerifyConnection = func { c | + config.VerifyConnection = func { c -> *called++ if l := len(c.PeerCertificates); l != 1 { return fmt.Errorf("server: got len(PeerCertificates) = %d, wanted 1", l) @@ -1608,7 +1608,7 @@ func testVerifyConnection(t *testing.T, version uint16) { } }, configureClient: func(config *Config, called *int) { - config.VerifyConnection = func { c | + config.VerifyConnection = func { c -> *called++ if l := len(c.PeerCertificates); l != 1 { return fmt.Errorf("client: got len(PeerCertificates) = %d, wanted 1", l) @@ -1636,7 +1636,7 @@ func testVerifyConnection(t *testing.T, version uint16) { configureServer: func(config *Config, called *int) { config.ClientAuth = RequireAnyClientCert config.InsecureSkipVerify = true - config.VerifyConnection = func { c | + config.VerifyConnection = func { c -> *called++ if l := len(c.PeerCertificates); l != 1 { return fmt.Errorf("server: got len(PeerCertificates) = %d, wanted 1", l) @@ -1649,7 +1649,7 @@ func testVerifyConnection(t *testing.T, version uint16) { }, configureClient: func(config *Config, called *int) { config.InsecureSkipVerify = true - config.VerifyConnection = func { c | + config.VerifyConnection = func { c -> *called++ if l := len(c.PeerCertificates); l != 1 { return fmt.Errorf("client: got len(PeerCertificates) = %d, wanted 1", l) @@ -1676,13 +1676,13 @@ func testVerifyConnection(t *testing.T, version uint16) { name: "NoClientCert", configureServer: func(config *Config, called *int) { config.ClientAuth = NoClientCert - config.VerifyConnection = func { c | + config.VerifyConnection = func { c -> *called++ return checkFields(c, called, "server") } }, configureClient: func(config *Config, called *int) { - config.VerifyConnection = func { c | + config.VerifyConnection = func { c -> *called++ return checkFields(c, called, "client") } @@ -1692,14 +1692,14 @@ func testVerifyConnection(t *testing.T, version uint16) { name: "RequestClientCert", configureServer: func(config *Config, called *int) { config.ClientAuth = RequestClientCert - config.VerifyConnection = func { c | + config.VerifyConnection = func { c -> *called++ return checkFields(c, called, "server") } }, configureClient: func(config *Config, called *int) { config.Certificates = nil // clear the client cert - config.VerifyConnection = func { c | + config.VerifyConnection = func { c -> *called++ if l := len(c.PeerCertificates); l != 1 { return fmt.Errorf("client: got len(PeerCertificates) = %d, wanted 1", l) @@ -1778,8 +1778,8 @@ func testVerifyConnection(t *testing.T, version uint16) { } func TestVerifyPeerCertificate(t *testing.T) { - t.Run("TLSv12", func { t | testVerifyPeerCertificate(t, VersionTLS12) }) - t.Run("TLSv13", func { t | testVerifyPeerCertificate(t, VersionTLS13) }) + t.Run("TLSv12", func { t -> testVerifyPeerCertificate(t, VersionTLS12) }) + t.Run("TLSv13", func { t -> testVerifyPeerCertificate(t, VersionTLS13) }) } func testVerifyPeerCertificate(t *testing.T, version uint16) { @@ -1827,11 +1827,11 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) { { configureServer: func(config *Config, called *bool) { config.InsecureSkipVerify = false - config.VerifyPeerCertificate = func { rawCerts, validatedChains | return verifyPeerCertificateCallback(called, rawCerts, validatedChains) } + config.VerifyPeerCertificate = func { rawCerts, validatedChains -> return verifyPeerCertificateCallback(called, rawCerts, validatedChains) } }, configureClient: func(config *Config, called *bool) { config.InsecureSkipVerify = false - config.VerifyPeerCertificate = func { rawCerts, validatedChains | return verifyPeerCertificateCallback(called, rawCerts, validatedChains) } + config.VerifyPeerCertificate = func { rawCerts, validatedChains -> return verifyPeerCertificateCallback(called, rawCerts, validatedChains) } }, validate: func(t *testing.T, testNo int, clientCalled, serverCalled bool, clientErr, serverErr error) { if clientErr != nil { @@ -1851,7 +1851,7 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) { { configureServer: func(config *Config, called *bool) { config.InsecureSkipVerify = false - config.VerifyPeerCertificate = func { rawCerts, validatedChains | return sentinelErr } + config.VerifyPeerCertificate = func { rawCerts, validatedChains -> return sentinelErr } }, configureClient: func(config *Config, called *bool) { config.VerifyPeerCertificate = nil @@ -1867,7 +1867,7 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) { config.InsecureSkipVerify = false }, configureClient: func(config *Config, called *bool) { - config.VerifyPeerCertificate = func { rawCerts, validatedChains | return sentinelErr } + config.VerifyPeerCertificate = func { rawCerts, validatedChains -> return sentinelErr } }, validate: func(t *testing.T, testNo int, clientCalled, serverCalled bool, clientErr, serverErr error) { if clientErr != sentinelErr { @@ -1881,7 +1881,7 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) { }, configureClient: func(config *Config, called *bool) { config.InsecureSkipVerify = true - config.VerifyPeerCertificate = func { rawCerts, validatedChains | + config.VerifyPeerCertificate = func { rawCerts, validatedChains -> if l := len(rawCerts); l != 1 { return fmt.Errorf("got len(rawCerts) = %d, wanted 1", l) } @@ -1910,11 +1910,11 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) { { configureServer: func(config *Config, called *bool) { config.InsecureSkipVerify = false - config.VerifyConnection = func { c | return verifyConnectionCallback(called, false, c) } + config.VerifyConnection = func { c -> return verifyConnectionCallback(called, false, c) } }, configureClient: func(config *Config, called *bool) { config.InsecureSkipVerify = false - config.VerifyConnection = func { c | return verifyConnectionCallback(called, true, c) } + config.VerifyConnection = func { c -> return verifyConnectionCallback(called, true, c) } }, validate: func(t *testing.T, testNo int, clientCalled, serverCalled bool, clientErr, serverErr error) { if clientErr != nil { @@ -1934,7 +1934,7 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) { { configureServer: func(config *Config, called *bool) { config.InsecureSkipVerify = false - config.VerifyConnection = func { c | return sentinelErr } + config.VerifyConnection = func { c -> return sentinelErr } }, configureClient: func(config *Config, called *bool) { config.InsecureSkipVerify = false @@ -1953,7 +1953,7 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) { }, configureClient: func(config *Config, called *bool) { config.InsecureSkipVerify = false - config.VerifyConnection = func { c | return sentinelErr } + config.VerifyConnection = func { c -> return sentinelErr } }, validate: func(t *testing.T, testNo int, clientCalled, serverCalled bool, clientErr, serverErr error) { if clientErr != sentinelErr { @@ -1964,8 +1964,8 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) { { configureServer: func(config *Config, called *bool) { config.InsecureSkipVerify = false - config.VerifyPeerCertificate = func { rawCerts, validatedChains | return verifyPeerCertificateCallback(called, rawCerts, validatedChains) } - config.VerifyConnection = func { c | return sentinelErr } + config.VerifyPeerCertificate = func { rawCerts, validatedChains -> return verifyPeerCertificateCallback(called, rawCerts, validatedChains) } + config.VerifyConnection = func { c -> return sentinelErr } }, configureClient: func(config *Config, called *bool) { config.InsecureSkipVerify = false @@ -1989,8 +1989,8 @@ func testVerifyPeerCertificate(t *testing.T, version uint16) { }, configureClient: func(config *Config, called *bool) { config.InsecureSkipVerify = false - config.VerifyPeerCertificate = func { rawCerts, validatedChains | return verifyPeerCertificateCallback(called, rawCerts, validatedChains) } - config.VerifyConnection = func { c | return sentinelErr } + config.VerifyPeerCertificate = func { rawCerts, validatedChains -> return verifyPeerCertificateCallback(called, rawCerts, validatedChains) } + config.VerifyConnection = func { c -> return sentinelErr } }, validate: func(t *testing.T, testNo int, clientCalled, serverCalled bool, clientErr, serverErr error) { if clientErr != sentinelErr { @@ -2104,8 +2104,8 @@ func (wcc *writeCountingConn) Write(data []byte) (int, error) { } func TestBuffering(t *testing.T) { - t.Run("TLSv12", func { t | testBuffering(t, VersionTLS12) }) - t.Run("TLSv13", func { t | testBuffering(t, VersionTLS13) }) + t.Run("TLSv12", func { t -> testBuffering(t, VersionTLS12) }) + t.Run("TLSv13", func { t -> testBuffering(t, VersionTLS13) }) } func testBuffering(t *testing.T, version uint16) { @@ -2257,7 +2257,7 @@ var getClientCertificateTests = []struct { // should result in an empty message being sent to the // server. serverConfig.ClientCAs = nil - clientConfig.GetClientCertificate = func { cri | + clientConfig.GetClientCertificate = func { cri -> if len(cri.SignatureSchemes) == 0 { panic("empty SignatureSchemes") } @@ -2279,7 +2279,7 @@ var getClientCertificateTests = []struct { // With TLS 1.1, the SignatureSchemes should be // synthesised from the supported certificate types. clientConfig.MaxVersion = VersionTLS11 - clientConfig.GetClientCertificate = func { cri | + clientConfig.GetClientCertificate = func { cri -> if len(cri.SignatureSchemes) == 0 { panic("empty SignatureSchemes") } @@ -2297,7 +2297,7 @@ var getClientCertificateTests = []struct { func(clientConfig, serverConfig *Config) { // Returning an error should abort the handshake with // that error. - clientConfig.GetClientCertificate = func { cri | return nil, errors.New("GetClientCertificate") } + clientConfig.GetClientCertificate = func { cri -> return nil, errors.New("GetClientCertificate") } }, "GetClientCertificate", func(t *testing.T, testNum int, cs *ConnectionState) { @@ -2305,7 +2305,7 @@ var getClientCertificateTests = []struct { }, { func(clientConfig, serverConfig *Config) { - clientConfig.GetClientCertificate = func { cri | + clientConfig.GetClientCertificate = func { cri -> if len(cri.AcceptableCAs) == 0 { panic("empty AcceptableCAs") } @@ -2326,8 +2326,8 @@ var getClientCertificateTests = []struct { } func TestGetClientCertificate(t *testing.T) { - t.Run("TLSv12", func { t | testGetClientCertificate(t, VersionTLS12) }) - t.Run("TLSv13", func { t | testGetClientCertificate(t, VersionTLS13) }) + t.Run("TLSv12", func { t -> testGetClientCertificate(t, VersionTLS12) }) + t.Run("TLSv13", func { t -> testGetClientCertificate(t, VersionTLS13) }) } func testGetClientCertificate(t *testing.T, version uint16) { @@ -2497,8 +2497,8 @@ func TestDowngradeCanary(t *testing.T) { } func TestResumptionKeepsOCSPAndSCT(t *testing.T) { - t.Run("TLSv12", func { t | testResumptionKeepsOCSPAndSCT(t, VersionTLS12) }) - t.Run("TLSv13", func { t | testResumptionKeepsOCSPAndSCT(t, VersionTLS13) }) + t.Run("TLSv12", func { t -> testResumptionKeepsOCSPAndSCT(t, VersionTLS12) }) + t.Run("TLSv13", func { t -> testResumptionKeepsOCSPAndSCT(t, VersionTLS13) }) } func testResumptionKeepsOCSPAndSCT(t *testing.T, ver uint16) { @@ -2638,7 +2638,7 @@ func TestTLS13OnlyClientHelloCipherSuite(t *testing.T) { } for _, tt := range tls13Tests { tt := tt - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> t.Parallel() testTLS13OnlyClientHelloCipherSuite(t, tt.ciphers) }) @@ -2827,7 +2827,7 @@ func TestTLS13ECHRejectionCallbacks(t *testing.T) { expectedErr: "tls: server rejected ECH", }, } { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> c, s := localPipe(t) done := make(chan error) diff --git a/src/crypto/tls/handshake_client_tls13.go b/src/crypto/tls/handshake_client_tls13.go index 708998fa30ce3..b8d686dda7f9f 100644 --- a/src/crypto/tls/handshake_client_tls13.go +++ b/src/crypto/tls/handshake_client_tls13.go @@ -318,7 +318,7 @@ func (hs *clientHandshakeStateTLS13) processHelloRetryRequest() error { c.sendAlert(alertIllegalParameter) return errors.New("tls: server selected unsupported group") } - if slices.ContainsFunc(hs.hello.keyShares, func { ks | return ks.group == curveID }) { + if slices.ContainsFunc(hs.hello.keyShares, func { ks -> return ks.group == curveID }) { c.sendAlert(alertIllegalParameter) return errors.New("tls: server sent an unnecessary HelloRetryRequest key_share") } @@ -438,7 +438,7 @@ func (hs *clientHandshakeStateTLS13) processServerHello() error { c.sendAlert(alertIllegalParameter) return errors.New("tls: server did not send a key share") } - if !slices.ContainsFunc(hs.hello.keyShares, func { ks | return ks.group == hs.serverHello.serverShare.group }) { + if !slices.ContainsFunc(hs.hello.keyShares, func { ks -> return ks.group == hs.serverHello.serverShare.group }) { c.sendAlert(alertIllegalParameter) return errors.New("tls: server selected unsupported group") } diff --git a/src/crypto/tls/handshake_messages.go b/src/crypto/tls/handshake_messages.go index 2b97f99455202..abdf59af9f559 100644 --- a/src/crypto/tls/handshake_messages.go +++ b/src/crypto/tls/handshake_messages.go @@ -24,7 +24,7 @@ func (f marshalingFunction) Marshal(b *cryptobyte.Builder) error { // addBytesWithLength appends a sequence of bytes to the cryptobyte.Builder. If // the length of the sequence is not the value specified, it produces an error. func addBytesWithLength(b *cryptobyte.Builder, v []byte, n int) { - b.AddValue(marshalingFunction(func { b | + b.AddValue(marshalingFunction(func { b -> if len(v) != n { return fmt.Errorf("invalid value length: expected %d, got %d", n, len(v)) } @@ -104,30 +104,30 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { if len(m.serverName) > 0 { // RFC 6066, Section 3 exts.AddUint16(extensionServerName) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint16LengthPrefixed(func { exts -> exts.AddUint8(0) // name_type = host_name - exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes([]byte(m.serverName)) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes([]byte(m.serverName)) }) }) }) } if len(m.supportedPoints) > 0 && !echInner { // RFC 4492, Section 5.1.2 exts.AddUint16(extensionSupportedPoints) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint8LengthPrefixed(func { exts | exts.AddBytes(m.supportedPoints) }) + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint8LengthPrefixed(func { exts -> exts.AddBytes(m.supportedPoints) }) }) } if m.ticketSupported && !echInner { // RFC 5077, Section 3.2 exts.AddUint16(extensionSessionTicket) - exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(m.sessionTicket) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(m.sessionTicket) }) } if m.secureRenegotiationSupported && !echInner { // RFC 5746, Section 3.2 exts.AddUint16(extensionRenegotiationInfo) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint8LengthPrefixed(func { exts | exts.AddBytes(m.secureRenegotiation) }) + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint8LengthPrefixed(func { exts -> exts.AddBytes(m.secureRenegotiation) }) }) } if m.extendedMasterSecret && !echInner { @@ -148,11 +148,11 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { if m.quicTransportParameters != nil { // marshal zero-length parameters when present // RFC 9001, Section 8.2 exts.AddUint16(extensionQUICTransportParameters) - exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(m.quicTransportParameters) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(m.quicTransportParameters) }) } if len(m.encryptedClientHello) > 0 { exts.AddUint16(extensionEncryptedClientHello) - exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(m.encryptedClientHello) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(m.encryptedClientHello) }) } // Note that any extension that can be compressed during ECH must be // contiguous. If any additional extensions are to be compressed they must @@ -165,7 +165,7 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { echOuterExts = append(echOuterExts, extensionStatusRequest) } else { exts.AddUint16(extensionStatusRequest) - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> exts.AddUint8(1) // status_type = ocsp exts.AddUint16(0) // empty responder_id_list exts.AddUint16(0) // empty request_extensions @@ -178,8 +178,8 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { echOuterExts = append(echOuterExts, extensionSupportedCurves) } else { exts.AddUint16(extensionSupportedCurves) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint16LengthPrefixed(func { exts | for _, curve := range m.supportedCurves { + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint16LengthPrefixed(func { exts -> for _, curve := range m.supportedCurves { exts.AddUint16(uint16(curve)) } }) }) @@ -191,8 +191,8 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { echOuterExts = append(echOuterExts, extensionSignatureAlgorithms) } else { exts.AddUint16(extensionSignatureAlgorithms) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint16LengthPrefixed(func { exts -> for _, sigAlgo := range m.supportedSignatureAlgorithms { exts.AddUint16(uint16(sigAlgo)) } @@ -206,8 +206,8 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { echOuterExts = append(echOuterExts, extensionSignatureAlgorithmsCert) } else { exts.AddUint16(extensionSignatureAlgorithmsCert) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint16LengthPrefixed(func { exts -> for _, sigAlgo := range m.supportedSignatureAlgorithmsCert { exts.AddUint16(uint16(sigAlgo)) } @@ -221,10 +221,10 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { echOuterExts = append(echOuterExts, extensionALPN) } else { exts.AddUint16(extensionALPN) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint16LengthPrefixed(func { exts -> for _, proto := range m.alpnProtocols { - exts.AddUint8LengthPrefixed(func { exts | exts.AddBytes([]byte(proto)) }) + exts.AddUint8LengthPrefixed(func { exts -> exts.AddBytes([]byte(proto)) }) } }) }) @@ -236,8 +236,8 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { echOuterExts = append(echOuterExts, extensionSupportedVersions) } else { exts.AddUint16(extensionSupportedVersions) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint8LengthPrefixed(func { exts | for _, vers := range m.supportedVersions { + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint8LengthPrefixed(func { exts -> for _, vers := range m.supportedVersions { exts.AddUint16(vers) } }) }) @@ -249,7 +249,7 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { echOuterExts = append(echOuterExts, extensionCookie) } else { exts.AddUint16(extensionCookie) - exts.AddUint16LengthPrefixed(func { exts | exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(m.cookie) }) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(m.cookie) }) }) } } if len(m.keyShares) > 0 { @@ -258,11 +258,11 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { echOuterExts = append(echOuterExts, extensionKeyShare) } else { exts.AddUint16(extensionKeyShare) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint16LengthPrefixed(func { exts -> for _, ks := range m.keyShares { exts.AddUint16(uint16(ks.group)) - exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(ks.data) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(ks.data) }) } }) }) @@ -274,13 +274,13 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { echOuterExts = append(echOuterExts, extensionPSKModes) } else { exts.AddUint16(extensionPSKModes) - exts.AddUint16LengthPrefixed(func { exts | exts.AddUint8LengthPrefixed(func { exts | exts.AddBytes(m.pskModes) }) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddUint8LengthPrefixed(func { exts -> exts.AddBytes(m.pskModes) }) }) } } if len(echOuterExts) > 0 && echInner { exts.AddUint16(extensionECHOuterExtensions) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint8LengthPrefixed(func { exts | for _, e := range echOuterExts { + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint8LengthPrefixed(func { exts -> for _, e := range echOuterExts { exts.AddUint16(e) } }) }) @@ -288,16 +288,16 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { if len(m.pskIdentities) > 0 { // pre_shared_key must be the last extension // RFC 8446, Section 4.2.11 exts.AddUint16(extensionPreSharedKey) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint16LengthPrefixed(func { exts -> for _, psk := range m.pskIdentities { - exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(psk.label) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(psk.label) }) exts.AddUint32(psk.obfuscatedTicketAge) } }) - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> for _, binder := range m.pskBinders { - exts.AddUint8LengthPrefixed(func { exts | exts.AddBytes(binder) }) + exts.AddUint8LengthPrefixed(func { exts -> exts.AddBytes(binder) }) } }) }) @@ -309,19 +309,19 @@ func (m *clientHelloMsg) marshalMsg(echInner bool) ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeClientHello) - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> b.AddUint16(m.vers) addBytesWithLength(b, m.random, 32) - b.AddUint8LengthPrefixed(func { b | if !echInner { + b.AddUint8LengthPrefixed(func { b -> if !echInner { b.AddBytes(m.sessionId) } }) - b.AddUint16LengthPrefixed(func { b | for _, suite := range m.cipherSuites { + b.AddUint16LengthPrefixed(func { b -> for _, suite := range m.cipherSuites { b.AddUint16(suite) } }) - b.AddUint8LengthPrefixed(func { b | b.AddBytes(m.compressionMethods) }) + b.AddUint8LengthPrefixed(func { b -> b.AddBytes(m.compressionMethods) }) if len(extBytes) > 0 { - b.AddUint16LengthPrefixed(func { b | b.AddBytes(extBytes) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(extBytes) }) } }) @@ -706,8 +706,8 @@ func (m *serverHelloMsg) marshal() ([]byte, error) { } if m.secureRenegotiationSupported { exts.AddUint16(extensionRenegotiationInfo) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint8LengthPrefixed(func { exts | exts.AddBytes(m.secureRenegotiation) }) + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint8LengthPrefixed(func { exts -> exts.AddBytes(m.secureRenegotiation) }) }) } if m.extendedMasterSecret { @@ -716,55 +716,55 @@ func (m *serverHelloMsg) marshal() ([]byte, error) { } if len(m.alpnProtocol) > 0 { exts.AddUint16(extensionALPN) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint8LengthPrefixed(func { exts | exts.AddBytes([]byte(m.alpnProtocol)) }) + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint8LengthPrefixed(func { exts -> exts.AddBytes([]byte(m.alpnProtocol)) }) }) }) } if len(m.scts) > 0 { exts.AddUint16(extensionSCT) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint16LengthPrefixed(func { exts -> for _, sct := range m.scts { - exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(sct) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(sct) }) } }) }) } if m.supportedVersion != 0 { exts.AddUint16(extensionSupportedVersions) - exts.AddUint16LengthPrefixed(func { exts | exts.AddUint16(m.supportedVersion) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddUint16(m.supportedVersion) }) } if m.serverShare.group != 0 { exts.AddUint16(extensionKeyShare) - exts.AddUint16LengthPrefixed(func { exts | + exts.AddUint16LengthPrefixed(func { exts -> exts.AddUint16(uint16(m.serverShare.group)) - exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(m.serverShare.data) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(m.serverShare.data) }) }) } if m.selectedIdentityPresent { exts.AddUint16(extensionPreSharedKey) - exts.AddUint16LengthPrefixed(func { exts | exts.AddUint16(m.selectedIdentity) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddUint16(m.selectedIdentity) }) } if len(m.cookie) > 0 { exts.AddUint16(extensionCookie) - exts.AddUint16LengthPrefixed(func { exts | exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(m.cookie) }) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(m.cookie) }) }) } if m.selectedGroup != 0 { exts.AddUint16(extensionKeyShare) - exts.AddUint16LengthPrefixed(func { exts | exts.AddUint16(uint16(m.selectedGroup)) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddUint16(uint16(m.selectedGroup)) }) } if len(m.supportedPoints) > 0 { exts.AddUint16(extensionSupportedPoints) - exts.AddUint16LengthPrefixed(func { exts | - exts.AddUint8LengthPrefixed(func { exts | exts.AddBytes(m.supportedPoints) }) + exts.AddUint16LengthPrefixed(func { exts -> + exts.AddUint8LengthPrefixed(func { exts -> exts.AddBytes(m.supportedPoints) }) }) } if len(m.encryptedClientHello) > 0 { exts.AddUint16(extensionEncryptedClientHello) - exts.AddUint16LengthPrefixed(func { exts | exts.AddBytes(m.encryptedClientHello) }) + exts.AddUint16LengthPrefixed(func { exts -> exts.AddBytes(m.encryptedClientHello) }) } if m.serverNameAck { exts.AddUint16(extensionServerName) @@ -778,15 +778,15 @@ func (m *serverHelloMsg) marshal() ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeServerHello) - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> b.AddUint16(m.vers) addBytesWithLength(b, m.random, 32) - b.AddUint8LengthPrefixed(func { b | b.AddBytes(m.sessionId) }) + b.AddUint8LengthPrefixed(func { b -> b.AddBytes(m.sessionId) }) b.AddUint16(m.cipherSuite) b.AddUint8(m.compressionMethod) if len(extBytes) > 0 { - b.AddUint16LengthPrefixed(func { b | b.AddBytes(extBytes) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(extBytes) }) } }) @@ -935,20 +935,20 @@ type encryptedExtensionsMsg struct { func (m *encryptedExtensionsMsg) marshal() ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeEncryptedExtensions) - b.AddUint24LengthPrefixed(func { b | - b.AddUint16LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> + b.AddUint16LengthPrefixed(func { b -> if len(m.alpnProtocol) > 0 { b.AddUint16(extensionALPN) - b.AddUint16LengthPrefixed(func { b | - b.AddUint16LengthPrefixed(func { b | - b.AddUint8LengthPrefixed(func { b | b.AddBytes([]byte(m.alpnProtocol)) }) + b.AddUint16LengthPrefixed(func { b -> + b.AddUint16LengthPrefixed(func { b -> + b.AddUint8LengthPrefixed(func { b -> b.AddBytes([]byte(m.alpnProtocol)) }) }) }) } if m.quicTransportParameters != nil { // marshal zero-length parameters when present // draft-ietf-quic-tls-32, Section 8.2 b.AddUint16(extensionQUICTransportParameters) - b.AddUint16LengthPrefixed(func { b | b.AddBytes(m.quicTransportParameters) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(m.quicTransportParameters) }) } if m.earlyData { // RFC 8446, Section 4.2.10 @@ -957,7 +957,7 @@ func (m *encryptedExtensionsMsg) marshal() ([]byte, error) { } if len(m.echRetryConfigs) > 0 { b.AddUint16(extensionEncryptedClientHello) - b.AddUint16LengthPrefixed(func { b | b.AddBytes(m.echRetryConfigs) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(m.echRetryConfigs) }) } }) }) @@ -1040,7 +1040,7 @@ type keyUpdateMsg struct { func (m *keyUpdateMsg) marshal() ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeKeyUpdate) - b.AddUint24LengthPrefixed(func { b | if m.updateRequested { + b.AddUint24LengthPrefixed(func { b -> if m.updateRequested { b.AddUint8(1) } else { b.AddUint8(0) @@ -1079,16 +1079,16 @@ type newSessionTicketMsgTLS13 struct { func (m *newSessionTicketMsgTLS13) marshal() ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeNewSessionTicket) - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> b.AddUint32(m.lifetime) b.AddUint32(m.ageAdd) - b.AddUint8LengthPrefixed(func { b | b.AddBytes(m.nonce) }) - b.AddUint16LengthPrefixed(func { b | b.AddBytes(m.label) }) + b.AddUint8LengthPrefixed(func { b -> b.AddBytes(m.nonce) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(m.label) }) - b.AddUint16LengthPrefixed(func { b | + b.AddUint16LengthPrefixed(func { b -> if m.maxEarlyData > 0 { b.AddUint16(extensionEarlyData) - b.AddUint16LengthPrefixed(func { b | b.AddUint32(m.maxEarlyData) }) + b.AddUint16LengthPrefixed(func { b -> b.AddUint32(m.maxEarlyData) }) } }) }) @@ -1148,12 +1148,12 @@ type certificateRequestMsgTLS13 struct { func (m *certificateRequestMsgTLS13) marshal() ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeCertificateRequest) - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> // certificate_request_context (SHALL be zero length unless used for // post-handshake authentication) b.AddUint8(0) - b.AddUint16LengthPrefixed(func { b | + b.AddUint16LengthPrefixed(func { b -> if m.ocspStapling { b.AddUint16(extensionStatusRequest) b.AddUint16(0) // empty extension_data @@ -1169,8 +1169,8 @@ func (m *certificateRequestMsgTLS13) marshal() ([]byte, error) { } if len(m.supportedSignatureAlgorithms) > 0 { b.AddUint16(extensionSignatureAlgorithms) - b.AddUint16LengthPrefixed(func { b | - b.AddUint16LengthPrefixed(func { b | + b.AddUint16LengthPrefixed(func { b -> + b.AddUint16LengthPrefixed(func { b -> for _, sigAlgo := range m.supportedSignatureAlgorithms { b.AddUint16(uint16(sigAlgo)) } @@ -1179,8 +1179,8 @@ func (m *certificateRequestMsgTLS13) marshal() ([]byte, error) { } if len(m.supportedSignatureAlgorithmsCert) > 0 { b.AddUint16(extensionSignatureAlgorithmsCert) - b.AddUint16LengthPrefixed(func { b | - b.AddUint16LengthPrefixed(func { b | + b.AddUint16LengthPrefixed(func { b -> + b.AddUint16LengthPrefixed(func { b -> for _, sigAlgo := range m.supportedSignatureAlgorithmsCert { b.AddUint16(uint16(sigAlgo)) } @@ -1189,10 +1189,10 @@ func (m *certificateRequestMsgTLS13) marshal() ([]byte, error) { } if len(m.certificateAuthorities) > 0 { b.AddUint16(extensionCertificateAuthorities) - b.AddUint16LengthPrefixed(func { b | - b.AddUint16LengthPrefixed(func { b | + b.AddUint16LengthPrefixed(func { b -> + b.AddUint16LengthPrefixed(func { b -> for _, ca := range m.certificateAuthorities { - b.AddUint16LengthPrefixed(func { b | b.AddBytes(ca) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(ca) }) } }) }) @@ -1358,7 +1358,7 @@ type certificateMsgTLS13 struct { func (m *certificateMsgTLS13) marshal() ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeCertificate) - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> b.AddUint8(0) // certificate_request_context certificate := m.certificate @@ -1375,27 +1375,27 @@ func (m *certificateMsgTLS13) marshal() ([]byte, error) { } func marshalCertificate(b *cryptobyte.Builder, certificate Certificate) { - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> for i, cert := range certificate.Certificate { - b.AddUint24LengthPrefixed(func { b | b.AddBytes(cert) }) - b.AddUint16LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> b.AddBytes(cert) }) + b.AddUint16LengthPrefixed(func { b -> if i > 0 { // This library only supports OCSP and SCT for leaf certificates. return } if certificate.OCSPStaple != nil { b.AddUint16(extensionStatusRequest) - b.AddUint16LengthPrefixed(func { b | + b.AddUint16LengthPrefixed(func { b -> b.AddUint8(statusTypeOCSP) - b.AddUint24LengthPrefixed(func { b | b.AddBytes(certificate.OCSPStaple) }) + b.AddUint24LengthPrefixed(func { b -> b.AddBytes(certificate.OCSPStaple) }) }) } if certificate.SignedCertificateTimestamps != nil { b.AddUint16(extensionSCT) - b.AddUint16LengthPrefixed(func { b | - b.AddUint16LengthPrefixed(func { b | + b.AddUint16LengthPrefixed(func { b -> + b.AddUint16LengthPrefixed(func { b -> for _, sct := range certificate.SignedCertificateTimestamps { - b.AddUint16LengthPrefixed(func { b | b.AddBytes(sct) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(sct) }) } }) }) @@ -1514,9 +1514,9 @@ type certificateStatusMsg struct { func (m *certificateStatusMsg) marshal() ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeCertificateStatus) - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> b.AddUint8(statusTypeOCSP) - b.AddUint24LengthPrefixed(func { b | b.AddBytes(m.response) }) + b.AddUint24LengthPrefixed(func { b -> b.AddBytes(m.response) }) }) return b.Bytes() @@ -1582,7 +1582,7 @@ type finishedMsg struct { func (m *finishedMsg) marshal() ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeFinished) - b.AddUint24LengthPrefixed(func { b | b.AddBytes(m.verifyData) }) + b.AddUint24LengthPrefixed(func { b -> b.AddBytes(m.verifyData) }) return b.Bytes() } @@ -1737,11 +1737,11 @@ type certificateVerifyMsg struct { func (m *certificateVerifyMsg) marshal() ([]byte, error) { var b cryptobyte.Builder b.AddUint8(typeCertificateVerify) - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> if m.hasSignatureAlgorithm { b.AddUint16(uint16(m.signatureAlgorithm)) } - b.AddUint16LengthPrefixed(func { b | b.AddBytes(m.signature) }) + b.AddUint16LengthPrefixed(func { b -> b.AddBytes(m.signature) }) }) return b.Bytes() diff --git a/src/crypto/tls/handshake_messages_test.go b/src/crypto/tls/handshake_messages_test.go index 2576ea7e85d47..19187a2ab269d 100644 --- a/src/crypto/tls/handshake_messages_test.go +++ b/src/crypto/tls/handshake_messages_test.go @@ -53,7 +53,7 @@ func TestMarshalUnmarshal(t *testing.T) { for i, m := range tests { ty := reflect.ValueOf(m).Type() - t.Run(ty.String(), func { t | + t.Run(ty.String(), func { t -> n := 100 if testing.Short() { n = 5 diff --git a/src/crypto/tls/handshake_server_test.go b/src/crypto/tls/handshake_server_test.go index 92388eb152f3c..d41f54cd91df0 100644 --- a/src/crypto/tls/handshake_server_test.go +++ b/src/crypto/tls/handshake_server_test.go @@ -328,7 +328,7 @@ func TestTLSPointFormats(t *testing.T) { {"RSA with ec_point_format", []uint16{TLS_RSA_WITH_AES_256_GCM_SHA384}, nil, []uint8{pointFormatUncompressed}, false}, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> clientHello := &clientHelloMsg{ vers: VersionTLS12, random: make([]byte, 32), @@ -460,8 +460,8 @@ func TestCipherSuitePreference(t *testing.T) { } func TestSCTHandshake(t *testing.T) { - t.Run("TLSv12", func { t | testSCTHandshake(t, VersionTLS12) }) - t.Run("TLSv13", func { t | testSCTHandshake(t, VersionTLS13) }) + t.Run("TLSv12", func { t -> testSCTHandshake(t, VersionTLS12) }) + t.Run("TLSv13", func { t -> testSCTHandshake(t, VersionTLS13) }) } func testSCTHandshake(t *testing.T, version uint16) { @@ -493,8 +493,8 @@ func testSCTHandshake(t *testing.T, version uint16) { } func TestCrossVersionResume(t *testing.T) { - t.Run("TLSv12", func { t | testCrossVersionResume(t, VersionTLS12) }) - t.Run("TLSv13", func { t | testCrossVersionResume(t, VersionTLS13) }) + t.Run("TLSv12", func { t -> testCrossVersionResume(t, VersionTLS12) }) + t.Run("TLSv13", func { t -> testCrossVersionResume(t, VersionTLS13) }) } func testCrossVersionResume(t *testing.T, version uint16) { @@ -1036,7 +1036,7 @@ func TestHandshakeServerSNIGetCertificate(t *testing.T) { // Replace the NameToCertificate map with a GetCertificate function nameToCert := config.NameToCertificate config.NameToCertificate = nil - config.GetCertificate = func { clientHello | + config.GetCertificate = func { clientHello -> cert := nameToCert[clientHello.ServerName] return cert, nil } @@ -1055,7 +1055,7 @@ func TestHandshakeServerSNIGetCertificate(t *testing.T) { func TestHandshakeServerSNIGetCertificateNotFound(t *testing.T) { config := testConfig.Clone() - config.GetCertificate = func { clientHello | return nil, nil } + config.GetCertificate = func { clientHello -> return nil, nil } test := &serverTest{ name: "SNI-GetCertificateNotFound", command: []string{"openssl", "s_client", "-no_ticket", "-cipher", "AES128-SHA", "-servername", "snitest.com"}, @@ -1070,7 +1070,7 @@ func TestHandshakeServerSNIGetCertificateError(t *testing.T) { const errMsg = "TestHandshakeServerSNIGetCertificateError error" serverConfig := testConfig.Clone() - serverConfig.GetCertificate = func { clientHello | return nil, errors.New(errMsg) } + serverConfig.GetCertificate = func { clientHello -> return nil, errors.New(errMsg) } clientHello := &clientHelloMsg{ vers: VersionTLS10, @@ -1088,7 +1088,7 @@ func TestHandshakeServerEmptyCertificates(t *testing.T) { const errMsg = "TestHandshakeServerEmptyCertificates error" serverConfig := testConfig.Clone() - serverConfig.GetCertificate = func { clientHello | return nil, errors.New(errMsg) } + serverConfig.GetCertificate = func { clientHello -> return nil, errors.New(errMsg) } serverConfig.Certificates = nil clientHello := &clientHelloMsg{ @@ -1305,49 +1305,49 @@ func benchmarkHandshakeServer(b *testing.B, version uint16, cipherSuite uint16, } func BenchmarkHandshakeServer(b *testing.B) { - b.Run("RSA", func { b | + b.Run("RSA", func { b -> benchmarkHandshakeServer(b, VersionTLS12, TLS_RSA_WITH_AES_128_GCM_SHA256, 0, testRSACertificate, testRSAPrivateKey) }) - b.Run("ECDHE-P256-RSA", func { b | - b.Run("TLSv13", func { b | + b.Run("ECDHE-P256-RSA", func { b -> + b.Run("TLSv13", func { b -> benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, CurveP256, testRSACertificate, testRSAPrivateKey) }) - b.Run("TLSv12", func { b | + b.Run("TLSv12", func { b -> benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305, CurveP256, testRSACertificate, testRSAPrivateKey) }) }) - b.Run("ECDHE-P256-ECDSA-P256", func { b | - b.Run("TLSv13", func { b | + b.Run("ECDHE-P256-ECDSA-P256", func { b -> + b.Run("TLSv13", func { b -> benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, CurveP256, testP256Certificate, testP256PrivateKey) }) - b.Run("TLSv12", func { b | + b.Run("TLSv12", func { b -> benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, CurveP256, testP256Certificate, testP256PrivateKey) }) }) - b.Run("ECDHE-X25519-ECDSA-P256", func { b | - b.Run("TLSv13", func { b | + b.Run("ECDHE-X25519-ECDSA-P256", func { b -> + b.Run("TLSv13", func { b -> benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, X25519, testP256Certificate, testP256PrivateKey) }) - b.Run("TLSv12", func { b | + b.Run("TLSv12", func { b -> benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, X25519, testP256Certificate, testP256PrivateKey) }) }) - b.Run("ECDHE-P521-ECDSA-P521", func { b | + b.Run("ECDHE-P521-ECDSA-P521", func { b -> if testECDSAPrivateKey.PublicKey.Curve != elliptic.P521() { b.Fatal("test ECDSA key doesn't use curve P-521") } - b.Run("TLSv13", func { b | + b.Run("TLSv13", func { b -> benchmarkHandshakeServer(b, VersionTLS13, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, CurveP521, testECDSACertificate, testECDSAPrivateKey) }) - b.Run("TLSv12", func { b | + b.Run("TLSv12", func { b -> benchmarkHandshakeServer(b, VersionTLS12, TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305, CurveP521, testECDSACertificate, testECDSAPrivateKey) }) @@ -1571,7 +1571,7 @@ func TestGetConfigForClient(t *testing.T) { } var configReturned *Config - serverConfig.GetConfigForClient = func { clientHello | + serverConfig.GetConfigForClient = func { clientHello -> config, err := test.callback(clientHello) configReturned = config return config, err @@ -1821,7 +1821,7 @@ func TestAESCipherReordering(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> hasAESGCMHardwareSupport = tc.serverHasAESGCM hs := &serverHandshakeState{ c: &Conn{ @@ -1920,7 +1920,7 @@ func TestAESCipherReorderingTLS13(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> hasAESGCMHardwareSupport = tc.serverHasAESGCM pk, _ := ecdh.X25519().GenerateKey(rand.Reader) hs := &serverHandshakeStateTLS13{ @@ -2000,7 +2000,7 @@ func TestHandshakeContextHierarchy(t *testing.T) { defer c.Close() var innerCtx context.Context clientConfig.Certificates = nil - clientConfig.GetClientCertificate = func { certificateRequest | + clientConfig.GetClientCertificate = func { certificateRequest -> if val, ok := certificateRequest.Context().Value(key).(bool); !ok || !val { t.Errorf("GetClientCertificate context was not child of HandshakeContext") } @@ -2025,7 +2025,7 @@ func TestHandshakeContextHierarchy(t *testing.T) { var innerCtx context.Context serverConfig.Certificates = nil serverConfig.ClientAuth = RequestClientCert - serverConfig.GetCertificate = func { clientHello | + serverConfig.GetCertificate = func { clientHello -> if val, ok := clientHello.Context().Value(key).(bool); !ok || !val { t.Errorf("GetClientCertificate context was not child of HandshakeContext") } diff --git a/src/crypto/tls/handshake_server_tls13.go b/src/crypto/tls/handshake_server_tls13.go index 843eb92c4ba3c..50e52167edcf3 100644 --- a/src/crypto/tls/handshake_server_tls13.go +++ b/src/crypto/tls/handshake_server_tls13.go @@ -185,7 +185,7 @@ func (hs *serverHandshakeStateTLS13) processClientHello() error { var clientKeyShare *keyShare preferredGroups := c.config.curvePreferences(c.vers) for _, preferredGroup := range preferredGroups { - ki := slices.IndexFunc(hs.clientHello.keyShares, func { ks | return ks.group == preferredGroup }) + ki := slices.IndexFunc(hs.clientHello.keyShares, func { ks -> return ks.group == preferredGroup }) if ki != -1 { clientKeyShare = &hs.clientHello.keyShares[ki] selectedGroup = clientKeyShare.group diff --git a/src/crypto/tls/handshake_test.go b/src/crypto/tls/handshake_test.go index 400f3140e90f3..d1bbd631122ed 100644 --- a/src/crypto/tls/handshake_test.go +++ b/src/crypto/tls/handshake_test.go @@ -50,7 +50,7 @@ var ( ) func runTestAndUpdateIfNeeded(t *testing.T, name string, run func(t *testing.T, update bool), wait bool) { - success := t.Run(name, func { t | + success := t.Run(name, func { t -> if !*update && !wait { t.Parallel() } @@ -58,7 +58,7 @@ func runTestAndUpdateIfNeeded(t *testing.T, name string, run func(t *testing.T, }) if !success && *update { - t.Run(name+"#update", func { t | run(t, true) }) + t.Run(name+"#update", func { t -> run(t, true) }) } } diff --git a/src/crypto/tls/handshake_unix_test.go b/src/crypto/tls/handshake_unix_test.go index 1fdae97bfb7e1..cff44021a961b 100644 --- a/src/crypto/tls/handshake_unix_test.go +++ b/src/crypto/tls/handshake_unix_test.go @@ -12,5 +12,5 @@ import ( ) func init() { - isConnRefused = func { err | return errors.Is(err, syscall.ECONNREFUSED) } + isConnRefused = func { err -> return errors.Is(err, syscall.ECONNREFUSED) } } diff --git a/src/crypto/tls/key_schedule.go b/src/crypto/tls/key_schedule.go index fdbf4a1294141..ae76c97d788d6 100644 --- a/src/crypto/tls/key_schedule.go +++ b/src/crypto/tls/key_schedule.go @@ -37,11 +37,11 @@ const ( func (c *cipherSuiteTLS13) expandLabel(secret []byte, label string, context []byte, length int) []byte { var hkdfLabel cryptobyte.Builder hkdfLabel.AddUint16(uint16(length)) - hkdfLabel.AddUint8LengthPrefixed(func { b | + hkdfLabel.AddUint8LengthPrefixed(func { b -> b.AddBytes([]byte("tls13 ")) b.AddBytes([]byte(label)) }) - hkdfLabel.AddUint8LengthPrefixed(func { b | b.AddBytes(context) }) + hkdfLabel.AddUint8LengthPrefixed(func { b -> b.AddBytes(context) }) hkdfLabelBytes, err := hkdfLabel.Bytes() if err != nil { // Rather than calling BytesOrPanic, we explicitly handle this error, in diff --git a/src/crypto/tls/key_schedule_test.go b/src/crypto/tls/key_schedule_test.go index e5fd474a0449f..61aa303f746a4 100644 --- a/src/crypto/tls/key_schedule_test.go +++ b/src/crypto/tls/key_schedule_test.go @@ -17,7 +17,7 @@ import ( // This file contains tests derived from draft-ietf-tls-tls13-vectors-07. func parseVector(v string) []byte { - v = strings.Map(func { c | + v = strings.Map(func { c -> if unicode.IsSpace(c) { return -1 } @@ -95,7 +95,7 @@ func TestDeriveSecret(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> c := cipherSuitesTLS13[0] if got := c.deriveSecret(tt.args.secret, tt.args.label, tt.args.transcript); !bytes.Equal(got, tt.want) { t.Errorf("cipherSuiteTLS13.deriveSecret() = % x, want % x", got, tt.want) @@ -166,7 +166,7 @@ func TestExtract(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> c := cipherSuitesTLS13[0] if got := c.extract(tt.args.newSecret, tt.args.currentSecret); !bytes.Equal(got, tt.want) { t.Errorf("cipherSuiteTLS13.extract() = % x, want % x", got, tt.want) diff --git a/src/crypto/tls/link_test.go b/src/crypto/tls/link_test.go index 5323b296e66cb..c51f5b8d9cc6e 100644 --- a/src/crypto/tls/link_test.go +++ b/src/crypto/tls/link_test.go @@ -75,7 +75,7 @@ func main() { tls.Dial("", "", nil) } goFile := filepath.Join(tmpDir, "x.go") exeFile := filepath.Join(tmpDir, "x.exe") for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> if err := os.WriteFile(goFile, []byte(tt.program), 0644); err != nil { t.Fatal(err) } diff --git a/src/crypto/tls/quic_test.go b/src/crypto/tls/quic_test.go index d7513f9b0f1f2..bc9f81417dbfd 100644 --- a/src/crypto/tls/quic_test.go +++ b/src/crypto/tls/quic_test.go @@ -399,7 +399,7 @@ func TestQUICStartContextPropagation(t *testing.T) { config := &QUICConfig{TLSConfig: testConfig.Clone()} config.TLSConfig.MinVersion = VersionTLS13 calls := 0 - config.TLSConfig.GetConfigForClient = func { info | + config.TLSConfig.GetConfigForClient = func { info -> calls++ got, _ := info.Context().Value(key).(string) if got != value { @@ -560,8 +560,8 @@ func TestQUICEarlyData(t *testing.T) { } func TestQUICEarlyDataDeclined(t *testing.T) { - t.Run("server", func { t | testQUICEarlyDataDeclined(t, true) }) - t.Run("client", func { t | testQUICEarlyDataDeclined(t, false) }) + t.Run("server", func { t -> testQUICEarlyDataDeclined(t, true) }) + t.Run("client", func { t -> testQUICEarlyDataDeclined(t, false) }) } func testQUICEarlyDataDeclined(t *testing.T, server bool) { diff --git a/src/crypto/tls/ticket.go b/src/crypto/tls/ticket.go index 08bfdb0d4c2c7..33dde63e9091c 100644 --- a/src/crypto/tls/ticket.go +++ b/src/crypto/tls/ticket.go @@ -115,10 +115,10 @@ func (s *SessionState) Bytes() ([]byte, error) { } b.AddUint16(s.cipherSuite) addUint64(&b, s.createdAt) - b.AddUint8LengthPrefixed(func { b | b.AddBytes(s.secret) }) - b.AddUint24LengthPrefixed(func { b | + b.AddUint8LengthPrefixed(func { b -> b.AddBytes(s.secret) }) + b.AddUint24LengthPrefixed(func { b -> for _, extra := range s.Extra { - b.AddUint24LengthPrefixed(func { b | b.AddBytes(extra) }) + b.AddUint24LengthPrefixed(func { b -> b.AddBytes(extra) }) } }) if s.extMasterSecret { @@ -136,22 +136,22 @@ func (s *SessionState) Bytes() ([]byte, error) { OCSPStaple: s.ocspResponse, SignedCertificateTimestamps: s.scts, }) - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> for _, chain := range s.verifiedChains { - b.AddUint24LengthPrefixed(func { b | + b.AddUint24LengthPrefixed(func { b -> // We elide the first certificate because it's always the leaf. if len(chain) == 0 { b.SetError(errors.New("tls: internal error: empty verified chain")) return } for _, cert := range chain[1:] { - b.AddUint24LengthPrefixed(func { b | b.AddBytes(cert.Raw) }) + b.AddUint24LengthPrefixed(func { b -> b.AddBytes(cert.Raw) }) } }) } }) if s.EarlyData { - b.AddUint8LengthPrefixed(func { b | b.AddBytes([]byte(s.alpnProtocol)) }) + b.AddUint8LengthPrefixed(func { b -> b.AddBytes([]byte(s.alpnProtocol)) }) } if s.isClient { if s.version >= VersionTLS13 { diff --git a/src/crypto/tls/tls_test.go b/src/crypto/tls/tls_test.go index dbdd65f75ae01..fd0bedcdb824b 100644 --- a/src/crypto/tls/tls_test.go +++ b/src/crypto/tls/tls_test.go @@ -987,9 +987,9 @@ func BenchmarkThroughput(b *testing.B) { for _, mode := range []string{"Max", "Dynamic"} { for size := 1; size <= 64; size <<= 1 { name := fmt.Sprintf("%sPacket/%dMB", mode, size) - b.Run(name, func { b | - b.Run("TLSv12", func { b | throughput(b, VersionTLS12, int64(size<<20), mode == "Max") }) - b.Run("TLSv13", func { b | throughput(b, VersionTLS13, int64(size<<20), mode == "Max") }) + b.Run(name, func { b -> + b.Run("TLSv12", func { b -> throughput(b, VersionTLS12, int64(size<<20), mode == "Max") }) + b.Run("TLSv13", func { b -> throughput(b, VersionTLS13, int64(size<<20), mode == "Max") }) }) } } @@ -1080,9 +1080,9 @@ func BenchmarkLatency(b *testing.B) { for _, mode := range []string{"Max", "Dynamic"} { for _, kbps := range []int{200, 500, 1000, 2000, 5000} { name := fmt.Sprintf("%sPacket/%dkbps", mode, kbps) - b.Run(name, func { b | - b.Run("TLSv12", func { b | latency(b, VersionTLS12, kbps*1000, mode == "Max") }) - b.Run("TLSv13", func { b | latency(b, VersionTLS13, kbps*1000, mode == "Max") }) + b.Run(name, func { b -> + b.Run("TLSv12", func { b -> latency(b, VersionTLS12, kbps*1000, mode == "Max") }) + b.Run("TLSv13", func { b -> latency(b, VersionTLS13, kbps*1000, mode == "Max") }) }) } } @@ -1119,7 +1119,7 @@ func TestConnectionState(t *testing.T) { case VersionTLS13: name = "TLSv13" } - t.Run(name, func { t | + t.Run(name, func { t -> config := &Config{ Time: now, Rand: zeroSource{}, @@ -1687,8 +1687,8 @@ func TestPKCS1OnlyCert(t *testing.T) { func TestVerifyCertificates(t *testing.T) { // See https://go.dev/issue/31641. - t.Run("TLSv12", func { t | testVerifyCertificates(t, VersionTLS12) }) - t.Run("TLSv13", func { t | testVerifyCertificates(t, VersionTLS13) }) + t.Run("TLSv12", func { t -> testVerifyCertificates(t, VersionTLS12) }) + t.Run("TLSv13", func { t -> testVerifyCertificates(t, VersionTLS13) }) } func testVerifyCertificates(t *testing.T, version uint16) { @@ -1745,7 +1745,7 @@ func testVerifyCertificates(t *testing.T, version uint16) { for _, test := range tests { test := test - t.Run(test.name, func { t | + t.Run(test.name, func { t -> t.Parallel() var serverVerifyConnection, clientVerifyConnection bool @@ -1761,19 +1761,19 @@ func testVerifyCertificates(t *testing.T, version uint16) { serverConfig := clientConfig.Clone() serverConfig.ClientCAs = rootCAs - clientConfig.VerifyConnection = func { cs | + clientConfig.VerifyConnection = func { cs -> clientVerifyConnection = true return nil } - clientConfig.VerifyPeerCertificate = func { rawCerts, verifiedChains | + clientConfig.VerifyPeerCertificate = func { rawCerts, verifiedChains -> clientVerifyPeerCertificates = true return nil } - serverConfig.VerifyConnection = func { cs | + serverConfig.VerifyConnection = func { cs -> serverVerifyConnection = true return nil } - serverConfig.VerifyPeerCertificate = func { rawCerts, verifiedChains | + serverConfig.VerifyPeerCertificate = func { rawCerts, verifiedChains -> serverVerifyPeerCertificates = true return nil } @@ -1901,7 +1901,7 @@ func TestHandshakeKyber(t *testing.T) { baseConfig := testConfig.Clone() baseConfig.CurvePreferences = nil for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> if test.preparation != nil { test.preparation(t) } else { @@ -1911,7 +1911,7 @@ func TestHandshakeKyber(t *testing.T) { if test.serverConfig != nil { test.serverConfig(serverConfig) } - serverConfig.GetConfigForClient = func { hello | + serverConfig.GetConfigForClient = func { hello -> if !test.expectClientSupport && slices.Contains(hello.SupportedCurves, x25519Kyber768Draft00) { return nil, errors.New("client supports Kyber768Draft00") } else if test.expectClientSupport && !slices.Contains(hello.SupportedCurves, x25519Kyber768Draft00) { @@ -1981,7 +1981,7 @@ func TestX509KeyPairPopulateCertificate(t *testing.T) { } certPEM := pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}) - t.Run("x509keypairleaf=0", func { t | + t.Run("x509keypairleaf=0", func { t -> t.Setenv("GODEBUG", "x509keypairleaf=0") cert, err := X509KeyPair(certPEM, keyPEM) if err != nil { @@ -1991,7 +1991,7 @@ func TestX509KeyPairPopulateCertificate(t *testing.T) { t.Fatal("Leaf should not be populated") } }) - t.Run("x509keypairleaf=1", func { t | + t.Run("x509keypairleaf=1", func { t -> t.Setenv("GODEBUG", "x509keypairleaf=1") cert, err := X509KeyPair(certPEM, keyPEM) if err != nil { @@ -2001,7 +2001,7 @@ func TestX509KeyPairPopulateCertificate(t *testing.T) { t.Fatal("Leaf should be populated") } }) - t.Run("GODEBUG unset", func { t | + t.Run("GODEBUG unset", func { t -> cert, err := X509KeyPair(certPEM, keyPEM) if err != nil { t.Fatal(err) diff --git a/src/crypto/x509/cert_pool_test.go b/src/crypto/x509/cert_pool_test.go index 5012b3eca5ba3..997737a6ae7a0 100644 --- a/src/crypto/x509/cert_pool_test.go +++ b/src/crypto/x509/cert_pool_test.go @@ -98,7 +98,7 @@ func TestCertPoolEqual(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> equal := tc.a.Equal(tc.b) if equal != tc.equal { t.Errorf("Unexpected Equal result: got %t, want %t", equal, tc.equal) diff --git a/src/crypto/x509/name_constraints_test.go b/src/crypto/x509/name_constraints_test.go index 751f4adf2c152..d1a0853956ed0 100644 --- a/src/crypto/x509/name_constraints_test.go +++ b/src/crypto/x509/name_constraints_test.go @@ -1868,7 +1868,7 @@ func TestConstraintCases(t *testing.T) { } for i, test := range nameConstraintsTests { - t.Run(fmt.Sprintf("#%d", i), func { t | + t.Run(fmt.Sprintf("#%d", i), func { t -> rootPool := NewCertPool() rootKey := privateKeys.Get().(*ecdsa.PrivateKey) rootName := "Root " + strconv.Itoa(i) diff --git a/src/crypto/x509/parser.go b/src/crypto/x509/parser.go index d18642f0734c3..603674505f56a 100644 --- a/src/crypto/x509/parser.go +++ b/src/crypto/x509/parser.go @@ -372,7 +372,7 @@ func forEachSAN(der cryptobyte.String, callback func(tag int, data []byte) error } func parseSANExtension(der cryptobyte.String) (dnsNames, emailAddresses []string, ipAddresses []net.IP, uris []*url.URL, err error) { - err = forEachSAN(der, func { tag, data | + err = forEachSAN(der, func { tag, data -> switch tag { case nameTypeEmail: email := string(data) diff --git a/src/crypto/x509/parser_test.go b/src/crypto/x509/parser_test.go index 14b511b49ffa1..83f4512ca9312 100644 --- a/src/crypto/x509/parser_test.go +++ b/src/crypto/x509/parser_test.go @@ -88,7 +88,7 @@ func TestParseASN1String(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> out, err := parseASN1String(tc.tag, tc.value) if err != nil && err.Error() != tc.expectedErr { t.Fatalf("parseASN1String returned unexpected error: got %q, want %q", err, tc.expectedErr) diff --git a/src/crypto/x509/platform_test.go b/src/crypto/x509/platform_test.go index 51e4e54291995..2c9ea630a6e99 100644 --- a/src/crypto/x509/platform_test.go +++ b/src/crypto/x509/platform_test.go @@ -203,7 +203,7 @@ func TestPlatformVerifier(t *testing.T) { for _, tc := range tests { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() parent := testRoot if tc.selfSigned { diff --git a/src/crypto/x509/root_test.go b/src/crypto/x509/root_test.go index 799e6e6213c35..2426fe984f5fd 100644 --- a/src/crypto/x509/root_test.go +++ b/src/crypto/x509/root_test.go @@ -78,7 +78,7 @@ func TestFallback(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> fallbacksSet = false systemRoots = tc.systemRoots if systemRoots != nil { diff --git a/src/crypto/x509/root_unix_test.go b/src/crypto/x509/root_unix_test.go index 642a3901733dc..891b014e6a5bf 100644 --- a/src/crypto/x509/root_unix_test.go +++ b/src/crypto/x509/root_unix_test.go @@ -91,7 +91,7 @@ func TestEnvVars(t *testing.T) { }() for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> if err := os.Setenv(certFileEnv, tc.fileEnv); err != nil { t.Fatalf("setenv %q failed: %v", certFileEnv, err) } diff --git a/src/crypto/x509/verify.go b/src/crypto/x509/verify.go index 9d3937bd1ff7f..5ecc0d3829c41 100644 --- a/src/crypto/x509/verify.go +++ b/src/crypto/x509/verify.go @@ -611,7 +611,7 @@ func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *V } } for _, sanCert := range toCheck { - err := forEachSAN(sanCert.getSANExtension(), func { tag, data | + err := forEachSAN(sanCert.getSANExtension(), func { tag, data -> switch tag { case nameTypeEmail: name := string(data) @@ -621,7 +621,7 @@ func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *V } if err := c.checkNameConstraints(&comparisonCount, maxConstraintComparisons, "email address", name, mailbox, - func { parsedName, constraint | return matchEmailConstraint(parsedName.(rfc2821Mailbox), constraint.(string)) }, c.PermittedEmailAddresses, c.ExcludedEmailAddresses); err != nil { + func { parsedName, constraint -> return matchEmailConstraint(parsedName.(rfc2821Mailbox), constraint.(string)) }, c.PermittedEmailAddresses, c.ExcludedEmailAddresses); err != nil { return err } @@ -632,7 +632,7 @@ func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *V } if err := c.checkNameConstraints(&comparisonCount, maxConstraintComparisons, "DNS name", name, name, - func { parsedName, constraint | return matchDomainConstraint(parsedName.(string), constraint.(string)) }, c.PermittedDNSDomains, c.ExcludedDNSDomains); err != nil { + func { parsedName, constraint -> return matchDomainConstraint(parsedName.(string), constraint.(string)) }, c.PermittedDNSDomains, c.ExcludedDNSDomains); err != nil { return err } @@ -644,7 +644,7 @@ func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *V } if err := c.checkNameConstraints(&comparisonCount, maxConstraintComparisons, "URI", name, uri, - func { parsedName, constraint | return matchURIConstraint(parsedName.(*url.URL), constraint.(string)) }, c.PermittedURIDomains, c.ExcludedURIDomains); err != nil { + func { parsedName, constraint -> return matchURIConstraint(parsedName.(*url.URL), constraint.(string)) }, c.PermittedURIDomains, c.ExcludedURIDomains); err != nil { return err } @@ -655,7 +655,7 @@ func (c *Certificate) isValid(certType int, currentChain []*Certificate, opts *V } if err := c.checkNameConstraints(&comparisonCount, maxConstraintComparisons, "IP address", ip.String(), ip, - func { parsedName, constraint | return matchIPConstraint(parsedName.(net.IP), constraint.(*net.IPNet)) }, c.PermittedIPRanges, c.ExcludedIPRanges); err != nil { + func { parsedName, constraint -> return matchIPConstraint(parsedName.(net.IP), constraint.(*net.IPNet)) }, c.PermittedIPRanges, c.ExcludedIPRanges); err != nil { return err } diff --git a/src/crypto/x509/verify_test.go b/src/crypto/x509/verify_test.go index 41959ad10aba7..9774a5e9efea1 100644 --- a/src/crypto/x509/verify_test.go +++ b/src/crypto/x509/verify_test.go @@ -558,7 +558,7 @@ func TestGoVerify(t *testing.T) { t.Setenv("GODEBUG", "x509sha1=1") for _, test := range verifyTests { - t.Run(test.name, func { t | testVerify(t, test, false) }) + t.Run(test.name, func { t -> testVerify(t, test, false) }) } } @@ -568,7 +568,7 @@ func TestSystemVerify(t *testing.T) { } for _, test := range verifyTests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> if test.systemSkip { t.SkipNow() } @@ -1503,7 +1503,7 @@ var unknownAuthorityErrorTests = []struct { func TestUnknownAuthorityError(t *testing.T) { for i, tt := range unknownAuthorityErrorTests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> der, _ := pem.Decode([]byte(tt.cert)) if der == nil { t.Fatalf("#%d: Unable to decode PEM block", i) @@ -1909,7 +1909,7 @@ func TestIssue51759(t *testing.T) { t.Fatal(err) } - t.Run("leaf", func { t | + t.Run("leaf", func { t -> opts := VerifyOptions{} expectedErr := "invalid leaf certificate" _, err = badCert.Verify(opts) @@ -1923,7 +1923,7 @@ func TestIssue51759(t *testing.T) { t.Fatal(err) } - t.Run("intermediate", func { t | + t.Run("intermediate", func { t -> opts := VerifyOptions{ Intermediates: NewCertPool(), } @@ -2580,7 +2580,7 @@ func TestPathBuilding(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> roots, intermediates, leaf := buildTrustGraph(t, tc.graph) chains, err := leaf.Verify(VerifyOptions{ Roots: roots, @@ -2686,9 +2686,9 @@ func TestEKUEnforcement(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> rootPool := NewCertPool() - root := genCertEdge(t, "root", k, func { c | + root := genCertEdge(t, "root", k, func { c -> c.ExtKeyUsage = tc.root.EKUs c.UnknownExtKeyUsage = tc.root.Unknown }, rootCertificate, nil, k) @@ -2697,7 +2697,7 @@ func TestEKUEnforcement(t *testing.T) { parent := root interPool := NewCertPool() for i, interEKUs := range tc.inters { - inter := genCertEdge(t, fmt.Sprintf("inter %d", i), k, func { c | + inter := genCertEdge(t, fmt.Sprintf("inter %d", i), k, func { c -> c.ExtKeyUsage = interEKUs.EKUs c.UnknownExtKeyUsage = interEKUs.Unknown }, intermediateCertificate, parent, k) @@ -2705,7 +2705,7 @@ func TestEKUEnforcement(t *testing.T) { parent = inter } - leaf := genCertEdge(t, "leaf", k, func { c | + leaf := genCertEdge(t, "leaf", k, func { c -> c.ExtKeyUsage = tc.leaf.EKUs c.UnknownExtKeyUsage = tc.leaf.Unknown }, intermediateCertificate, parent, k) @@ -2760,7 +2760,7 @@ func TestVerifyEKURootAsLeaf(t *testing.T) { succeed: false, }, } { - t.Run(fmt.Sprintf("root EKUs %#v, verify EKUs %#v", tc.rootEKUs, tc.verifyEKUs), func { t | + t.Run(fmt.Sprintf("root EKUs %#v, verify EKUs %#v", tc.rootEKUs, tc.verifyEKUs), func { t -> tmpl := &Certificate{ SerialNumber: big.NewInt(1), Subject: pkix.Name{CommonName: "root"}, diff --git a/src/crypto/x509/x509.go b/src/crypto/x509/x509.go index 7cd617127e17c..1dda44437d191 100644 --- a/src/crypto/x509/x509.go +++ b/src/crypto/x509/x509.go @@ -1232,14 +1232,14 @@ func buildCertExtensions(template *Certificate, subjectIsEmpty bool, authorityKe return nil, err } - b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b | - b.AddASN1(cryptobyte_asn1.Tag(2).ContextSpecific(), func { b | b.AddBytes([]byte(name)) }) + b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b -> + b.AddASN1(cryptobyte_asn1.Tag(2).ContextSpecific(), func { b -> b.AddBytes([]byte(name)) }) }) } for _, ipNet := range ips { - b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b | - b.AddASN1(cryptobyte_asn1.Tag(7).ContextSpecific(), func { b | b.AddBytes(ipAndMask(ipNet)) }) + b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b -> + b.AddASN1(cryptobyte_asn1.Tag(7).ContextSpecific(), func { b -> b.AddBytes(ipAndMask(ipNet)) }) }) } @@ -1248,8 +1248,8 @@ func buildCertExtensions(template *Certificate, subjectIsEmpty bool, authorityKe return nil, err } - b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b | - b.AddASN1(cryptobyte_asn1.Tag(1).ContextSpecific(), func { b | b.AddBytes([]byte(email)) }) + b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b -> + b.AddASN1(cryptobyte_asn1.Tag(1).ContextSpecific(), func { b -> b.AddBytes([]byte(email)) }) }) } @@ -1258,8 +1258,8 @@ func buildCertExtensions(template *Certificate, subjectIsEmpty bool, authorityKe return nil, err } - b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b | - b.AddASN1(cryptobyte_asn1.Tag(6).ContextSpecific(), func { b | b.AddBytes([]byte(uriDomain)) }) + b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b -> + b.AddASN1(cryptobyte_asn1.Tag(6).ContextSpecific(), func { b -> b.AddBytes([]byte(uriDomain)) }) }) } @@ -1277,13 +1277,13 @@ func buildCertExtensions(template *Certificate, subjectIsEmpty bool, authorityKe } var b cryptobyte.Builder - b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b | + b.AddASN1(cryptobyte_asn1.SEQUENCE, func { b -> if len(permitted) > 0 { - b.AddASN1(cryptobyte_asn1.Tag(0).ContextSpecific().Constructed(), func { b | b.AddBytes(permitted) }) + b.AddASN1(cryptobyte_asn1.Tag(0).ContextSpecific().Constructed(), func { b -> b.AddBytes(permitted) }) } if len(excluded) > 0 { - b.AddASN1(cryptobyte_asn1.Tag(1).ContextSpecific().Constructed(), func { b | b.AddBytes(excluded) }) + b.AddASN1(cryptobyte_asn1.Tag(1).ContextSpecific().Constructed(), func { b -> b.AddBytes(excluded) }) } }) @@ -1378,12 +1378,12 @@ func marshalCertificatePolicies(policies []OID, policyIdentifiers []asn1.ObjectI ext := pkix.Extension{Id: oidExtensionCertificatePolicies} b := cryptobyte.NewBuilder(make([]byte, 0, 128)) - b.AddASN1(cryptobyte_asn1.SEQUENCE, func { child | + b.AddASN1(cryptobyte_asn1.SEQUENCE, func { child -> if x509usepolicies.Value() == "1" { x509usepolicies.IncNonDefault() for _, v := range policies { - child.AddASN1(cryptobyte_asn1.SEQUENCE, func { child | - child.AddASN1(cryptobyte_asn1.OBJECT_IDENTIFIER, func { child | + child.AddASN1(cryptobyte_asn1.SEQUENCE, func { child -> + child.AddASN1(cryptobyte_asn1.OBJECT_IDENTIFIER, func { child -> if len(v.der) == 0 { child.SetError(errors.New("invalid policy object identifier")) return @@ -1394,7 +1394,7 @@ func marshalCertificatePolicies(policies []OID, policyIdentifiers []asn1.ObjectI } } else { for _, v := range policyIdentifiers { - child.AddASN1(cryptobyte_asn1.SEQUENCE, func { child | child.AddASN1ObjectIdentifier(v) }) + child.AddASN1(cryptobyte_asn1.SEQUENCE, func { child -> child.AddASN1ObjectIdentifier(v) }) } } }) diff --git a/src/crypto/x509/x509_test.go b/src/crypto/x509/x509_test.go index c65d28754868c..ba93e1ae6d394 100644 --- a/src/crypto/x509/x509_test.go +++ b/src/crypto/x509/x509_test.go @@ -105,21 +105,21 @@ func testParsePKIXPublicKey(t *testing.T, pemBytes string) (pub any) { } func TestParsePKIXPublicKey(t *testing.T) { - t.Run("RSA", func { t | + t.Run("RSA", func { t -> pub := testParsePKIXPublicKey(t, pemPublicKey) _, ok := pub.(*rsa.PublicKey) if !ok { t.Errorf("Value returned from ParsePKIXPublicKey was not an RSA public key") } }) - t.Run("Ed25519", func { t | + t.Run("Ed25519", func { t -> pub := testParsePKIXPublicKey(t, pemEd25519Key) _, ok := pub.(ed25519.PublicKey) if !ok { t.Errorf("Value returned from ParsePKIXPublicKey was not an Ed25519 public key") } }) - t.Run("X25519", func { t | + t.Run("X25519", func { t -> pub := testParsePKIXPublicKey(t, pemX25519Key) k, ok := pub.(*ecdh.PublicKey) if !ok || k.Curve() != ecdh.X25519() { @@ -2784,7 +2784,7 @@ func TestCreateRevocationList(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> crl, err := CreateRevocationList(rand.Reader, tc.template, tc.issuer, tc.key) if err != nil && tc.expectedError == "" { t.Fatalf("CreateRevocationList failed unexpectedly: %s", err) @@ -3034,7 +3034,7 @@ func TestIA5SANEnforcement(t *testing.T) { } for _, tc := range marshalTests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> _, err := CreateCertificate(rand.Reader, tc.template, tc.template, k.Public(), k) if err == nil { t.Errorf("expected CreateCertificate to fail with template: %v", tc.template) @@ -3114,7 +3114,7 @@ func BenchmarkCreateCertificate(b *testing.B) { for _, tc := range tests { k := tc.gen() b.ResetTimer() - b.Run(tc.name, func { b | + b.Run(tc.name, func { b -> for i := 0; i < b.N; i++ { _, err := CreateCertificate(rand.Reader, template, template, k.Public(), k) if err != nil { @@ -3359,7 +3359,7 @@ Qc4= }, } for _, c := range cases { - b.Run(c.name, func { b | + b.Run(c.name, func { b -> pemBlock, _ := pem.Decode([]byte(c.pem)) b.ReportAllocs() b.ResetTimer() @@ -3775,7 +3775,7 @@ func TestRevocationListCheckSignatureFrom(t *testing.T) { SubjectKeyId: []byte{1, 2, 3}, } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> crlDER, err := CreateRevocationList(rand.Reader, &RevocationList{Number: big.NewInt(1)}, crlIssuer, goodKey) if err != nil { t.Fatalf("failed to generate CRL: %s", err) diff --git a/src/database/sql/convert_test.go b/src/database/sql/convert_test.go index 79fc101dca6f6..f2d99c0c20b4f 100644 --- a/src/database/sql/convert_test.go +++ b/src/database/sql/convert_test.go @@ -583,7 +583,7 @@ func TestDecimal(t *testing.T) { {name: "bad-form", in: dec{form: 200}, err: true}, } for _, item := range list { - t.Run(item.name, func { t | + t.Run(item.name, func { t -> out := dec{} err := convertAssign(&out, item.in) if item.err { diff --git a/src/database/sql/sql.go b/src/database/sql/sql.go index fe33dc398cd87..43f66b7ebbe40 100644 --- a/src/database/sql/sql.go +++ b/src/database/sql/sql.go @@ -888,7 +888,7 @@ func (db *DB) PingContext(ctx context.Context) error { var dc *driverConn var err error - err = db.retry(func { strategy | + err = db.retry(func { strategy -> dc, err = db.conn(ctx, strategy) return err }) @@ -1587,7 +1587,7 @@ func (db *DB) PrepareContext(ctx context.Context, query string) (*Stmt, error) { var stmt *Stmt var err error - err = db.retry(func { strategy | + err = db.retry(func { strategy -> stmt, err = db.prepare(ctx, query, strategy) return err }) @@ -1660,7 +1660,7 @@ func (db *DB) ExecContext(ctx context.Context, query string, args ...any) (Resul var res Result var err error - err = db.retry(func { strategy | + err = db.retry(func { strategy -> res, err = db.exec(ctx, query, args, strategy) return err }) @@ -1730,7 +1730,7 @@ func (db *DB) QueryContext(ctx context.Context, query string, args ...any) (*Row var rows *Rows var err error - err = db.retry(func { strategy | + err = db.retry(func { strategy -> rows, err = db.query(ctx, query, args, strategy) return err }) @@ -1862,7 +1862,7 @@ func (db *DB) BeginTx(ctx context.Context, opts *TxOptions) (*Tx, error) { var tx *Tx var err error - err = db.retry(func { strategy | + err = db.retry(func { strategy -> tx, err = db.begin(ctx, opts, strategy) return err }) @@ -1938,7 +1938,7 @@ func (db *DB) Conn(ctx context.Context) (*Conn, error) { var dc *driverConn var err error - err = db.retry(func { strategy | + err = db.retry(func { strategy -> dc, err = db.conn(ctx, strategy) return err }) @@ -2637,7 +2637,7 @@ func (s *Stmt) ExecContext(ctx context.Context, args ...any) (Result, error) { defer s.closemu.RUnlock() var res Result - err := s.db.retry(func { strategy | + err := s.db.retry(func { strategy -> dc, releaseConn, ds, err := s.connStmt(ctx, strategy) if err != nil { return err @@ -2781,7 +2781,7 @@ func (s *Stmt) QueryContext(ctx context.Context, args ...any) (*Rows, error) { var rowsi driver.Rows var rows *Rows - err := s.db.retry(func { strategy | + err := s.db.retry(func { strategy -> dc, releaseConn, ds, err := s.connStmt(ctx, strategy) if err != nil { return err @@ -2802,7 +2802,7 @@ func (s *Stmt) QueryContext(ctx context.Context, args ...any) (*Rows, error) { // releaseConn must be set before initContextClose or it could // release the connection before it is set. - rows.releaseConn = func { err | + rows.releaseConn = func { err -> releaseConn(err) s.db.removeDep(s, rows) } diff --git a/src/database/sql/sql_test.go b/src/database/sql/sql_test.go index 4edfea9f94e33..61fb5e01a10e5 100644 --- a/src/database/sql/sql_test.go +++ b/src/database/sql/sql_test.go @@ -39,7 +39,7 @@ func init() { defer mu.Unlock() freedFrom[c] = s } - putConnHook = func { db, c | + putConnHook = func { db, c -> if slices.Contains(db.freeConn, c) { // print before panic, as panic may get lost due to conflicting panic // (all goroutines asleep) elsewhere, since we might not unlock @@ -149,7 +149,7 @@ func closeDB(t testing.TB, db *DB) { panic(e) } defer setHookpostCloseConn(nil) - setHookpostCloseConn(func { _, err | if err != nil { + setHookpostCloseConn(func { _, err -> if err != nil { t.Errorf("Error closing fakeConn: %v", err) } }) db.mu.Lock() @@ -424,7 +424,7 @@ func TestQueryContextWait(t *testing.T) { t.Fatal(err) } - c.dc.ci.(*fakeConn).waiter = func { c | + c.dc.ci.(*fakeConn).waiter = func { c -> cancel() <-ctx.Done() } @@ -465,7 +465,7 @@ func testContextWait(t *testing.T, keepConnOnRollback bool) { } tx.keepConnOnRollback = keepConnOnRollback - tx.dc.ci.(*fakeConn).waiter = func { c | + tx.dc.ci.(*fakeConn).waiter = func { c -> cancel() <-ctx.Done() } @@ -1410,7 +1410,7 @@ func TestConnRaw(t *testing.T) { defer conn.Close() sawFunc := false - err = conn.Raw(func { dc | + err = conn.Raw(func { dc -> sawFunc = true if _, ok := dc.(*fakeConn); !ok { return fmt.Errorf("got %T want *fakeConn", dc) @@ -1437,7 +1437,7 @@ func TestConnRaw(t *testing.T) { t.Fatal("expected connection to be closed after panic") } }() - err = conn.Raw(func { dc | panic("Conn.Raw panic should return an error") }) + err = conn.Raw(func { dc -> panic("Conn.Raw panic should return an error") }) t.Fatal("expected panic from Raw func") }() } @@ -1510,7 +1510,7 @@ func TestInvalidNilValues(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> db := newTestDB(t, "people") defer closeDB(t, db) @@ -1592,7 +1592,7 @@ func TestConnIsValid(t *testing.T) { t.Fatal(err) } - err = c.Raw(func { raw | + err = c.Raw(func { raw -> dc := raw.(*fakeConn) dc.stickyBad = true return nil @@ -1748,7 +1748,7 @@ func TestIssue6651(t *testing.T) { var v string want := "error in rows.Next" - rowsCursorNextHook = func { dest | return errors.New(want) } + rowsCursorNextHook = func { dest -> return errors.New(want) } defer func() { rowsCursorNextHook = nil }() err := db.QueryRow("SELECT|people|name|").Scan(&v) @@ -1758,7 +1758,7 @@ func TestIssue6651(t *testing.T) { rowsCursorNextHook = nil want = "error in rows.Close" - setRowsCloseHook(func { rows, err | *err = errors.New(want) }) + setRowsCloseHook(func { rows, err -> *err = errors.New(want) }) defer setRowsCloseHook(nil) err = db.QueryRow("SELECT|people|name|").Scan(&v) if err == nil || err.Error() != want { @@ -2045,7 +2045,7 @@ func TestMaxOpenConns(t *testing.T) { t.Skip("skipping in short mode") } defer setHookpostCloseConn(nil) - setHookpostCloseConn(func { _, err | if err != nil { + setHookpostCloseConn(func { _, err -> if err != nil { t.Errorf("Error closing fakeConn: %v", err) } }) @@ -2156,7 +2156,7 @@ func TestMaxOpenConns(t *testing.T) { // and affects the subsequent release of connections. func TestMaxOpenConnsOnBusy(t *testing.T) { defer setHookpostCloseConn(nil) - setHookpostCloseConn(func { _, err | if err != nil { + setHookpostCloseConn(func { _, err -> if err != nil { t.Errorf("Error closing fakeConn: %v", err) } }) @@ -2425,7 +2425,7 @@ func TestStmtCloseDeps(t *testing.T) { t.Skip("skipping in short mode") } defer setHookpostCloseConn(nil) - setHookpostCloseConn(func { _, err | if err != nil { + setHookpostCloseConn(func { _, err -> if err != nil { t.Errorf("Error closing fakeConn: %v", err) } }) @@ -2516,7 +2516,7 @@ func TestCloseConnBeforeStmts(t *testing.T) { defer closeDB(t, db) defer setHookpostCloseConn(nil) - setHookpostCloseConn(func { _, err | + setHookpostCloseConn(func { _, err -> if err != nil { t.Errorf("Error closing fakeConn: %v; from %s", err, stack()) db.dumpDeps(t) @@ -2740,7 +2740,7 @@ func TestManyErrBadConn(t *testing.T) { } // Stmt.Exec - db = manyErrBadConnSetup(func { db | + db = manyErrBadConnSetup(func { db -> stmt, err = db.Prepare("INSERT|people|name=Julia,age=19") if err != nil { t.Fatal(err) @@ -2756,7 +2756,7 @@ func TestManyErrBadConn(t *testing.T) { } // Stmt.Query - db = manyErrBadConnSetup(func { db | + db = manyErrBadConnSetup(func { db -> stmt, err = db.Prepare("SELECT|people|age,name|") if err != nil { t.Fatal(err) @@ -2930,7 +2930,7 @@ func TestConnExpiresFreshOutOfPool(t *testing.T) { for _, ec := range execCases { ec := ec name := fmt.Sprintf("expired=%t,badReset=%t", ec.expired, ec.badReset) - t.Run(name, func { t | + t.Run(name, func { t -> db.clearAllConns(t) db.SetMaxIdleConns(1) @@ -3594,7 +3594,7 @@ func TestIssue6081(t *testing.T) { if err != nil { t.Fatal(err) } - setRowsCloseHook(func { rows, err | *err = driver.ErrBadConn }) + setRowsCloseHook(func { rows, err -> *err = driver.ErrBadConn }) defer setRowsCloseHook(nil) for i := 0; i < 10; i++ { rows, err := stmt.Query() @@ -3817,7 +3817,7 @@ func TestConcurrency(t *testing.T) { {"Random", new(concurrentRandomTest)}, } for _, item := range list { - t.Run(item.name, func { t | doConcurrentTest(t, item.ct) }) + t.Run(item.name, func { t -> doConcurrentTest(t, item.ct) }) } } @@ -4002,7 +4002,7 @@ func TestMaxIdleTime(t *testing.T) { }() for _, item := range list { nowFunc = func { return baseTime } - t.Run(fmt.Sprintf("%v", item.wantMaxIdleTime), func { t | + t.Run(fmt.Sprintf("%v", item.wantMaxIdleTime), func { t -> db := newTestDB(t, "people") defer closeDB(t, db) @@ -4376,7 +4376,7 @@ func TestDriverArgsWrapsErrors(t *testing.T) { db := newTestDB(t, "people") defer closeDB(t, db) - t.Run("exec", func { t | + t.Run("exec", func { t -> _, err := db.Exec("INSERT|keys|dec1=?", alwaysErrValuer{}) if err == nil { t.Fatal("expecting back an error") @@ -4390,7 +4390,7 @@ func TestDriverArgsWrapsErrors(t *testing.T) { } }) - t.Run("query", func { t | + t.Run("query", func { t -> _, err := db.Query("INSERT|keys|dec1=?", alwaysErrValuer{}) if err == nil { t.Fatal("expecting back an error") @@ -4407,7 +4407,7 @@ func TestDriverArgsWrapsErrors(t *testing.T) { func TestContextCancelDuringRawBytesScan(t *testing.T) { for _, mode := range []string{"nocancel", "top", "bottom", "go"} { - t.Run(mode, func { t | testContextCancelDuringRawBytesScan(t, mode) }) + t.Run(mode, func { t -> testContextCancelDuringRawBytesScan(t, mode) }) } } @@ -4772,7 +4772,7 @@ func BenchmarkManyConcurrentQueries(b *testing.B) { defer stmt.Close() b.SetParallelism(parallelism) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { rows, err := stmt.Query("sleep", 1) if err != nil { @@ -4831,7 +4831,7 @@ func TestConnRequestSet(t *testing.T) { } reset := func() { s = connRequestSet{} } - t.Run("add-delete", func { t | + t.Run("add-delete", func { t -> reset() wantLen(0) dh := s.Add(nil) @@ -4845,7 +4845,7 @@ func TestConnRequestSet(t *testing.T) { } wantLen(0) }) - t.Run("take-before-delete", func { t | + t.Run("take-before-delete", func { t -> reset() ch1 := make(chan connRequest) dh := s.Add(ch1) @@ -4858,7 +4858,7 @@ func TestConnRequestSet(t *testing.T) { t.Error("unexpected delete after take") } }) - t.Run("get-take-many", func { t | + t.Run("get-take-many", func { t -> reset() m := map[chan connRequest]bool{} const N = 100 @@ -4890,7 +4890,7 @@ func TestConnRequestSet(t *testing.T) { t.Error("wasn't random") } }) - t.Run("close-delete", func { t | + t.Run("close-delete", func { t -> reset() ch := make(chan connRequest) dh := s.Add(ch) diff --git a/src/debug/buildinfo/buildinfo.go b/src/debug/buildinfo/buildinfo.go index 875fd1232fe51..b454512468ed8 100644 --- a/src/debug/buildinfo/buildinfo.go +++ b/src/debug/buildinfo/buildinfo.go @@ -210,7 +210,7 @@ func readRawBuildInfo(r io.ReaderAt) (vers, mod string, err error) { } var readPtr func([]byte) uint64 if ptrSize == 4 { - readPtr = func { b | return uint64(bo.Uint32(b)) } + readPtr = func { b -> return uint64(bo.Uint32(b)) } } else if ptrSize == 8 { readPtr = bo.Uint64 } else { diff --git a/src/debug/buildinfo/buildinfo_test.go b/src/debug/buildinfo/buildinfo_test.go index d3e46c2992ac3..1aa5a96e23c6b 100644 --- a/src/debug/buildinfo/buildinfo_test.go +++ b/src/debug/buildinfo/buildinfo_test.go @@ -142,7 +142,7 @@ func TestReadFile(t *testing.T) { // We'll remove all build lines except the compiler, just to make sure // build lines are included. got = goVersionRe.ReplaceAllString(got, "go\tGOVERSION\n") - got = buildRe.ReplaceAllStringFunc(got, func { match | + got = buildRe.ReplaceAllStringFunc(got, func { match -> if strings.HasPrefix(match, "build\t-compiler=") { return match } @@ -213,16 +213,16 @@ func TestReadFile(t *testing.T) { for _, p := range platforms { p := p - t.Run(p.goos+"_"+p.goarch, func { t | + t.Run(p.goos+"_"+p.goarch, func { t -> if p != runtimePlatform && !*flagAll { t.Skipf("skipping platforms other than %s_%s because -all was not set", runtimePlatform.goos, runtimePlatform.goarch) } for _, mode := range buildModes { mode := mode - t.Run(mode, func { t | + t.Run(mode, func { t -> for _, tc := range cases { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() name := tc.build(t, p.goos, p.goarch, mode) if info, err := buildinfo.ReadFile(name); err != nil { @@ -255,7 +255,7 @@ func TestReadFile(t *testing.T) { func FuzzIssue57002(f *testing.F) { // input from issue f.Add([]byte{0x4d, 0x5a, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x50, 0x45, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x20, 0x20, 0x20, 0x20, 0x0, 0x0, 0x0, 0x0, 0x20, 0x3f, 0x0, 0x20, 0x0, 0x0, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0x20, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xb, 0x20, 0x20, 0x20, 0xfc, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x9, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x20, 0x20, 0x20, 0x20, 0x20, 0xef, 0x20, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xf, 0x0, 0x2, 0x0, 0x20, 0x0, 0x0, 0x9, 0x0, 0x4, 0x0, 0x20, 0xf6, 0x0, 0xd3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x1, 0x0, 0x0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xa, 0x20, 0xa, 0x20, 0x20, 0x20, 0xff, 0x20, 0x20, 0xff, 0x20, 0x47, 0x6f, 0x20, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x69, 0x6e, 0x66, 0x3a, 0xde, 0xb5, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x6, 0x7f, 0x7f, 0x7f, 0x20, 0xf4, 0xb2, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0xb, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x20, 0x0, 0x0, 0x0, 0x0, 0x5, 0x0, 0x20, 0x20, 0x20, 0x20, 0x0, 0x0, 0x0, 0x0, 0x20, 0x3f, 0x27, 0x20, 0x0, 0xd, 0x0, 0xa, 0x20, 0x20, 0x20, 0x20, 0x20, 0xff, 0x20, 0x20, 0xff, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x0, 0x20, 0x20, 0x0, 0x0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x5c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20}) - f.Fuzz(func { t, input | buildinfo.Read(bytes.NewReader(input)) }) + f.Fuzz(func { t, input -> buildinfo.Read(bytes.NewReader(input)) }) } // TestIssue54968 is a regression test for golang.org/issue/54968. @@ -307,7 +307,7 @@ func TestIssue54968(t *testing.T) { continue } - t.Run(fmt.Sprintf("start_at_%d", i), func { t | + t.Run(fmt.Sprintf("start_at_%d", i), func { t -> d := data[:start] // Construct intentionally-misaligned buildInfoMagic. d = append(d, bytes.Repeat([]byte{0}, i)...) diff --git a/src/debug/dwarf/entry_test.go b/src/debug/dwarf/entry_test.go index bc51900dd0d4b..e20a7a8fd537b 100644 --- a/src/debug/dwarf/entry_test.go +++ b/src/debug/dwarf/entry_test.go @@ -290,7 +290,7 @@ func TestUnitIteration(t *testing.T) { t.Fatal(err) } for _, file := range files { - t.Run(file, func { t | + t.Run(file, func { t -> d := elfData(t, file) var units [2][]any for method := range units { diff --git a/src/debug/dwarf/unit.go b/src/debug/dwarf/unit.go index e94db308578a0..89791c6c41fd7 100644 --- a/src/debug/dwarf/unit.go +++ b/src/debug/dwarf/unit.go @@ -123,7 +123,7 @@ func (d *Data) parseUnits() ([]unit, error) { // It returns -1 if no unit contains this offset. func (d *Data) offsetToUnit(off Offset) int { // Find the unit after off - next := sort.Search(len(d.unit), func { i | return d.unit[i].off > off }) + next := sort.Search(len(d.unit), func { i -> return d.unit[i].off > off }) if next == 0 { return -1 } diff --git a/src/debug/elf/file.go b/src/debug/elf/file.go index 04717bb22c985..44945fd698381 100644 --- a/src/debug/elf/file.go +++ b/src/debug/elf/file.go @@ -156,7 +156,7 @@ func (s *Section) Open() io.ReadSeeker { case COMPRESS_ZLIB: zrd = zlib.NewReader case COMPRESS_ZSTD: - zrd = func { r | return io.NopCloser(zstd.NewReader(r)), nil } + zrd = func { r -> return io.NopCloser(zstd.NewReader(r)), nil } } if zrd == nil { diff --git a/src/debug/elf/file_test.go b/src/debug/elf/file_test.go index dfe27bf2bfa1c..7dc845730cac1 100644 --- a/src/debug/elf/file_test.go +++ b/src/debug/elf/file_test.go @@ -995,7 +995,7 @@ var relocationTests = []relocationTest{ func TestDWARFRelocations(t *testing.T) { for _, test := range relocationTests { test := test - t.Run(test.file, func { t | + t.Run(test.file, func { t -> t.Parallel() f, err := Open(test.file) if err != nil { diff --git a/src/debug/gosym/pclntab.go b/src/debug/gosym/pclntab.go index 1ac4188c12102..d68edda42ee4b 100644 --- a/src/debug/gosym/pclntab.go +++ b/src/debug/gosym/pclntab.go @@ -334,7 +334,7 @@ func (t *LineTable) findFunc(pc uint64) funcData { if pc < ft.pc(0) || pc >= ft.pc(ft.Count()) { return funcData{} } - idx := sort.Search(int(t.nfunctab), func { i | return ft.pc(i) > pc }) + idx := sort.Search(int(t.nfunctab), func { i -> return ft.pc(i) > pc }) idx-- return t.funcData(uint32(idx)) } diff --git a/src/debug/gosym/pclntab_test.go b/src/debug/gosym/pclntab_test.go index 0b487a94892d1..adbbf256e14ad 100644 --- a/src/debug/gosym/pclntab_test.go +++ b/src/debug/gosym/pclntab_test.go @@ -344,7 +344,7 @@ func Benchmark115(b *testing.B) { dat := read115Executable(b) const textStart = 0x1001000 - b.Run("NewLineTable", func { b | + b.Run("NewLineTable", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sinkLineTable = NewLineTable(dat, textStart) @@ -352,7 +352,7 @@ func Benchmark115(b *testing.B) { }) pcln := NewLineTable(dat, textStart) - b.Run("NewTable", func { b | + b.Run("NewTable", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { var err error @@ -368,7 +368,7 @@ func Benchmark115(b *testing.B) { b.Fatal(err) } - b.Run("LineToPC", func { b | + b.Run("LineToPC", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { var f *Func @@ -389,7 +389,7 @@ func Benchmark115(b *testing.B) { } }) - b.Run("PCToLine", func { b | + b.Run("PCToLine", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { file, line, fn := tab.PCToLine(0x105c280) diff --git a/src/debug/gosym/symtab.go b/src/debug/gosym/symtab.go index b0da08cbbfe9d..9fc1b16705fe9 100644 --- a/src/debug/gosym/symtab.go +++ b/src/debug/gosym/symtab.go @@ -335,7 +335,7 @@ func walksymtab(data []byte, fn func(sym) error) error { // Starting with Go 1.3, the Go symbol table no longer includes symbol data. func NewTable(symtab []byte, pcln *LineTable) (*Table, error) { var n int - err := walksymtab(symtab, func { s | + err := walksymtab(symtab, func { s -> n++ return nil }) @@ -352,7 +352,7 @@ func NewTable(symtab []byte, pcln *LineTable) (*Table, error) { nf := 0 nz := 0 lasttyp := uint8(0) - err = walksymtab(symtab, func { s | + err = walksymtab(symtab, func { s -> n := len(t.Syms) t.Syms = t.Syms[0 : n+1] ts := &t.Syms[n] diff --git a/src/debug/plan9obj/file.go b/src/debug/plan9obj/file.go index 20ce92ab7f690..626848f43aaa6 100644 --- a/src/debug/plan9obj/file.go +++ b/src/debug/plan9obj/file.go @@ -264,7 +264,7 @@ func walksymtab(data []byte, ptrsz int, fn func(sym) error) error { // returning an in-memory representation. func newTable(symtab []byte, ptrsz int) ([]Sym, error) { var n int - err := walksymtab(symtab, ptrsz, func { s | + err := walksymtab(symtab, ptrsz, func { s -> n++ return nil }) @@ -274,7 +274,7 @@ func newTable(symtab []byte, ptrsz int) ([]Sym, error) { fname := make(map[uint16]string) syms := make([]Sym, 0, n) - err = walksymtab(symtab, ptrsz, func { s | + err = walksymtab(symtab, ptrsz, func { s -> n := len(syms) syms = syms[0 : n+1] ts := &syms[n] diff --git a/src/embed/embed.go b/src/embed/embed.go index 0dc10d5c2332d..80d24be1c4be5 100644 --- a/src/embed/embed.go +++ b/src/embed/embed.go @@ -257,7 +257,7 @@ func (f FS) lookup(name string) *file { // and then check if name is at that position. dir, elem, _ := split(name) files := *f.files - i := sortSearch(len(files), func { i | + i := sortSearch(len(files), func { i -> idir, ielem, _ := split(files[i].name) return idir > dir || idir == dir && ielem >= elem }) @@ -275,11 +275,11 @@ func (f FS) readDir(dir string) []file { // Binary search to find where dir starts and ends in the list // and then return that slice of the list. files := *f.files - i := sortSearch(len(files), func { i | + i := sortSearch(len(files), func { i -> idir, _, _ := split(files[i].name) return idir >= dir }) - j := sortSearch(len(files), func { j | + j := sortSearch(len(files), func { j -> jdir, _, _ := split(files[j].name) return jdir > dir }) diff --git a/src/encoding/base64/base64_test.go b/src/encoding/base64/base64_test.go index 67f2e84b51799..84caaa15ceb43 100644 --- a/src/encoding/base64/base64_test.go +++ b/src/encoding/base64/base64_test.go @@ -536,7 +536,7 @@ func BenchmarkDecodeString(b *testing.B) { } } for _, size := range sizes { - b.Run(fmt.Sprintf("%d", size), func { b | benchFunc(b, size) }) + b.Run(fmt.Sprintf("%d", size), func { b -> benchFunc(b, size) }) } } diff --git a/src/encoding/binary/binary_test.go b/src/encoding/binary/binary_test.go index feb217ba25756..210b5bc3aa43b 100644 --- a/src/encoding/binary/binary_test.go +++ b/src/encoding/binary/binary_test.go @@ -184,7 +184,7 @@ var decoders = []struct { func testRead(t *testing.T, order ByteOrder, b []byte, s1 any) { for _, dec := range decoders { - t.Run(dec.name, func { t | + t.Run(dec.name, func { t -> var s2 Struct err := dec.fn(order, &s2, b) checkResult(t, dec.name, order, err, s2, s1) @@ -194,7 +194,7 @@ func testRead(t *testing.T, order ByteOrder, b []byte, s1 any) { func testWrite(t *testing.T, order ByteOrder, b []byte, s1 any) { for _, enc := range encoders { - t.Run(enc.name, func { t | + t.Run(enc.name, func { t -> buf, err := enc.fn(order, s1) checkResult(t, enc.name, order, err, buf, b) }) @@ -210,13 +210,13 @@ func TestBigEndianWrite(t *testing.T) { testWrite(t, BigEndian, big, s) } func TestBigEndianPtrWrite(t *testing.T) { testWrite(t, BigEndian, big, &s) } func TestReadSlice(t *testing.T) { - t.Run("Read", func { t | + t.Run("Read", func { t -> slice := make([]int32, 2) err := Read(bytes.NewReader(src), BigEndian, slice) checkResult(t, "ReadSlice", BigEndian, err, slice, res) }) - t.Run("Decode", func { t | + t.Run("Decode", func { t -> slice := make([]int32, 2) _, err := Decode(src, BigEndian, slice) checkResult(t, "ReadSlice", BigEndian, err, slice, res) @@ -229,7 +229,7 @@ func TestWriteSlice(t *testing.T) { func TestReadBool(t *testing.T) { for _, dec := range decoders { - t.Run(dec.name, func { t | + t.Run(dec.name, func { t -> var res bool var err error err = dec.fn(BigEndian, &res, []byte{0}) @@ -247,7 +247,7 @@ func TestReadBool(t *testing.T) { func TestReadBoolSlice(t *testing.T) { for _, dec := range decoders { - t.Run(dec.name, func { t | + t.Run(dec.name, func { t -> slice := make([]bool, 4) err := dec.fn(BigEndian, slice, []byte{0, 1, 2, 255}) checkResult(t, dec.name, BigEndian, err, slice, []bool{false, true, true, true}) @@ -270,10 +270,10 @@ var intArrays = []any{ func TestSliceRoundTrip(t *testing.T) { for _, enc := range encoders { for _, dec := range decoders { - t.Run(fmt.Sprintf("%s,%s", enc.name, dec.name), func { t | + t.Run(fmt.Sprintf("%s,%s", enc.name, dec.name), func { t -> for _, array := range intArrays { src := reflect.ValueOf(array).Elem() - t.Run(src.Index(0).Type().Name(), func { t | + t.Run(src.Index(0).Type().Name(), func { t -> unsigned := false switch src.Index(0).Kind() { case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: @@ -310,7 +310,7 @@ func TestSliceRoundTrip(t *testing.T) { func TestWriteT(t *testing.T) { for _, enc := range encoders { - t.Run(enc.name, func { t | + t.Run(enc.name, func { t -> ts := T{} if _, err := enc.fn(BigEndian, ts); err == nil { t.Errorf("WriteT: have err == nil, want non-nil") @@ -358,7 +358,7 @@ type BlankFieldsProbe struct { func TestBlankFields(t *testing.T) { for _, enc := range encoders { - t.Run(enc.name, func { t | + t.Run(enc.name, func { t -> b1 := BlankFields{A: 1234567890, B: 2.718281828, C: 42} buf, err := enc.fn(LittleEndian, &b1) if err != nil { @@ -400,7 +400,7 @@ func TestSizeStructCache(t *testing.T) { count := func { var i int - structSize.Range(func { _, _ | + structSize.Range(func { _, _ -> i++ return true }) @@ -498,7 +498,7 @@ func TestUnexportedRead(t *testing.T) { } for _, dec := range decoders { - t.Run(dec.name, func { t | + t.Run(dec.name, func { t -> defer func() { if recover() == nil { t.Fatal("did not panic") @@ -513,7 +513,7 @@ func TestUnexportedRead(t *testing.T) { func TestReadErrorMsg(t *testing.T) { for _, dec := range decoders { - t.Run(dec.name, func { t | + t.Run(dec.name, func { t -> read := func(data any) { err := dec.fn(LittleEndian, data, nil) want := fmt.Sprintf("binary.%s: invalid type %s", dec.name, reflect.TypeOf(data).String()) @@ -693,7 +693,7 @@ func TestNoFixedSize(t *testing.T) { } for _, enc := range encoders { - t.Run(enc.name, func { t | + t.Run(enc.name, func { t -> _, err := enc.fn(LittleEndian, &person) if err == nil { t.Fatalf("binary.%s: unexpected success as size of type *binary.Person is not fixed", enc.name) @@ -743,7 +743,7 @@ var sizableTypes = []any{ func TestSizeAllocs(t *testing.T) { for _, data := range sizableTypes { - t.Run(fmt.Sprintf("%T", data), func { t | + t.Run(fmt.Sprintf("%T", data), func { t -> // Size uses a sync.Map behind the scenes. The slow lookup path of // that does allocate, so we need a couple of runs here to be // allocation free. @@ -1130,7 +1130,7 @@ func BenchmarkWriteSlice1000Uint8s(b *testing.B) { func BenchmarkSize(b *testing.B) { for _, data := range sizableTypes { - b.Run(fmt.Sprintf("%T", data), func { b | for range b.N { + b.Run(fmt.Sprintf("%T", data), func { b -> for range b.N { _ = Size(data) } }) } diff --git a/src/encoding/binary/varint_test.go b/src/encoding/binary/varint_test.go index ccd9944aad00a..ac9abbc816eb4 100644 --- a/src/encoding/binary/varint_test.go +++ b/src/encoding/binary/varint_test.go @@ -182,7 +182,7 @@ func TestBufferTooBigWithOverflow(t *testing.T) { for _, tt := range tests { tt := tt - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> value, n := Uvarint(tt.in) if g, w := n, tt.wantN; g != w { t.Errorf("bytes returned=%d, want=%d", g, w) diff --git a/src/encoding/csv/fuzz_test.go b/src/encoding/csv/fuzz_test.go index d00831afdd03d..c5e0b420fd907 100644 --- a/src/encoding/csv/fuzz_test.go +++ b/src/encoding/csv/fuzz_test.go @@ -13,7 +13,7 @@ import ( ) func FuzzRoundtrip(f *testing.F) { - f.Fuzz(func { t, in | + f.Fuzz(func { t, in -> buf := new(bytes.Buffer) t.Logf("input = %q", in) @@ -80,7 +80,7 @@ func FuzzRoundtrip(f *testing.F) { // Note that the reader parses the quoted record "" as an empty string, // and the writer turns that into an empty line, which the reader skips over. // Filter those out to avoid false positives. - records = slices.DeleteFunc(records, func { record | return len(record) == 1 && record[0] == "" }) + records = slices.DeleteFunc(records, func { record -> return len(record) == 1 && record[0] == "" }) // The reader uses nil when returning no records at all. if len(records) == 0 { records = nil diff --git a/src/encoding/csv/reader.go b/src/encoding/csv/reader.go index a5ee57131dcfb..c0d14d9e7201d 100644 --- a/src/encoding/csv/reader.go +++ b/src/encoding/csv/reader.go @@ -330,7 +330,7 @@ func (r *Reader) readRecord(dst []string) ([]string, error) { parseField: for { if r.TrimLeadingSpace { - i := bytes.IndexFunc(line, func { r | return !unicode.IsSpace(r) }) + i := bytes.IndexFunc(line, func { r -> return !unicode.IsSpace(r) }) if i < 0 { i = len(line) pos.col -= lengthNL(line) diff --git a/src/encoding/csv/reader_test.go b/src/encoding/csv/reader_test.go index 5b3251c5437d9..0ec6e33e803fe 100644 --- a/src/encoding/csv/reader_test.go +++ b/src/encoding/csv/reader_test.go @@ -424,7 +424,7 @@ func TestRead(t *testing.T) { } for _, tt := range readTests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> r, positions, errPositions, input := newReader(tt) out, err := r.ReadAll() if wantErr := firstError(tt.Errors, positions, errPositions); wantErr != nil { @@ -621,11 +621,11 @@ func BenchmarkRead(b *testing.B) { } func BenchmarkReadWithFieldsPerRecord(b *testing.B) { - benchmarkRead(b, func { r | r.FieldsPerRecord = 4 }, benchmarkCSVData) + benchmarkRead(b, func { r -> r.FieldsPerRecord = 4 }, benchmarkCSVData) } func BenchmarkReadWithoutFieldsPerRecord(b *testing.B) { - benchmarkRead(b, func { r | r.FieldsPerRecord = -1 }, benchmarkCSVData) + benchmarkRead(b, func { r -> r.FieldsPerRecord = -1 }, benchmarkCSVData) } func BenchmarkReadLargeFields(b *testing.B) { @@ -637,25 +637,25 @@ xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,zzzzzzzzzzzzzz } func BenchmarkReadReuseRecord(b *testing.B) { - benchmarkRead(b, func { r | r.ReuseRecord = true }, benchmarkCSVData) + benchmarkRead(b, func { r -> r.ReuseRecord = true }, benchmarkCSVData) } func BenchmarkReadReuseRecordWithFieldsPerRecord(b *testing.B) { - benchmarkRead(b, func { r | + benchmarkRead(b, func { r -> r.ReuseRecord = true r.FieldsPerRecord = 4 }, benchmarkCSVData) } func BenchmarkReadReuseRecordWithoutFieldsPerRecord(b *testing.B) { - benchmarkRead(b, func { r | + benchmarkRead(b, func { r -> r.ReuseRecord = true r.FieldsPerRecord = -1 }, benchmarkCSVData) } func BenchmarkReadReuseRecordLargeFields(b *testing.B) { - benchmarkRead(b, func { r | r.ReuseRecord = true }, strings.Repeat(`xxxxxxxxxxxxxxxx,yyyyyyyyyyyyyyyy,zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww,vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv + benchmarkRead(b, func { r -> r.ReuseRecord = true }, strings.Repeat(`xxxxxxxxxxxxxxxx,yyyyyyyyyyyyyyyy,zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww,vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv xxxxxxxxxxxxxxxxxxxxxxxx,yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww,vvvv ,,zzzz,wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww,vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy,zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz,wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww,vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv diff --git a/src/encoding/gob/codec_test.go b/src/encoding/gob/codec_test.go index 43b980bf63384..777e0c1c5ed78 100644 --- a/src/encoding/gob/codec_test.go +++ b/src/encoding/gob/codec_test.go @@ -1566,7 +1566,7 @@ func testEncodeDecode(t *testing.T, in, out any) { } func TestLargeSlice(t *testing.T) { - t.Run("byte", func { t | + t.Run("byte", func { t -> if unsafe.Sizeof(uintptr(0)) > 4 { t.Parallel() // Only run in parallel in a large address space } @@ -1578,7 +1578,7 @@ func TestLargeSlice(t *testing.T) { rt := &LargeSliceByte{} testEncodeDecode(t, st, rt) }) - t.Run("int8", func { t | + t.Run("int8", func { t -> if unsafe.Sizeof(uintptr(0)) > 4 { t.Parallel() } @@ -1590,7 +1590,7 @@ func TestLargeSlice(t *testing.T) { rt := &LargeSliceInt8{} testEncodeDecode(t, st, rt) }) - t.Run("struct", func { t | + t.Run("struct", func { t -> if unsafe.Sizeof(uintptr(0)) > 4 { t.Parallel() } @@ -1603,7 +1603,7 @@ func TestLargeSlice(t *testing.T) { rt := &LargeSliceStruct{} testEncodeDecode(t, st, rt) }) - t.Run("string", func { t | + t.Run("string", func { t -> if unsafe.Sizeof(uintptr(0)) > 4 { t.Parallel() } diff --git a/src/encoding/gob/decode.go b/src/encoding/gob/decode.go index 0637bb101895a..bb449426f038d 100644 --- a/src/encoding/gob/decode.go +++ b/src/encoding/gob/decode.go @@ -852,7 +852,7 @@ func (dec *Decoder) decOpFor(wireId typeId, rt reflect.Type, name string, inProg elemOp := dec.decOpFor(elemId, t.Elem(), name, inProgress) ovfl := overflow(name) helper := decArrayHelper[t.Elem().Kind()] - op = func { i, state, value | state.dec.decodeArray(state, value, *elemOp, t.Len(), ovfl, helper) } + op = func { i, state, value -> state.dec.decodeArray(state, value, *elemOp, t.Len(), ovfl, helper) } case reflect.Map: keyId := dec.wireType[wireId].MapT.Key @@ -860,7 +860,7 @@ func (dec *Decoder) decOpFor(wireId typeId, rt reflect.Type, name string, inProg keyOp := dec.decOpFor(keyId, t.Key(), "key of "+name, inProgress) elemOp := dec.decOpFor(elemId, t.Elem(), "element of "+name, inProgress) ovfl := overflow(name) - op = func { i, state, value | state.dec.decodeMap(t, state, value, *keyOp, *elemOp, ovfl) } + op = func { i, state, value -> state.dec.decodeMap(t, state, value, *keyOp, *elemOp, ovfl) } case reflect.Slice: name = "element of " + name @@ -877,7 +877,7 @@ func (dec *Decoder) decOpFor(wireId typeId, rt reflect.Type, name string, inProg elemOp := dec.decOpFor(elemId, t.Elem(), name, inProgress) ovfl := overflow(name) helper := decSliceHelper[t.Elem().Kind()] - op = func { i, state, value | state.dec.decodeSlice(state, value, *elemOp, ovfl, helper) } + op = func { i, state, value -> state.dec.decodeSlice(state, value, *elemOp, ovfl, helper) } case reflect.Struct: // Generate a closure that calls out to the engine for the nested type. @@ -886,11 +886,11 @@ func (dec *Decoder) decOpFor(wireId typeId, rt reflect.Type, name string, inProg if err != nil { error_(err) } - op = func { i, state, value | + op = func { i, state, value -> // indirect through enginePtr to delay evaluation for recursive structs. dec.decodeStruct(*enginePtr, value) } case reflect.Interface: - op = func { i, state, value | state.dec.decodeInterface(t, state, value) } + op = func { i, state, value -> state.dec.decodeInterface(t, state, value) } } } if op == nil { @@ -920,7 +920,7 @@ func (dec *Decoder) decIgnoreOpFor(wireId typeId, inProgress map[typeId]*decOp) if wireId == tInterface { // Special case because it's a method: the ignored item might // define types and we need to record their state in the decoder. - op = func { i, state, value | state.dec.ignoreInterface(state) } + op = func { i, state, value -> state.dec.ignoreInterface(state) } return &op } // Special cases @@ -931,19 +931,19 @@ func (dec *Decoder) decIgnoreOpFor(wireId typeId, inProgress map[typeId]*decOp) case wire.ArrayT != nil: elemId := wire.ArrayT.Elem elemOp := dec.decIgnoreOpFor(elemId, inProgress) - op = func { i, state, value | state.dec.ignoreArray(state, *elemOp, wire.ArrayT.Len) } + op = func { i, state, value -> state.dec.ignoreArray(state, *elemOp, wire.ArrayT.Len) } case wire.MapT != nil: keyId := dec.wireType[wireId].MapT.Key elemId := dec.wireType[wireId].MapT.Elem keyOp := dec.decIgnoreOpFor(keyId, inProgress) elemOp := dec.decIgnoreOpFor(elemId, inProgress) - op = func { i, state, value | state.dec.ignoreMap(state, *keyOp, *elemOp) } + op = func { i, state, value -> state.dec.ignoreMap(state, *keyOp, *elemOp) } case wire.SliceT != nil: elemId := wire.SliceT.Elem elemOp := dec.decIgnoreOpFor(elemId, inProgress) - op = func { i, state, value | state.dec.ignoreSlice(state, *elemOp) } + op = func { i, state, value -> state.dec.ignoreSlice(state, *elemOp) } case wire.StructT != nil: // Generate a closure that calls out to the engine for the nested type. @@ -951,12 +951,12 @@ func (dec *Decoder) decIgnoreOpFor(wireId typeId, inProgress map[typeId]*decOp) if err != nil { error_(err) } - op = func { i, state, value | + op = func { i, state, value -> // indirect through enginePtr to delay evaluation for recursive structs state.dec.ignoreStruct(*enginePtr) } case wire.GobEncoderT != nil, wire.BinaryMarshalerT != nil, wire.TextMarshalerT != nil: - op = func { i, state, value | state.dec.ignoreGobDecoder(state) } + op = func { i, state, value -> state.dec.ignoreGobDecoder(state) } } } if op == nil { @@ -977,7 +977,7 @@ func (dec *Decoder) gobDecodeOpFor(ut *userTypeInfo) *decOp { } } var op decOp - op = func { i, state, value | + op = func { i, state, value -> // We now have the base type. We need its address if the receiver is a pointer. if value.Kind() != reflect.Pointer && rcvrType.Kind() == reflect.Pointer { value = value.Addr() diff --git a/src/encoding/gob/encode.go b/src/encoding/gob/encode.go index 84f78a75497dd..3c75d35bf78aa 100644 --- a/src/encoding/gob/encode.go +++ b/src/encoding/gob/encode.go @@ -508,7 +508,7 @@ func encOpFor(rt reflect.Type, inProgress map[reflect.Type]*encOp, building map[ // Slices have a header; we decode it to find the underlying array. elemOp, elemIndir := encOpFor(t.Elem(), inProgress, building) helper := encSliceHelper[t.Elem().Kind()] - op = func { i, state, slice | + op = func { i, state, slice -> if !state.sendZero && slice.Len() == 0 { return } @@ -519,14 +519,14 @@ func encOpFor(rt reflect.Type, inProgress map[reflect.Type]*encOp, building map[ // True arrays have size in the type. elemOp, elemIndir := encOpFor(t.Elem(), inProgress, building) helper := encArrayHelper[t.Elem().Kind()] - op = func { i, state, array | + op = func { i, state, array -> state.update(i) state.enc.encodeArray(state.b, array, *elemOp, elemIndir, array.Len(), helper) } case reflect.Map: keyOp, keyIndir := encOpFor(t.Key(), inProgress, building) elemOp, elemIndir := encOpFor(t.Elem(), inProgress, building) - op = func { i, state, mv | + op = func { i, state, mv -> // We send zero-length (but non-nil) maps because the // receiver might want to use the map. (Maps don't use append.) if !state.sendZero && mv.IsNil() { @@ -539,14 +539,14 @@ func encOpFor(rt reflect.Type, inProgress map[reflect.Type]*encOp, building map[ // Generate a closure that calls out to the engine for the nested type. getEncEngine(userType(typ), building) info := mustGetTypeInfo(typ) - op = func { i, state, sv | + op = func { i, state, sv -> state.update(i) // indirect through info to delay evaluation for recursive structs enc := info.encoder.Load() state.enc.encodeStruct(state.b, enc, sv) } case reflect.Interface: - op = func { i, state, iv | + op = func { i, state, iv -> if !state.sendZero && (!iv.IsValid() || iv.IsNil()) { return } @@ -572,7 +572,7 @@ func gobEncodeOpFor(ut *userTypeInfo) (*encOp, int) { } } var op encOp - op = func { i, state, v | + op = func { i, state, v -> if ut.encIndir == -1 { // Need to climb up one level to turn value into pointer. if !v.CanAddr() { diff --git a/src/encoding/gob/encoder_test.go b/src/encoding/gob/encoder_test.go index 58f253ef81ce2..c09cdff3a975a 100644 --- a/src/encoding/gob/encoder_test.go +++ b/src/encoding/gob/encoder_test.go @@ -65,7 +65,7 @@ func TestEncodeIntSlice(t *testing.T) { s32 := []int32{532, 590, 651, 715, 782, 852, 925, 1001, 1080} s64 := []int64{1162, 1247, 1335, 1426, 1520, 1617, 1717, 1820, 1926} - t.Run("int8", func { t | + t.Run("int8", func { t -> var sink bytes.Buffer enc := NewEncoder(&sink) enc.Encode(s8) @@ -79,7 +79,7 @@ func TestEncodeIntSlice(t *testing.T) { } }) - t.Run("int16", func { t | + t.Run("int16", func { t -> var sink bytes.Buffer enc := NewEncoder(&sink) enc.Encode(s16) @@ -93,7 +93,7 @@ func TestEncodeIntSlice(t *testing.T) { } }) - t.Run("int32", func { t | + t.Run("int32", func { t -> var sink bytes.Buffer enc := NewEncoder(&sink) enc.Encode(s32) @@ -107,7 +107,7 @@ func TestEncodeIntSlice(t *testing.T) { } }) - t.Run("int64", func { t | + t.Run("int64", func { t -> var sink bytes.Buffer enc := NewEncoder(&sink) enc.Encode(s64) @@ -1187,7 +1187,7 @@ func TestMarshalFloatMap(t *testing.T) { for k, v := range m { entries = append(entries, mapEntry{math.Float64bits(k), v}) } - slices.SortFunc(entries, func { a, b | + slices.SortFunc(entries, func { a, b -> r := cmp.Compare(a.keyBits, b.keyBits) if r != 0 { return r diff --git a/src/encoding/gob/timing_test.go b/src/encoding/gob/timing_test.go index 9248b8782c122..65cab36e5f3a2 100644 --- a/src/encoding/gob/timing_test.go +++ b/src/encoding/gob/timing_test.go @@ -22,7 +22,7 @@ type Bench struct { func benchmarkEndToEnd(b *testing.B, ctor func() any, pipe func() (r io.Reader, w io.Writer, err error)) { b.ReportAllocs() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> r, w, err := pipe() if err != nil { b.Fatal("can't get pipe:", err) @@ -133,7 +133,7 @@ func TestCountDecodeMallocs(t *testing.T) { func benchmarkEncodeSlice(b *testing.B, a any) { b.ResetTimer() b.ReportAllocs() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var buf bytes.Buffer enc := NewEncoder(&buf) @@ -228,7 +228,7 @@ func benchmarkDecodeSlice(b *testing.B, a any) { b.ResetTimer() b.ReportAllocs() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> // TODO(#19025): Move per-thread allocation before ResetTimer. rp := reflect.New(rt) rp.Elem().Set(reflect.MakeSlice(rt, ra.Len(), ra.Cap())) diff --git a/src/encoding/hex/hex_test.go b/src/encoding/hex/hex_test.go index 02bb5fa3d2557..0c93919b61137 100644 --- a/src/encoding/hex/hex_test.go +++ b/src/encoding/hex/hex_test.go @@ -252,7 +252,7 @@ func BenchmarkEncode(b *testing.B) { src := bytes.Repeat([]byte{2, 3, 5, 7, 9, 11, 13, 17}, size/8) sink = make([]byte, 2*size) - b.Run(fmt.Sprintf("%v", size), func { b | + b.Run(fmt.Sprintf("%v", size), func { b -> b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { Encode(sink, src) @@ -266,7 +266,7 @@ func BenchmarkDecode(b *testing.B) { src := bytes.Repeat([]byte{'2', 'b', '7', '4', '4', 'f', 'a', 'a'}, size/8) sink = make([]byte, size/2) - b.Run(fmt.Sprintf("%v", size), func { b | + b.Run(fmt.Sprintf("%v", size), func { b -> b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { Decode(sink, src) @@ -278,7 +278,7 @@ func BenchmarkDecode(b *testing.B) { func BenchmarkDecodeString(b *testing.B) { for _, size := range []int{256, 1024, 4096, 16384} { src := strings.Repeat("2b744faa", size/8) - b.Run(fmt.Sprintf("%v", size), func { b | + b.Run(fmt.Sprintf("%v", size), func { b -> b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { sink, _ = DecodeString(src) @@ -291,7 +291,7 @@ func BenchmarkDump(b *testing.B) { for _, size := range []int{256, 1024, 4096, 16384} { src := bytes.Repeat([]byte{2, 3, 5, 7, 9, 11, 13, 17}, size/8) - b.Run(fmt.Sprintf("%v", size), func { b | + b.Run(fmt.Sprintf("%v", size), func { b -> b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { Dump(src) diff --git a/src/encoding/json/bench_test.go b/src/encoding/json/bench_test.go index 65d7143ee1bfd..3591bfb6f0973 100644 --- a/src/encoding/json/bench_test.go +++ b/src/encoding/json/bench_test.go @@ -89,7 +89,7 @@ func BenchmarkCodeEncoder(b *testing.B) { codeInit() b.StartTimer() } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> enc := NewEncoder(io.Discard) for pb.Next() { if err := enc.Encode(&codeStruct); err != nil { @@ -116,7 +116,7 @@ func BenchmarkCodeEncoderError(b *testing.B) { dummy := Dummy{Name: "Dummy"} dummy.Next = &dummy - b.RunParallel(func { pb | + b.RunParallel(func { pb -> enc := NewEncoder(io.Discard) for pb.Next() { if err := enc.Encode(&codeStruct); err != nil { @@ -137,7 +137,7 @@ func BenchmarkCodeMarshal(b *testing.B) { codeInit() b.StartTimer() } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { if _, err := Marshal(&codeStruct); err != nil { b.Fatalf("Marshal error: %v", err) @@ -163,7 +163,7 @@ func BenchmarkCodeMarshalError(b *testing.B) { dummy := Dummy{Name: "Dummy"} dummy.Next = &dummy - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { if _, err := Marshal(&codeStruct); err != nil { b.Fatalf("Marshal error: %v", err) @@ -253,7 +253,7 @@ func BenchmarkMarshalMap(b *testing.B) { "key2": 2, "key1": 1, } - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { if _, err := Marshal(m); err != nil { b.Fatal("Marshal:", err) } @@ -267,7 +267,7 @@ func BenchmarkCodeDecoder(b *testing.B) { codeInit() b.StartTimer() } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var buf bytes.Buffer dec := NewDecoder(&buf) var r codeResponse @@ -334,7 +334,7 @@ func BenchmarkCodeUnmarshal(b *testing.B) { codeInit() b.StartTimer() } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { var r codeResponse if err := Unmarshal(codeJSON, &r); err != nil { @@ -352,7 +352,7 @@ func BenchmarkCodeUnmarshalReuse(b *testing.B) { codeInit() b.StartTimer() } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var r codeResponse for pb.Next() { if err := Unmarshal(codeJSON, &r); err != nil { @@ -366,7 +366,7 @@ func BenchmarkCodeUnmarshalReuse(b *testing.B) { func BenchmarkUnmarshalString(b *testing.B) { b.ReportAllocs() data := []byte(`"hello, world"`) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var s string for pb.Next() { if err := Unmarshal(data, &s); err != nil { @@ -379,7 +379,7 @@ func BenchmarkUnmarshalString(b *testing.B) { func BenchmarkUnmarshalFloat64(b *testing.B) { b.ReportAllocs() data := []byte(`3.14`) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var f float64 for pb.Next() { if err := Unmarshal(data, &f); err != nil { @@ -392,7 +392,7 @@ func BenchmarkUnmarshalFloat64(b *testing.B) { func BenchmarkUnmarshalInt64(b *testing.B) { b.ReportAllocs() data := []byte(`3`) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var x int64 for pb.Next() { if err := Unmarshal(data, &x); err != nil { @@ -405,7 +405,7 @@ func BenchmarkUnmarshalInt64(b *testing.B) { func BenchmarkUnmarshalMap(b *testing.B) { b.ReportAllocs() data := []byte(`{"key1":"value1","key2":"value2","key3":"value3"}`) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> x := make(map[string]string, 3) for pb.Next() { if err := Unmarshal(data, &x); err != nil { @@ -418,7 +418,7 @@ func BenchmarkUnmarshalMap(b *testing.B) { func BenchmarkIssue10335(b *testing.B) { b.ReportAllocs() j := []byte(`{"a":{ }}`) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var s struct{} for pb.Next() { if err := Unmarshal(j, &s); err != nil { @@ -435,7 +435,7 @@ func BenchmarkIssue34127(b *testing.B) { }{ Bar: `foobar`, } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { if _, err := Marshal(&j); err != nil { b.Fatalf("Marshal error: %v", err) @@ -447,7 +447,7 @@ func BenchmarkIssue34127(b *testing.B) { func BenchmarkUnmapped(b *testing.B) { b.ReportAllocs() j := []byte(`{"s": "hello", "y": 2, "o": {"x": 0}, "a": [1, 99, {"x": 1}]}`) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var s struct{} for pb.Next() { if err := Unmarshal(j, &s); err != nil { @@ -484,7 +484,7 @@ func BenchmarkTypeFieldsCache(b *testing.B) { // This measures the time to rebuild a cache of size nt. for nt := 1; nt <= maxTypes; nt *= 10 { ts := types[:nt] - b.Run(fmt.Sprintf("MissTypes%d", nt), func { b | + b.Run(fmt.Sprintf("MissTypes%d", nt), func { b -> nc := runtime.GOMAXPROCS(0) for i := 0; i < b.N; i++ { clearCache() @@ -511,8 +511,8 @@ func BenchmarkTypeFieldsCache(b *testing.B) { for _, t := range types[:nt] { cachedTypeFields(t) } - b.Run(fmt.Sprintf("HitTypes%d", nt), func { b | - b.RunParallel(func { pb | for pb.Next() { + b.Run(fmt.Sprintf("HitTypes%d", nt), func { b -> + b.RunParallel(func { pb -> for pb.Next() { cachedTypeFields(types[0]) } }) }) @@ -527,7 +527,7 @@ func BenchmarkEncodeMarshaler(b *testing.B) { B RawMessage }{} - b.RunParallel(func { pb | + b.RunParallel(func { pb -> enc := NewEncoder(io.Discard) for pb.Next() { @@ -544,7 +544,7 @@ func BenchmarkEncoderEncode(b *testing.B) { X, Y string } v := &T{"foo", "bar"} - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { if err := NewEncoder(io.Discard).Encode(v); err != nil { b.Fatalf("Encode error: %v", err) diff --git a/src/encoding/json/decode_test.go b/src/encoding/json/decode_test.go index e7e7208a8a9e0..e06a1d00e010a 100644 --- a/src/encoding/json/decode_test.go +++ b/src/encoding/json/decode_test.go @@ -1076,7 +1076,7 @@ func TestMarshalInvalidUTF8(t *testing.T) { {Name(""), "\xe6\x97\xa5\xe6\x9c\xac\xff\xaa\x9e", `"日本\ufffd\ufffd\ufffd"`}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> got, err := Marshal(tt.in) if string(got) != tt.want || err != nil { t.Errorf("%s: Marshal(%q):\n\tgot: (%q, %v)\n\twant: (%q, nil)", tt.Where, tt.in, got, err, tt.want) @@ -1148,7 +1148,7 @@ func equalError(a, b error) bool { func TestUnmarshal(t *testing.T) { for _, tt := range unmarshalTests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> in := []byte(tt.in) var scan scanner if err := checkValid(in, &scan); err != nil { @@ -1256,7 +1256,7 @@ func TestNumberAccessors(t *testing.T) { {CaseName: Name(""), in: "1e1000", intErr: "strconv.ParseInt: parsing \"1e1000\": invalid syntax", floatErr: "strconv.ParseFloat: parsing \"1e1000\": value out of range"}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> n := Number(tt.in) if got := n.String(); got != tt.in { t.Errorf("%s: Number(%q).String() = %s, want %s", tt.Where, tt.in, got, tt.in) @@ -1351,7 +1351,7 @@ func TestErrorMessageFromMisusedString(t *testing.T) { {Name(""), `{"result":"\"foo"}`, `json: invalid use of ,string struct tag, trying to unmarshal "\"foo" into string`}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> r := strings.NewReader(tt.in) var s WrongString err := NewDecoder(r).Decode(&s) @@ -1782,7 +1782,7 @@ func TestInterfaceSet(t *testing.T) { {Name(""), intpp(intp(1)), `null`, intpp(nil)}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> b := struct{ X any }{tt.pre} blob := `{"X":` + tt.json + `}` if err := Unmarshal([]byte(blob), &b); err != nil { @@ -2037,7 +2037,7 @@ func TestUnmarshalTypeError(t *testing.T) { {Name(""), new(error), `true`}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> err := Unmarshal([]byte(tt.in), tt.dest) if _, ok := err.(*UnmarshalTypeError); !ok { t.Errorf("%s: Unmarshal(%#q, %T):\n\tgot: %T\n\twant: %T", @@ -2063,7 +2063,7 @@ func TestUnmarshalSyntax(t *testing.T) { {Name(""), `{"key":1,`}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> err := Unmarshal([]byte(tt.in), &x) if _, ok := err.(*SyntaxError); !ok { t.Errorf("%s: Unmarshal(%#q, any):\n\tgot: %T\n\twant: %T", @@ -2178,7 +2178,7 @@ func TestPrefilled(t *testing.T) { out: &[...]int{3, 0}, }} for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> ptrstr := fmt.Sprintf("%v", tt.ptr) err := Unmarshal([]byte(tt.in), tt.ptr) // tt.ptr edited here if err != nil { @@ -2203,7 +2203,7 @@ func TestInvalidUnmarshal(t *testing.T) { {Name(""), (*int)(nil), "json: Unmarshal(nil *int)"}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> err := Unmarshal(buf, tt.v) if err == nil { t.Fatalf("%s: Unmarshal error: got nil, want non-nil", tt.Where) @@ -2228,7 +2228,7 @@ func TestInvalidUnmarshalText(t *testing.T) { {Name(""), new(net.IP), "json: cannot unmarshal number into Go value of type *net.IP"}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> err := Unmarshal(buf, tt.v) if err == nil { t.Fatalf("%s: Unmarshal error: got nil, want non-nil", tt.Where) @@ -2394,7 +2394,7 @@ func TestUnmarshalEmbeddedUnexported(t *testing.T) { out: &S9{}, }} for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> err := Unmarshal([]byte(tt.in), tt.ptr) if !equalError(err, tt.err) { t.Errorf("%s: Unmarshal error:\n\tgot: %v\n\twant: %v", tt.Where, err, tt.err) @@ -2433,7 +2433,7 @@ func TestUnmarshalErrorAfterMultipleJSON(t *testing.T) { err: &SyntaxError{"invalid character '#' in literal null (expecting 'l')", 13}, }} for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> dec := NewDecoder(strings.NewReader(tt.in)) var err error for err == nil { @@ -2604,7 +2604,7 @@ func TestUnmarshalMaxDepth(t *testing.T) { for _, tt := range tests { for _, target := range targets { - t.Run(target.Name+"-"+tt.Name, func { t | + t.Run(target.Name+"-"+tt.Name, func { t -> err := Unmarshal([]byte(tt.data), target.newValue()) if !tt.errMaxDepth { if err != nil { diff --git a/src/encoding/json/encode.go b/src/encoding/json/encode.go index 56bd9847c0c2b..eee78ef2bedc2 100644 --- a/src/encoding/json/encode.go +++ b/src/encoding/json/encode.go @@ -354,7 +354,7 @@ func typeEncoder(t reflect.Type) encoderFunc { f encoderFunc ) wg.Add(1) - fi, loaded := encoderCache.LoadOrStore(t, encoderFunc(func { e, v, opts | + fi, loaded := encoderCache.LoadOrStore(t, encoderFunc(func { e, v, opts -> wg.Wait() f(e, v, opts) })) @@ -759,7 +759,7 @@ func (me mapEncoder) encode(e *encodeState, v reflect.Value, opts encOpts) { } sv[i].v = mi.Value() } - slices.SortFunc(sv, func { i, j | return strings.Compare(i.ks, j.ks) }) + slices.SortFunc(sv, func { i, j -> return strings.Compare(i.ks, j.ks) }) for i, kv := range sv { if i > 0 { @@ -1181,7 +1181,7 @@ func typeFields(t reflect.Type) structFields { } } - slices.SortFunc(fields, func { a, b | + slices.SortFunc(fields, func { a, b -> // sort field by name, breaking ties with depth, then // breaking ties with "name came from json tag", then // breaking ties with index sequence. @@ -1229,7 +1229,7 @@ func typeFields(t reflect.Type) structFields { } fields = out - slices.SortFunc(fields, func { i, j | return slices.Compare(i.index, j.index) }) + slices.SortFunc(fields, func { i, j -> return slices.Compare(i.index, j.index) }) for i := range fields { f := &fields[i] diff --git a/src/encoding/json/encode_test.go b/src/encoding/json/encode_test.go index 89ad5f7c2c4e6..108e1416b3ce0 100644 --- a/src/encoding/json/encode_test.go +++ b/src/encoding/json/encode_test.go @@ -115,7 +115,7 @@ func TestRoundtripStringTag(t *testing.T) { }`, }} for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> got, err := MarshalIndent(&tt.in, "", "\t") if err != nil { t.Fatalf("%s: MarshalIndent error: %v", tt.Where, err) @@ -231,7 +231,7 @@ func TestUnsupportedValues(t *testing.T) { {Name(""), recursiveSliceCycle}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> if _, err := Marshal(tt.in); err != nil { if _, ok := err.(*UnsupportedValueError); !ok { t.Errorf("%s: Marshal error:\n\tgot: %T\n\twant: %T", tt.Where, err, new(UnsupportedValueError)) @@ -528,7 +528,7 @@ func TestAnonymousFields(t *testing.T) { }} for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> b, err := Marshal(tt.makeInput()) if err != nil { t.Fatalf("%s: Marshal error: %v", tt.Where, err) @@ -606,7 +606,7 @@ func TestNilMarshal(t *testing.T) { {Name(""), struct{ M any }{(*nilTextMarshaler)(nil)}, `{"M":null}`}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> switch got, err := Marshal(tt.in); { case err != nil: t.Fatalf("%s: Marshal error: %v", tt.Where, err) @@ -881,7 +881,7 @@ func TestEncodeBytekind(t *testing.T) { {Name(""), []textfloat{12, 3}, `["TF:12.00","TF:3.00"]`}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> b, err := Marshal(tt.in) if err != nil { t.Errorf("%s: Marshal error: %v", tt.Where, err) @@ -1012,7 +1012,7 @@ func TestMarshalFloat(t *testing.T) { } next := math.Nextafter if bits == 32 { - next = func { g, h | return float64(math.Nextafter32(float32(g), float32(h))) } + next = func { g, h -> return float64(math.Nextafter32(float32(g), float32(h))) } } test(f, bits) test(next(f, bigger), bits) @@ -1118,7 +1118,7 @@ func TestMarshalRawMessageValue(t *testing.T) { } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> b, err := Marshal(tt.in) if ok := (err == nil); ok != tt.ok { if err != nil { @@ -1183,7 +1183,7 @@ func TestMarshalerError(t *testing.T) { }} for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> got := tt.err.Error() if got != tt.want { t.Errorf("%s: Error:\n\tgot: %s\n\twant: %s", tt.Where, got, tt.want) diff --git a/src/encoding/json/fold_test.go b/src/encoding/json/fold_test.go index 3280cf1ee1046..53cb1650d0060 100644 --- a/src/encoding/json/fold_test.go +++ b/src/encoding/json/fold_test.go @@ -40,7 +40,7 @@ func FuzzEqualFold(f *testing.F) { f.Add([]byte(ss[0]), []byte(ss[1])) } equalFold := func(x, y []byte) bool { return string(foldName(x)) == string(foldName(y)) } - f.Fuzz(func { t, x, y | + f.Fuzz(func { t, x, y -> got := equalFold(x, y) want := bytes.EqualFold(x, y) if got != want { diff --git a/src/encoding/json/fuzz_test.go b/src/encoding/json/fuzz_test.go index d9d747b5a4917..7c0fdffb56f4e 100644 --- a/src/encoding/json/fuzz_test.go +++ b/src/encoding/json/fuzz_test.go @@ -27,7 +27,7 @@ func FuzzUnmarshalJSON(f *testing.F) { "float": 3e-9" }`)) - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> for _, typ := range []func() interface{}{ func() interface{} { return new(interface{}) }, func() interface{} { return new(map[string]interface{}) }, @@ -67,7 +67,7 @@ func FuzzDecoderToken(f *testing.F) { "float": 3e-9" }`)) - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> r := bytes.NewReader(b) d := NewDecoder(r) for { diff --git a/src/encoding/json/scanner_test.go b/src/encoding/json/scanner_test.go index dad8521d0697e..dd7f46c86590c 100644 --- a/src/encoding/json/scanner_test.go +++ b/src/encoding/json/scanner_test.go @@ -18,7 +18,7 @@ func indentNewlines(s string) string { } func stripWhitespace(s string) string { - return strings.Map(func { r | + return strings.Map(func { r -> if r == ' ' || r == '\n' || r == '\r' || r == '\t' { return -1 } @@ -40,7 +40,7 @@ func TestValid(t *testing.T) { {Name(""), `{"foo":"bar","bar":{"baz":["qux"]}}`, true}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> if ok := Valid([]byte(tt.data)); ok != tt.ok { t.Errorf("%s: Valid(`%s`) = %v, want %v", tt.Where, tt.data, ok, tt.ok) } @@ -75,7 +75,7 @@ func TestCompactAndIndent(t *testing.T) { } var buf bytes.Buffer for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> buf.Reset() if err := Compact(&buf, []byte(tt.compact)); err != nil { t.Errorf("%s: Compact error: %v", tt.Where, err) @@ -118,7 +118,7 @@ func TestCompactSeparators(t *testing.T) { {Name(""), "{\"\u2029\" :2}", "{\"\u2029\":2}"}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> var buf bytes.Buffer if err := Compact(&buf, []byte(tt.in)); err != nil { t.Errorf("%s: Compact error: %v", tt.Where, err) @@ -194,7 +194,7 @@ func TestIndentErrors(t *testing.T) { {Name(""), `{"X": "foo" "Y": "bar"}`, &SyntaxError{"invalid character '\"' after object key:value pair", 13}}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> slice := make([]uint8, 0) buf := bytes.NewBuffer(slice) if err := Indent(buf, []uint8(tt.in), "", ""); err != nil { diff --git a/src/encoding/json/stream_test.go b/src/encoding/json/stream_test.go index e42846a836e1f..e5a4ebc29381c 100644 --- a/src/encoding/json/stream_test.go +++ b/src/encoding/json/stream_test.go @@ -213,7 +213,7 @@ func TestEncoderSetEscapeHTML(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> var buf strings.Builder enc := NewEncoder(&buf) if err := enc.Encode(tt.v); err != nil { @@ -363,7 +363,7 @@ func TestBlocking(t *testing.T) { {Name(""), `[1, 2, 3]`}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> r, w := net.Pipe() go w.Write([]byte(tt.in)) var val any @@ -459,7 +459,7 @@ func TestDecodeInStream(t *testing.T) { }}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> dec := NewDecoder(strings.NewReader(tt.json)) for i, want := range tt.expTokens { var got any @@ -491,7 +491,7 @@ func TestDecodeInStream(t *testing.T) { func TestHTTPDecoding(t *testing.T) { const raw = `{ "foo": "bar" }` - ts := httptest.NewServer(http.HandlerFunc(func { w, r | w.Write([]byte(raw)) })) + ts := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Write([]byte(raw)) })) defer ts.Close() res, err := http.Get(ts.URL) if err != nil { diff --git a/src/encoding/json/tagkey_test.go b/src/encoding/json/tagkey_test.go index 10b423cafbbd1..cd49c9b24ba21 100644 --- a/src/encoding/json/tagkey_test.go +++ b/src/encoding/json/tagkey_test.go @@ -97,7 +97,7 @@ func TestStructTagObjectKey(t *testing.T) { {Name(""), unicodeTag{"Loukanikos"}, "Loukanikos", "Ελλάδα"}, } for _, tt := range tests { - t.Run(tt.Name, func { t | + t.Run(tt.Name, func { t -> b, err := Marshal(tt.raw) if err != nil { t.Fatalf("%s: Marshal error: %v", tt.Where, err) diff --git a/src/encoding/xml/marshal_test.go b/src/encoding/xml/marshal_test.go index 714d7aaa68006..b910492063989 100644 --- a/src/encoding/xml/marshal_test.go +++ b/src/encoding/xml/marshal_test.go @@ -1664,7 +1664,7 @@ func TestMarshal(t *testing.T) { continue } - t.Run(fmt.Sprintf("%d", idx), func { t | + t.Run(fmt.Sprintf("%d", idx), func { t -> data, err := Marshal(test.Value) if err != nil { if test.MarshalError == "" { @@ -1795,7 +1795,7 @@ func TestUnmarshal(t *testing.T) { dest := reflect.New(vt.Elem()).Interface() err := Unmarshal([]byte(test.ExpectXML), dest) - t.Run(fmt.Sprintf("%d", i), func { t | + t.Run(fmt.Sprintf("%d", i), func { t -> switch fix := dest.(type) { case *Feed: fix.Author.InnerXML = "" @@ -1912,7 +1912,7 @@ func TestMarshalFlush(t *testing.T) { func BenchmarkMarshal(b *testing.B) { b.ReportAllocs() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { Marshal(atomValue) } }) } @@ -1920,7 +1920,7 @@ func BenchmarkMarshal(b *testing.B) { func BenchmarkUnmarshal(b *testing.B) { b.ReportAllocs() xml := []byte(atomXML) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { Unmarshal(xml, &Feed{}) } }) } @@ -2558,7 +2558,7 @@ var closeTests = []struct { func TestClose(t *testing.T) { for _, tt := range closeTests { tt := tt - t.Run(tt.desc, func { t | + t.Run(tt.desc, func { t -> var out strings.Builder enc := NewEncoder(&out) for j, tok := range tt.toks { diff --git a/src/encoding/xml/xml_test.go b/src/encoding/xml/xml_test.go index 8b482e9ee212e..c04567ec00267 100644 --- a/src/encoding/xml/xml_test.go +++ b/src/encoding/xml/xml_test.go @@ -59,7 +59,7 @@ func TestDecodeEOF(t *testing.T) { for _, tc := range tests { for _, eof := range []bool{true, false} { name := fmt.Sprintf("%s/earlyEOF=%v", tc.name, eof) - t.Run(name, func { t | + t.Run(name, func { t -> d := NewTokenDecoder(&toks{ earlyEOF: eof, t: tc.tokens, @@ -101,7 +101,7 @@ func (t *toksNil) Token() (Token, error) { func TestDecodeNilToken(t *testing.T) { for _, strict := range []bool{true, false} { name := fmt.Sprintf("Strict=%v", strict) - t.Run(name, func { t | + t.Run(name, func { t -> start := StartElement{Name: Name{Local: "test"}} bad := StartElement{Name: Name{Local: "bad"}} d := NewTokenDecoder(&toksNil{ @@ -351,7 +351,7 @@ func (d *downCaser) Read(p []byte) (int, error) { func TestRawTokenAltEncoding(t *testing.T) { d := NewDecoder(strings.NewReader(testInputAltEncoding)) - d.CharsetReader = func { charset, input | + d.CharsetReader = func { charset, input -> if charset != "x-testing-uppercase" { t.Fatalf("unexpected charset %q", charset) } @@ -1222,7 +1222,7 @@ func TestNewTokenDecoderIdempotent(t *testing.T) { func TestWrapDecoder(t *testing.T) { d := NewDecoder(strings.NewReader(`[Re-enter Clown with a letter, and FABIAN]`)) - m := tokenMap(func { t | + m := tokenMap(func { t -> switch tok := t.(type) { case StartElement: if tok.Name.Local == "quote" { @@ -1328,7 +1328,7 @@ func TestRoundTrip(t *testing.T) { "comments in directives": `--x --> > --x ]>`, } for name, input := range tests { - t.Run(name, func { t | testRoundTrip(t, input) }) + t.Run(name, func { t -> testRoundTrip(t, input) }) } } @@ -1396,7 +1396,7 @@ const testInputHTMLAutoClose = `
abc

` func BenchmarkHTMLAutoClose(b *testing.B) { - b.RunParallel(func { p | + b.RunParallel(func { p -> for p.Next() { d := NewDecoder(strings.NewReader(testInputHTMLAutoClose)) d.Strict = false diff --git a/src/errors/wrap_test.go b/src/errors/wrap_test.go index 02b0ac8881246..937a974d39b2b 100644 --- a/src/errors/wrap_test.go +++ b/src/errors/wrap_test.go @@ -61,7 +61,7 @@ func TestIs(t *testing.T) { {multiErr{nil}, nil, false}, } for _, tc := range testCases { - t.Run("", func { t | + t.Run("", func { t -> if got := errors.Is(tc.err, tc.target); got != tc.match { t.Errorf("Is(%v, %v) = %v, want %v", tc.err, tc.target, got, tc.match) } @@ -201,7 +201,7 @@ func TestAs(t *testing.T) { // Clear the target pointer, in case it was set in a previous test. rtarget := reflect.ValueOf(tc.target) rtarget.Elem().Set(reflect.Zero(reflect.TypeOf(tc.target).Elem())) - t.Run(name, func { t | + t.Run(name, func { t -> match := errors.As(tc.err, tc.target) if match != tc.match { t.Fatalf("match: got %v; want %v", match, tc.match) @@ -226,7 +226,7 @@ func TestAsValidation(t *testing.T) { } err := errors.New("error") for _, tc := range testCases { - t.Run(fmt.Sprintf("%T(%v)", tc, tc), func { t | + t.Run(fmt.Sprintf("%T(%v)", tc, tc), func { t -> defer func() { recover() }() diff --git a/src/expvar/expvar.go b/src/expvar/expvar.go index 1a6eeb42a98aa..0f79f792f5e4a 100644 --- a/src/expvar/expvar.go +++ b/src/expvar/expvar.go @@ -136,13 +136,13 @@ func (v *Map) appendJSONMayExpand(b []byte, expand bool) []byte { mayAppendNewline := func(b []byte) []byte { return b } if expand { afterCommaDelim = '\n' - mayAppendNewline = func { b | return append(b, '\n') } + mayAppendNewline = func { b -> return append(b, '\n') } } b = append(b, '{') b = mayAppendNewline(b) first := true - v.Do(func { kv | + v.Do(func { kv -> if !first { b = append(b, ',', afterCommaDelim) } diff --git a/src/expvar/expvar_test.go b/src/expvar/expvar_test.go index 48fe15bf9b591..60c8ec2b1dd0c 100644 --- a/src/expvar/expvar_test.go +++ b/src/expvar/expvar_test.go @@ -67,7 +67,7 @@ func TestInt(t *testing.T) { func BenchmarkIntAdd(b *testing.B) { var v Int - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { v.Add(1) } }) } @@ -75,7 +75,7 @@ func BenchmarkIntAdd(b *testing.B) { func BenchmarkIntSet(b *testing.B) { var v Int - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { v.Set(1) } }) } @@ -109,7 +109,7 @@ func TestFloat(t *testing.T) { func BenchmarkFloatAdd(b *testing.B) { var f Float - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { f.Add(1.0) } }) } @@ -117,7 +117,7 @@ func BenchmarkFloatAdd(b *testing.B) { func BenchmarkFloatSet(b *testing.B) { var f Float - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { f.Set(1.0) } }) } @@ -147,7 +147,7 @@ func TestString(t *testing.T) { func BenchmarkStringSet(b *testing.B) { var s String - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { s.Set("red") } }) } @@ -285,7 +285,7 @@ func BenchmarkMapSet(b *testing.B) { v := new(Int) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { m.Set("red", v) } }) } @@ -305,7 +305,7 @@ func BenchmarkMapSetDifferent(b *testing.B) { b.ResetTimer() var n int32 - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := int(atomic.AddInt32(&n, 1)-1) % len(procKeys) keys := procKeys[i] @@ -343,13 +343,13 @@ func BenchmarkMapSetString(b *testing.B) { v := new(String) v.Set("Hello, !") - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { m.Set("red", v) } }) } func BenchmarkMapAddSame(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { m := new(Map).Init() m.Add("red", 1) @@ -373,7 +373,7 @@ func BenchmarkMapAddDifferent(b *testing.B) { b.ResetTimer() var n int32 - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := int(atomic.AddInt32(&n, 1)-1) % len(procKeys) keys := procKeys[i] @@ -407,7 +407,7 @@ func BenchmarkMapAddDifferentRandom(b *testing.B) { func BenchmarkMapAddSameSteadyState(b *testing.B) { m := new(Map).Init() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { m.Add("red", 1) } }) } @@ -426,7 +426,7 @@ func BenchmarkMapAddDifferentSteadyState(b *testing.B) { b.ResetTimer() var n int32 - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := int(atomic.AddInt32(&n, 1)-1) % len(procKeys) keys := procKeys[i] diff --git a/src/flag/example_func_test.go b/src/flag/example_func_test.go index 1b8f12169474b..f2411c8fbea57 100644 --- a/src/flag/example_func_test.go +++ b/src/flag/example_func_test.go @@ -16,7 +16,7 @@ func ExampleFunc() { fs := flag.NewFlagSet("ExampleFunc", flag.ContinueOnError) fs.SetOutput(os.Stdout) var ip net.IP - fs.Func("ip", "`IP address` to parse", func { s | + fs.Func("ip", "`IP address` to parse", func { s -> ip = net.ParseIP(s) if ip == nil { return errors.New("could not parse IP") @@ -44,7 +44,7 @@ func ExampleBoolFunc() { fs := flag.NewFlagSet("ExampleBoolFunc", flag.ContinueOnError) fs.SetOutput(os.Stdout) - fs.BoolFunc("log", "logs a dummy message", func { s | + fs.BoolFunc("log", "logs a dummy message", func { s -> fmt.Println("dummy message:", s) return nil }) diff --git a/src/flag/flag.go b/src/flag/flag.go index 9a9835f008d9f..9215f041b3bd8 100644 --- a/src/flag/flag.go +++ b/src/flag/flag.go @@ -420,7 +420,7 @@ func sortFlags(flags map[string]*Flag) []*Flag { result[i] = f i++ } - slices.SortFunc(result, func { a, b | return strings.Compare(a.Name, b.Name) }) + slices.SortFunc(result, func { a, b -> return strings.Compare(a.Name, b.Name) }) return result } @@ -604,7 +604,7 @@ func UnquoteUsage(flag *Flag) (name string, usage string) { // documentation for the global function PrintDefaults for more information. func (f *FlagSet) PrintDefaults() { var isZeroValueErrs []error - f.VisitAll(func { flag | + f.VisitAll(func { flag -> var b strings.Builder fmt.Fprintf(&b, " -%s", flag.Name) // Two spaces before -; see next two comments. name, usage := UnquoteUsage(flag) diff --git a/src/flag/flag_test.go b/src/flag/flag_test.go index 469350116782f..eafd7c62f8d7b 100644 --- a/src/flag/flag_test.go +++ b/src/flag/flag_test.go @@ -100,7 +100,7 @@ func TestEverything(t *testing.T) { } // Now test they're visited in sort order. var flagNames []string - Visit(func { f | flagNames = append(flagNames, f.Name) }) + Visit(func { f -> flagNames = append(flagNames, f.Name) }) if !slices.IsSorted(flagNames) { t.Errorf("flag names not sorted: %v", flagNames) } @@ -270,7 +270,7 @@ func TestUserDefinedFunc(t *testing.T) { flags := NewFlagSet("test", ContinueOnError) flags.SetOutput(io.Discard) var ss []string - flags.Func("v", "usage", func { s | + flags.Func("v", "usage", func { s -> ss = append(ss, s) return nil }) @@ -294,7 +294,7 @@ func TestUserDefinedFunc(t *testing.T) { // test Func error flags = NewFlagSet("test", ContinueOnError) flags.SetOutput(io.Discard) - flags.Func("v", "usage", func { s | return fmt.Errorf("test error") }) + flags.Func("v", "usage", func { s -> return fmt.Errorf("test error") }) // flag not set, so no error if err := flags.Parse(nil); err != nil { t.Error(err) @@ -805,7 +805,7 @@ func TestUserDefinedBoolFunc(t *testing.T) { flags := NewFlagSet("test", ContinueOnError) flags.SetOutput(io.Discard) var ss []string - flags.BoolFunc("v", "usage", func { s | + flags.BoolFunc("v", "usage", func { s -> ss = append(ss, s) return nil }) @@ -829,7 +829,7 @@ func TestUserDefinedBoolFunc(t *testing.T) { // test BoolFunc error flags = NewFlagSet("test", ContinueOnError) flags.SetOutput(io.Discard) - flags.BoolFunc("v", "usage", func { s | return fmt.Errorf("test error") }) + flags.BoolFunc("v", "usage", func { s -> return fmt.Errorf("test error") }) // flag not set, so no error if err := flags.Parse(nil); err != nil { t.Error(err) diff --git a/src/fmt/fmt_test.go b/src/fmt/fmt_test.go index ef4088212e2fc..b6577c4737a9a 100644 --- a/src/fmt/fmt_test.go +++ b/src/fmt/fmt_test.go @@ -1236,62 +1236,62 @@ func TestReorder(t *testing.T) { } func BenchmarkSprintfPadding(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%16f", 1.0) } }) } func BenchmarkSprintfEmpty(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("") } }) } func BenchmarkSprintfString(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%s", "hello") } }) } func BenchmarkSprintfTruncateString(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%.3s", "日本語日本語日本語日本語") } }) } func BenchmarkSprintfTruncateBytes(b *testing.B) { var bytes any = []byte("日本語日本語日本語日本語") - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%.3s", bytes) } }) } func BenchmarkSprintfSlowParsingPath(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%.v", nil) } }) } func BenchmarkSprintfQuoteString(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%q", "日本語日本語日本語") } }) } func BenchmarkSprintfInt(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%d", 5) } }) } func BenchmarkSprintfIntInt(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%d %d", 5, 6) } }) } func BenchmarkSprintfPrefixedInt(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("This is some meaningless prefix text that needs to be scanned %d", 6) } @@ -1299,59 +1299,59 @@ func BenchmarkSprintfPrefixedInt(b *testing.B) { } func BenchmarkSprintfFloat(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%g", 5.23184) } }) } func BenchmarkSprintfComplex(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%f", 5.23184+5.23184i) } }) } func BenchmarkSprintfBoolean(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%t", true) } }) } func BenchmarkSprintfHexString(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("% #x", "0123456789abcdef") } }) } func BenchmarkSprintfHexBytes(b *testing.B) { data := []byte("0123456789abcdef") - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("% #x", data) } }) } func BenchmarkSprintfBytes(b *testing.B) { data := []byte("0123456789abcdef") - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%v", data) } }) } func BenchmarkSprintfStringer(b *testing.B) { stringer := I(12345) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%v", stringer) } }) } func BenchmarkSprintfStructure(b *testing.B) { s := &[]any{SI{12345}, map[int]string{0: "hello"}} - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _ = Sprintf("%#v", s) } }) } func BenchmarkManyArgs(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var buf bytes.Buffer for pb.Next() { buf.Reset() diff --git a/src/fmt/scan_test.go b/src/fmt/scan_test.go index 3c63f4e42642d..d96fa31660f23 100644 --- a/src/fmt/scan_test.go +++ b/src/fmt/scan_test.go @@ -84,7 +84,7 @@ var ( type Xs string func (x *Xs) Scan(state ScanState, verb rune) error { - tok, err := state.Token(true, func { r | return r == verb }) + tok, err := state.Token(true, func { r -> return r == verb }) if err != nil { return err } @@ -531,13 +531,13 @@ func testScan(t *testing.T, f func(string) io.Reader, scan func(r io.Reader, a . func TestScan(t *testing.T) { for _, r := range readers { - t.Run(r.name, func { t | testScan(t, r.f, Fscan) }) + t.Run(r.name, func { t -> testScan(t, r.f, Fscan) }) } } func TestScanln(t *testing.T) { for _, r := range readers { - t.Run(r.name, func { t | testScan(t, r.f, Fscanln) }) + t.Run(r.name, func { t -> testScan(t, r.f, Fscanln) }) } } @@ -670,7 +670,7 @@ func testScanfMulti(t *testing.T, f func(string) io.Reader) { func TestScanfMulti(t *testing.T) { for _, r := range readers { - t.Run(r.name, func { t | testScanfMulti(t, r.f) }) + t.Run(r.name, func { t -> testScanfMulti(t, r.f) }) } } diff --git a/src/go/ast/commentmap.go b/src/go/ast/commentmap.go index be4c73554be5d..f13a3fff3b427 100644 --- a/src/go/ast/commentmap.go +++ b/src/go/ast/commentmap.go @@ -15,7 +15,7 @@ import ( // sortComments sorts the list of comment groups in source order. func sortComments(list []*CommentGroup) { - slices.SortFunc(list, func { a, b | return cmp.Compare(a.Pos(), b.Pos()) }) + slices.SortFunc(list, func { a, b -> return cmp.Compare(a.Pos(), b.Pos()) }) } // A CommentMap maps an AST node to a list of comment groups @@ -45,7 +45,7 @@ func (a byInterval) Swap(i, j int) { a[i], a[j] = a[j], a[i] } // nodeList returns the list of nodes of the AST n in source order. func nodeList(n Node) []Node { var list []Node - Inspect(n, func { n | + Inspect(n, func { n -> // don't collect comments switch n.(type) { case nil, *CommentGroup, *Comment: @@ -246,7 +246,7 @@ func (cmap CommentMap) Update(old, new Node) Node { // the AST specified by node. func (cmap CommentMap) Filter(node Node) CommentMap { umap := make(CommentMap) - Inspect(node, func { n | + Inspect(node, func { n -> if g := cmap[n]; len(g) > 0 { umap[n] = g } @@ -308,7 +308,7 @@ func (cmap CommentMap) String() string { for node := range cmap { nodes = append(nodes, node) } - slices.SortFunc(nodes, func { a, b | + slices.SortFunc(nodes, func { a, b -> r := cmp.Compare(a.Pos(), b.Pos()) if r != 0 { return r diff --git a/src/go/ast/example_test.go b/src/go/ast/example_test.go index cd56f6117abd1..c0569dabfb86b 100644 --- a/src/go/ast/example_test.go +++ b/src/go/ast/example_test.go @@ -30,7 +30,7 @@ var X = f(3.14)*2 + c } // Inspect the AST and print all identifiers and literals. - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> var s string switch x := n.(type) { case *ast.BasicLit: diff --git a/src/go/ast/import.go b/src/go/ast/import.go index a3f8213d118ad..2874816346d96 100644 --- a/src/go/ast/import.go +++ b/src/go/ast/import.go @@ -173,7 +173,7 @@ func sortSpecs(fset *token.FileSet, f *File, specs []Spec) []Spec { // Reassign the import paths to have the same position sequence. // Reassign each comment to the spec on the same line. // Sort the comments by new position. - slices.SortFunc(specs, func { a, b | + slices.SortFunc(specs, func { a, b -> ipath := importPath(a) jpath := importPath(b) r := cmp.Compare(ipath, jpath) @@ -225,7 +225,7 @@ func sortSpecs(fset *token.FileSet, f *File, specs []Spec) []Spec { } } - slices.SortFunc(comments, func { a, b | return cmp.Compare(a.Pos(), b.Pos()) }) + slices.SortFunc(comments, func { a, b -> return cmp.Compare(a.Pos(), b.Pos()) }) return specs } diff --git a/src/go/ast/issues_test.go b/src/go/ast/issues_test.go index 249a01729bb77..16c422ebe1bdd 100644 --- a/src/go/ast/issues_test.go +++ b/src/go/ast/issues_test.go @@ -26,7 +26,7 @@ func TestIssue33649(t *testing.T) { // find corresponding token.File var tf *token.File - fset.Iterate(func { f | + fset.Iterate(func { f -> tf = f return true }) diff --git a/src/go/ast/walk.go b/src/go/ast/walk.go index cd3fafa1a0d05..c226e1c4d3685 100644 --- a/src/go/ast/walk.go +++ b/src/go/ast/walk.go @@ -380,7 +380,7 @@ func Inspect(node Node, f func(Node) bool) { func Preorder(root Node) iter.Seq[Node] { return func(yield func(Node) bool) { ok := true - Inspect(root, func { n | + Inspect(root, func { n -> if n != nil { // yield must not be called once ok is false. ok = ok && yield(n) diff --git a/src/go/build/build.go b/src/go/build/build.go index 70c600b60467b..d71a9a292ee82 100644 --- a/src/go/build/build.go +++ b/src/go/build/build.go @@ -1938,7 +1938,7 @@ func (ctxt *Context) matchAuto(text string, allTags map[string]bool) bool { } func (ctxt *Context) eval(x constraint.Expr, allTags map[string]bool) bool { - return x.Eval(func { tag | return ctxt.matchTag(tag, allTags) }) + return x.Eval(func { tag -> return ctxt.matchTag(tag, allTags) }) } // matchTag reports whether the name is one of: diff --git a/src/go/build/build_test.go b/src/go/build/build_test.go index 878b5cc351e01..cc1694317d2f4 100644 --- a/src/go/build/build_test.go +++ b/src/go/build/build_test.go @@ -341,7 +341,7 @@ var shouldBuildTests = []struct { func TestShouldBuild(t *testing.T) { for _, tt := range shouldBuildTests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> ctx := &Context{BuildTags: []string{"yes"}} tags := map[string]bool{} shouldBuild, binaryOnly, err := ctx.shouldBuild([]byte(tt.content), tags) @@ -412,7 +412,7 @@ func TestMatchFile(t *testing.T) { } return &readNopCloser{strings.NewReader(tt.data)}, nil } - ctxt.JoinPath = func { elem | return strings.Join(elem, "+") } + ctxt.JoinPath = func { elem -> return strings.Join(elem, "+") } match, err := ctxt.MatchFile("x", tt.name) if match != tt.match || err != nil { t.Fatalf("MatchFile(%q) = %v, %v, want %v, nil", tt.name, match, err, tt.match) @@ -514,7 +514,7 @@ func TestImportDirNotExist(t *testing.T) { defer os.Setenv("GO111MODULE", os.Getenv("GO111MODULE")) for _, GO111MODULE := range []string{"off", "on"} { - t.Run("GO111MODULE="+GO111MODULE, func { t | + t.Run("GO111MODULE="+GO111MODULE, func { t -> os.Setenv("GO111MODULE", GO111MODULE) for _, test := range tests { diff --git a/src/go/build/constraint/expr_test.go b/src/go/build/constraint/expr_test.go index 07617af0636e8..b360bb8983082 100644 --- a/src/go/build/constraint/expr_test.go +++ b/src/go/build/constraint/expr_test.go @@ -39,7 +39,7 @@ var exprStringTests = []struct { func TestExprString(t *testing.T) { for i, tt := range exprStringTests { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> s := tt.x.String() if s != tt.out { t.Errorf("String() mismatch:\nhave %s\nwant %s", s, tt.out) @@ -70,7 +70,7 @@ var lexTests = []struct { func TestLex(t *testing.T) { for i, tt := range lexTests { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> p := &exprParser{s: tt.in} out := "" for { @@ -126,7 +126,7 @@ var parseExprTests = []struct { func TestParseExpr(t *testing.T) { for i, tt := range parseExprTests { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> x, err := parseExpr(tt.in) if err != nil { t.Fatal(err) @@ -153,7 +153,7 @@ var parseExprErrorTests = []struct { func TestParseError(t *testing.T) { for i, tt := range parseExprErrorTests { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> x, err := parseExpr(tt.in) if err == nil { t.Fatalf("parseExpr(%q) = %v, want error", tt.in, x) @@ -179,7 +179,7 @@ var exprEvalTests = []struct { func TestExprEval(t *testing.T) { for i, tt := range exprEvalTests { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> x, err := parseExpr(tt.in) if err != nil { t.Fatal(err) @@ -221,7 +221,7 @@ var parsePlusBuildExprTests = []struct { func TestParsePlusBuildExpr(t *testing.T) { for i, tt := range parsePlusBuildExprTests { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> x, _ := parsePlusBuildExpr(tt.in) if x.String() != tt.x.String() { t.Errorf("parsePlusBuildExpr(%q):\nhave %v\nwant %v", tt.in, x, tt.x) @@ -253,7 +253,7 @@ var constraintTests = []struct { func TestParse(t *testing.T) { for i, tt := range constraintTests { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> x, err := Parse(tt.in) if err != nil { if tt.err == "" { @@ -291,7 +291,7 @@ var plusBuildLinesTests = []struct { func TestPlusBuildLines(t *testing.T) { for i, tt := range plusBuildLinesTests { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> x, err := parseExpr(tt.in) if err != nil { t.Fatal(err) @@ -342,7 +342,7 @@ func TestSizeLimits(t *testing.T) { expr: "//go:build " + strings.Repeat("(a ||", maxSize+2), }, } { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> _, err := Parse(tc.expr) if err == nil { t.Error("expression did not trigger limit") @@ -372,7 +372,7 @@ func TestPlusSizeLimits(t *testing.T) { expr: "// +build " + strings.Repeat("a,", maxOldSize+2), }, } { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> _, err := Parse(tc.expr) if err == nil { t.Error("expression did not trigger limit") diff --git a/src/go/build/read_test.go b/src/go/build/read_test.go index 22d3076c8d909..1a41a5ce2f73c 100644 --- a/src/go/build/read_test.go +++ b/src/go/build/read_test.go @@ -151,7 +151,7 @@ func testRead(t *testing.T, tests []readTest, read func(io.Reader) ([]byte, erro } func TestReadGoInfo(t *testing.T) { - testRead(t, readGoInfoTests, func { r | + testRead(t, readGoInfoTests, func { r -> var info fileInfo err := readGoInfo(r, &info) return info.header, err @@ -241,7 +241,7 @@ func TestReadFailuresIgnored(t *testing.T) { tt.err = "" } } - testRead(t, tests, func { r | + testRead(t, tests, func { r -> var info fileInfo err := readGoInfo(r, &info) return info.header, err diff --git a/src/go/constant/example_test.go b/src/go/constant/example_test.go index b5e1fdeac4c57..6e2e7e8807835 100644 --- a/src/go/constant/example_test.go +++ b/src/go/constant/example_test.go @@ -98,7 +98,7 @@ func ExampleCompare() { constant.MakeFromLiteral(`"a"`, token.STRING, 0), } - slices.SortFunc(vs, func { a, b | + slices.SortFunc(vs, func { a, b -> if constant.Compare(a, token.LSS, b) { return -1 } diff --git a/src/go/constant/value_test.go b/src/go/constant/value_test.go index 7255460fc13b1..4a32ac870032f 100644 --- a/src/go/constant/value_test.go +++ b/src/go/constant/value_test.go @@ -689,7 +689,7 @@ func TestMake(t *testing.T) { func BenchmarkStringAdd(b *testing.B) { for size := 1; size <= 65536; size *= 4 { - b.Run(fmt.Sprint(size), func { b | + b.Run(fmt.Sprint(size), func { b -> b.ReportAllocs() n := int64(0) for i := 0; i < b.N; i++ { diff --git a/src/go/doc/comment/testdata_test.go b/src/go/doc/comment/testdata_test.go index 597e44df51625..d96179e9174a8 100644 --- a/src/go/doc/comment/testdata_test.go +++ b/src/go/doc/comment/testdata_test.go @@ -48,7 +48,7 @@ func TestTestdata(t *testing.T) { return bytes.ReplaceAll(b, []byte("$\n"), []byte("\n")) } for _, file := range files { - t.Run(filepath.Base(file), func { t | + t.Run(filepath.Base(file), func { t -> var pr Printer a, err := txtar.ParseFile(file) if err != nil { diff --git a/src/go/doc/comment/text.go b/src/go/doc/comment/text.go index cd71fa574cc9d..cc1253281c454 100644 --- a/src/go/doc/comment/text.go +++ b/src/go/doc/comment/text.go @@ -278,7 +278,7 @@ func wrap(words []string, max int) (seq []int) { g := func(i, j int) score { return add(f[i], weight(i, j)) } bridge := func(a, b, c int) bool { - k := c + sort.Search(len(words)+1-c, func { k | + k := c + sort.Search(len(words)+1-c, func { k -> k += c return cmp(g(a, k), g(b, k)) > 0 }) diff --git a/src/go/doc/comment/wrap_test.go b/src/go/doc/comment/wrap_test.go index d972cf8485e20..abaf3afaa1687 100644 --- a/src/go/doc/comment/wrap_test.go +++ b/src/go/doc/comment/wrap_test.go @@ -38,11 +38,11 @@ func TestWrap(t *testing.T) { } for n := 1; n <= len(words) && !t.Failed(); n++ { - t.Run(fmt.Sprint("n=", n), func { t | + t.Run(fmt.Sprint("n=", n), func { t -> words := words[:n] t.Logf("words: %v", words) for max := 1; max < 100 && !t.Failed(); max++ { - t.Run(fmt.Sprint("max=", max), func { t | + t.Run(fmt.Sprint("max=", max), func { t -> seq := wrap(words, max) // Compute score for seq. diff --git a/src/go/doc/doc_test.go b/src/go/doc/doc_test.go index ac28e77e92981..d12ec20263ae8 100644 --- a/src/go/doc/doc_test.go +++ b/src/go/doc/doc_test.go @@ -86,7 +86,7 @@ func test(t *testing.T, mode Mode) { if err != nil { t.Fatal(err) } - filter = func { fi | return isGoFile(fi) && rx.MatchString(fi.Name()) } + filter = func { fi -> return isGoFile(fi) && rx.MatchString(fi.Name()) } } // get packages @@ -98,7 +98,7 @@ func test(t *testing.T, mode Mode) { // test packages for _, pkg := range pkgs { - t.Run(pkg.Name, func { t | + t.Run(pkg.Name, func { t -> importPath := dataDir + "/" + pkg.Name var files []*ast.File for _, f := range pkg.Files { @@ -145,9 +145,9 @@ func test(t *testing.T, mode Mode) { } func Test(t *testing.T) { - t.Run("default", func { t | test(t, 0) }) - t.Run("AllDecls", func { t | test(t, AllDecls) }) - t.Run("AllMethods", func { t | test(t, AllMethods) }) + t.Run("default", func { t -> test(t, 0) }) + t.Run("AllDecls", func { t -> test(t, AllDecls) }) + t.Run("AllMethods", func { t -> test(t, AllMethods) }) } func TestFuncs(t *testing.T) { @@ -187,7 +187,7 @@ func TestFuncs(t *testing.T) { } compareSlices(t, "Funcs", doc.Funcs, funcsPackage.Funcs, compareFuncs) - compareSlices(t, "Types", doc.Types, funcsPackage.Types, func { t, msg, got, want | + compareSlices(t, "Types", doc.Types, funcsPackage.Types, func { t, msg, got, want -> if got.Name != want.Name { t.Errorf("%s.Name: got %q, want %q", msg, got.Name, want.Name) } else { diff --git a/src/go/doc/example.go b/src/go/doc/example.go index 1bd286a32dc24..c36b4294e25af 100644 --- a/src/go/doc/example.go +++ b/src/go/doc/example.go @@ -105,7 +105,7 @@ func Examples(testFiles ...*ast.File) []*Example { list = append(list, flist...) } // sort by name - slices.SortFunc(list, func { a, b | return cmp.Compare(a.Name, b.Name) }) + slices.SortFunc(list, func { a, b -> return cmp.Compare(a.Name, b.Name) }) return list } @@ -308,8 +308,8 @@ func playExample(file *ast.File, f *ast.FuncDecl) *ast.File { decls = append(decls, depDecls...) decls = append(decls, funcDecl) - slices.SortFunc(decls, func { a, b | return cmp.Compare(a.Pos(), b.Pos()) }) - slices.SortFunc(comments, func { a, b | return cmp.Compare(a.Pos(), b.Pos()) }) + slices.SortFunc(decls, func { a, b -> return cmp.Compare(a.Pos(), b.Pos()) }) + slices.SortFunc(comments, func { a, b -> return cmp.Compare(a.Pos(), b.Pos()) }) // Synthesize file. return &ast.File{ @@ -338,7 +338,7 @@ func findDeclsAndUnresolved(body ast.Node, topDecls map[*ast.Object]ast.Decl, ty usedObjs := make(map[*ast.Object]bool) // set of objects reachable from the body (each declared by a usedDecl) var inspectFunc func(ast.Node) bool - inspectFunc = func { n | + inspectFunc = func { n -> switch e := n.(type) { case *ast.Ident: if e.Obj == nil && e.Name != "_" { @@ -486,7 +486,7 @@ func findDeclsAndUnresolved(body ast.Node, topDecls map[*ast.Object]ast.Decl, ty func hasIota(s ast.Spec) bool { has := false - ast.Inspect(s, func { n | + ast.Inspect(s, func { n -> // Check that this is the special built-in "iota" identifier, not // a user-defined shadow. if id, ok := n.(*ast.Ident); ok && id.Name == "iota" && id.Obj == nil { @@ -515,7 +515,7 @@ func findImportGroupStarts1(origImps []*ast.ImportSpec) []*ast.ImportSpec { imps := make([]*ast.ImportSpec, len(origImps)) copy(imps, origImps) // Assume the imports are sorted by position. - slices.SortFunc(imps, func { a, b | return cmp.Compare(a.Pos(), b.Pos()) }) + slices.SortFunc(imps, func { a, b -> return cmp.Compare(a.Pos(), b.Pos()) }) // Assume gofmt has been applied, so there is a blank line between adjacent imps // if and only if they are more than 2 positions apart (newline, tab). var groupStarts []*ast.ImportSpec @@ -670,7 +670,7 @@ func classifyExamples(p *Package, examples []*Example) { // Sort list of example according to the user-specified suffix name. for _, exs := range ids { - slices.SortFunc(*exs, func { a, b | return cmp.Compare(a.Suffix, b.Suffix) }) + slices.SortFunc(*exs, func { a, b -> return cmp.Compare(a.Suffix, b.Suffix) }) } } diff --git a/src/go/doc/example_internal_test.go b/src/go/doc/example_internal_test.go index 820dede99417e..20476fbd115f1 100644 --- a/src/go/doc/example_internal_test.go +++ b/src/go/doc/example_internal_test.go @@ -98,7 +98,7 @@ import ( want: []string{"a", "b", "c"}, }, } { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> fset := token.NewFileSet() file, err := parser.ParseFile(fset, "test.go", strings.NewReader(test.in), parser.ParseComments) if err != nil { diff --git a/src/go/doc/example_test.go b/src/go/doc/example_test.go index 0c8673293cab8..3028009e31a82 100644 --- a/src/go/doc/example_test.go +++ b/src/go/doc/example_test.go @@ -27,7 +27,7 @@ func TestExamples(t *testing.T) { t.Fatal(err) } for _, filename := range filenames { - t.Run(strings.TrimSuffix(filepath.Base(filename), ".go"), func { t | + t.Run(strings.TrimSuffix(filepath.Base(filename), ".go"), func { t -> fset := token.NewFileSet() astFile, err := parser.ParseFile(fset, filename, nil, parser.ParseComments) if err != nil { diff --git a/src/go/doc/headscan.go b/src/go/doc/headscan.go index a453cc5f6bce1..a22e1b00cb153 100644 --- a/src/go/doc/headscan.go +++ b/src/go/doc/headscan.go @@ -63,7 +63,7 @@ func main() { flag.Parse() fset := token.NewFileSet() nheadings := 0 - err := filepath.WalkDir(*root, func { path, info, err | + err := filepath.WalkDir(*root, func { path, info, err -> if !info.IsDir() { return nil } diff --git a/src/go/doc/reader.go b/src/go/doc/reader.go index 21c274a3eaf10..25e8381b0f56c 100644 --- a/src/go/doc/reader.go +++ b/src/go/doc/reader.go @@ -849,7 +849,7 @@ func sortedValues(m []*Value, tok token.Token) []*Value { } list = list[0:i] - slices.SortFunc(list, func { a, b | + slices.SortFunc(list, func { a, b -> r := strings.Compare(sortingName(a.Decl), sortingName(b.Decl)) if r != 0 { return r @@ -876,7 +876,7 @@ func sortedTypes(m map[string]*namedType, allMethods bool) []*Type { i++ } - slices.SortFunc(list, func { a, b | return strings.Compare(a.Name, b.Name) }) + slices.SortFunc(list, func { a, b -> return strings.Compare(a.Name, b.Name) }) return list } @@ -904,7 +904,7 @@ func sortedFuncs(m methodSet, allMethods bool) []*Func { } } list = list[0:i] - slices.SortFunc(list, func { a, b | return strings.Compare(a.Name, b.Name) }) + slices.SortFunc(list, func { a, b -> return strings.Compare(a.Name, b.Name) }) return list } diff --git a/src/go/format/benchmark_test.go b/src/go/format/benchmark_test.go index f63cb11d8f543..bcdc315c2243b 100644 --- a/src/go/format/benchmark_test.go +++ b/src/go/format/benchmark_test.go @@ -73,7 +73,7 @@ func BenchmarkFormat(b *testing.B) { } } - b.Run(fmt.Sprintf("%s-%d", t.name, t.n), func { b | + b.Run(fmt.Sprintf("%s-%d", t.name, t.n), func { b -> b.SetBytes(int64(len(data))) b.ReportAllocs() b.ResetTimer() diff --git a/src/go/format/internal.go b/src/go/format/internal.go index d9f01c9a6cfcf..3e34dcf9ddf17 100644 --- a/src/go/format/internal.go +++ b/src/go/format/internal.go @@ -42,7 +42,7 @@ func parse(fset *token.FileSet, filename string, src []byte, fragmentOk bool) ( psrc := append([]byte("package p;"), src...) file, err = parser.ParseFile(fset, filename, psrc, parserMode) if err == nil { - sourceAdj = func { src, indent | + sourceAdj = func { src, indent -> // Remove the package clause. // Gofmt has turned the ';' into a '\n'. src = src[indent+len("package p\n"):] @@ -66,7 +66,7 @@ func parse(fset *token.FileSet, filename string, src []byte, fragmentOk bool) ( fsrc := append(append([]byte("package p; func _() {"), src...), '\n', '\n', '}') file, err = parser.ParseFile(fset, filename, fsrc, parserMode) if err == nil { - sourceAdj = func { src, indent | + sourceAdj = func { src, indent -> // Cap adjusted indent to zero. if indent < 0 { indent = 0 diff --git a/src/go/importer/importer_test.go b/src/go/importer/importer_test.go index 406624e490e00..d61e666adcb93 100644 --- a/src/go/importer/importer_test.go +++ b/src/go/importer/importer_test.go @@ -36,7 +36,7 @@ func TestForCompiler(t *testing.T) { fset := token.NewFileSet() - t.Run("LookupDefault", func { t | + t.Run("LookupDefault", func { t -> imp := ForCompiler(fset, compiler, nil) pkg, err := imp.Import(thePackage) if err != nil { @@ -62,7 +62,7 @@ func TestForCompiler(t *testing.T) { } }) - t.Run("LookupCustom", func { t | + t.Run("LookupCustom", func { t -> // TODO(mdempsky): Decide whether to remove this test, or to fix // support for it in unified IR. It's not clear that we actually // need to support importing "math/big" as "math/bigger", for diff --git a/src/go/internal/gccgoimporter/parser.go b/src/go/internal/gccgoimporter/parser.go index dbbffd4360f99..71ea40ed73a47 100644 --- a/src/go/internal/gccgoimporter/parser.go +++ b/src/go/internal/gccgoimporter/parser.go @@ -63,7 +63,7 @@ func (p *parser) init(filename string, src io.Reader, imports map[string]*types. func (p *parser) initScanner(filename string, src io.Reader) { p.scanner.Init(src) - p.scanner.Error = func { _, msg | p.error(msg) } + p.scanner.Error = func { _, msg -> p.error(msg) } p.scanner.Mode = scanner.ScanIdents | scanner.ScanInts | scanner.ScanFloats | scanner.ScanStrings p.scanner.Whitespace = 1<<'\t' | 1<<' ' p.scanner.Filename = filename // for good error messages diff --git a/src/go/internal/gcimporter/gcimporter_test.go b/src/go/internal/gcimporter/gcimporter_test.go index d2293527795ad..4e0eb7fb05ca0 100644 --- a/src/go/internal/gcimporter/gcimporter_test.go +++ b/src/go/internal/gcimporter/gcimporter_test.go @@ -166,7 +166,7 @@ func TestImportTypeparamTests(t *testing.T) { continue } - t.Run(entry.Name(), func { t | + t.Run(entry.Name(), func { t -> filename := filepath.Join(rootDir, entry.Name()) src, err := os.ReadFile(filename) if err != nil { @@ -365,7 +365,7 @@ func TestImportStdLib(t *testing.T) { var nimports int for _, pkg := range pkgs { - t.Run(pkg, func { t | + t.Run(pkg, func { t -> if testPath(t, pkg, filepath.Join(testenv.GOROOT(t), "src", path.Dir(pkg))) != nil { nimports++ } diff --git a/src/go/internal/gcimporter/iimport.go b/src/go/internal/gcimporter/iimport.go index 5341ec407d98b..84bcccf028503 100644 --- a/src/go/internal/gcimporter/iimport.go +++ b/src/go/internal/gcimporter/iimport.go @@ -205,7 +205,7 @@ func iImportData(fset *token.FileSet, imports map[string]*types.Package, dataRea // record all referenced packages as imports list := append(([]*types.Package)(nil), pkgList[1:]...) - slices.SortFunc(list, func { a, b | return strings.Compare(a.Path(), b.Path()) }) + slices.SortFunc(list, func { a, b -> return strings.Compare(a.Path(), b.Path()) }) localpkg.SetImports(list) // package was imported completely and without errors diff --git a/src/go/internal/gcimporter/ureader.go b/src/go/internal/gcimporter/ureader.go index f3e67f093babb..2c6065ac1204c 100644 --- a/src/go/internal/gcimporter/ureader.go +++ b/src/go/internal/gcimporter/ureader.go @@ -93,7 +93,7 @@ func readUnifiedPackage(fset *token.FileSet, ctxt *types.Context, imports map[st imps = append(imps, imp) } } - slices.SortFunc(imps, func { a, b | return strings.Compare(a.Path(), b.Path()) }) + slices.SortFunc(imps, func { a, b -> return strings.Compare(a.Path(), b.Path()) }) pkg.SetImports(imps) pkg.MarkComplete() diff --git a/src/go/internal/srcimporter/srcimporter.go b/src/go/internal/srcimporter/srcimporter.go index 5035a5b34238c..0ce07a0e987dc 100644 --- a/src/go/internal/srcimporter/srcimporter.go +++ b/src/go/internal/srcimporter/srcimporter.go @@ -166,7 +166,7 @@ func (p *Importer) parseFiles(dir string, filenames []string) ([]*ast.File, erro // use build.Context's OpenFile if there is one open := p.ctxt.OpenFile if open == nil { - open = func { name | return os.Open(name) } + open = func { name -> return os.Open(name) } } files := make([]*ast.File, len(filenames)) diff --git a/src/go/parser/error_test.go b/src/go/parser/error_test.go index 1a670b8a99c57..5e1a8f8e209ca 100644 --- a/src/go/parser/error_test.go +++ b/src/go/parser/error_test.go @@ -39,7 +39,7 @@ const testdata = "testdata" // getFile assumes that each filename occurs at most once func getFile(fset *token.FileSet, filename string) (file *token.File) { - fset.Iterate(func { f | + fset.Iterate(func { f -> if f.Name() == filename { if file != nil { panic(filename + " used multiple times") @@ -189,7 +189,7 @@ func TestErrors(t *testing.T) { } for _, d := range list { name := d.Name() - t.Run(name, func { t | + t.Run(name, func { t -> if !d.IsDir() && !strings.HasPrefix(name, ".") && (strings.HasSuffix(name, ".src") || strings.HasSuffix(name, ".go2")) { mode := DeclarationErrors | AllErrors if *traceErrs { diff --git a/src/go/parser/parser_test.go b/src/go/parser/parser_test.go index bc105f1a9736c..f8dbd6a987d84 100644 --- a/src/go/parser/parser_test.go +++ b/src/go/parser/parser_test.go @@ -227,7 +227,7 @@ func f() { L: } "L": ast.Lbl, } - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> if ident, ok := n.(*ast.Ident); ok { obj := ident.Obj if obj == nil { @@ -462,7 +462,7 @@ func TestIssue9979(t *testing.T) { } var pos, end token.Pos - ast.Inspect(f, func { x | + ast.Inspect(f, func { x -> switch s := x.(type) { case *ast.BlockStmt: pos, end = s.Pos()+1, s.End()-1 // exclude "{", "}" @@ -537,7 +537,7 @@ func TestIncompleteSelection(t *testing.T) { } var sel *ast.SelectorExpr - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> if n, ok := n.(*ast.SelectorExpr); ok { sel = n } @@ -650,7 +650,7 @@ func TestParseDepthLimit(t *testing.T) { } for _, tt := range parseDepthTests { for _, size := range []string{"small", "big"} { - t.Run(tt.name+"/"+size, func { t | + t.Run(tt.name+"/"+size, func { t -> n := maxNestLev + 1 if tt.parseMultiplier > 0 { n /= tt.parseMultiplier @@ -696,7 +696,7 @@ func TestScopeDepthLimit(t *testing.T) { continue } for _, size := range []string{"small", "big"} { - t.Run(tt.name+"/"+size, func { t | + t.Run(tt.name+"/"+size, func { t -> n := maxScopeDepth + 1 if tt.scopeMultiplier > 0 { n /= tt.scopeMultiplier @@ -753,7 +753,7 @@ func TestRangePos(t *testing.T) { t.Fatal(err) } - ast.Inspect(f, func { x | + ast.Inspect(f, func { x -> switch s := x.(type) { case *ast.RangeStmt: pos := fset.Position(s.Range) diff --git a/src/go/parser/resolver_test.go b/src/go/parser/resolver_test.go index 3a8877ec3a34b..0d87ae000e67a 100644 --- a/src/go/parser/resolver_test.go +++ b/src/go/parser/resolver_test.go @@ -35,7 +35,7 @@ func TestResolution(t *testing.T) { } for _, fi := range fis { - t.Run(fi.Name(), func { t | + t.Run(fi.Name(), func { t -> fset := token.NewFileSet() path := filepath.Join(dir, fi.Name()) src := readFile(path) // panics on failure @@ -77,7 +77,7 @@ func TestResolution(t *testing.T) { // identifier position with its declaration position. func declsFromParser(file *ast.File) map[token.Pos]token.Pos { objmap := map[token.Pos]token.Pos{} - ast.Inspect(file, func { node | + ast.Inspect(file, func { node -> // Ignore blank identifiers to reduce noise. if ident, _ := node.(*ast.Ident); ident != nil && ident.Obj != nil && ident.Name != "_" { objmap[ident.Pos()] = ident.Obj.Pos() diff --git a/src/go/printer/nodes.go b/src/go/printer/nodes.go index 0c5cd0d5aa4bb..68b30b44dee39 100644 --- a/src/go/printer/nodes.go +++ b/src/go/printer/nodes.go @@ -1250,7 +1250,7 @@ func stripParens(x ast.Expr) ast.Expr { // parentheses must not be stripped if there are any // unparenthesized composite literals starting with // a type name - ast.Inspect(px.X, func { node | + ast.Inspect(px.X, func { node -> switch x := node.(type) { case *ast.ParenExpr: // parentheses protect enclosed composite literals diff --git a/src/go/printer/printer_test.go b/src/go/printer/printer_test.go index 117221b2a40a0..3b0e8cb3b10e5 100644 --- a/src/go/printer/printer_test.go +++ b/src/go/printer/printer_test.go @@ -200,7 +200,7 @@ func TestFiles(t *testing.T) { source := filepath.Join(dataDir, e.source) golden := filepath.Join(dataDir, e.golden) mode := e.mode - t.Run(e.source, func { t | + t.Run(e.source, func { t -> t.Parallel() check(t, source, golden, mode) // TODO(gri) check that golden is idempotent @@ -549,7 +549,7 @@ func TestBaseIndent(t *testing.T) { for indent := 0; indent < 4; indent++ { indent := indent - t.Run(fmt.Sprint(indent), func { t | + t.Run(fmt.Sprint(indent), func { t -> t.Parallel() var buf bytes.Buffer (&Config{Tabwidth: tabwidth, Indent: indent}).Fprint(&buf, fset, file) diff --git a/src/go/scanner/scanner_test.go b/src/go/scanner/scanner_test.go index 1451c3cc78823..89565e9ef7888 100644 --- a/src/go/scanner/scanner_test.go +++ b/src/go/scanner/scanner_test.go @@ -575,7 +575,7 @@ func testSegments(t *testing.T, segments []segment, filename string) { // verify scan var S Scanner file := fset.AddFile(filename, fset.Base(), len(src)) - S.Init(file, []byte(src), func { pos, msg | t.Error(Error{pos, msg}) }, dontInsertSemis) + S.Init(file, []byte(src), func { pos, msg -> t.Error(Error{pos, msg}) }, dontInsertSemis) for _, s := range segments { p, _, lit := S.Scan() pos := file.Position(p) @@ -614,7 +614,7 @@ func TestInvalidLineDirectives(t *testing.T) { var S Scanner var s segment // current segment file := fset.AddFile(filepath.Join("dir", "TestInvalidLineDirectives"), fset.Base(), len(src)) - S.Init(file, []byte(src), func { pos, msg | + S.Init(file, []byte(src), func { pos, msg -> if msg != s.filename { t.Errorf("got error %q; want %q", msg, s.filename) } @@ -900,7 +900,7 @@ func BenchmarkScanFiles(b *testing.B) { "net/http/server.go", "go/scanner/errors.go", } { - b.Run(p, func { b | + b.Run(p, func { b -> b.StopTimer() filename := filepath.Join("..", "..", filepath.FromSlash(p)) src, err := os.ReadFile(filename) @@ -1081,7 +1081,7 @@ func TestNumbers(t *testing.T) { } { var s Scanner var err string - s.Init(fset.AddFile("", fset.Base(), len(test.src)), []byte(test.src), func { _, msg | if err == "" { + s.Init(fset.AddFile("", fset.Base(), len(test.src)), []byte(test.src), func { _, msg -> if err == "" { err = msg } }, 0) for i, want := range strings.Split(test.tokens, " ") { diff --git a/src/go/token/position.go b/src/go/token/position.go index 73b2c4a0522c5..3a6cb7624fe1c 100644 --- a/src/go/token/position.go +++ b/src/go/token/position.go @@ -323,7 +323,7 @@ func (f *File) Line(p Pos) int { } func searchLineInfos(a []lineInfo, x int) int { - i, found := slices.BinarySearchFunc(a, x, func { a, x | return cmp.Compare(a.Offset, x) }) + i, found := slices.BinarySearchFunc(a, x, func { a, x -> return cmp.Compare(a.Offset, x) }) if !found { // We want the lineInfo containing x, but if we didn't // find x then i is the next one. @@ -523,7 +523,7 @@ func (s *FileSet) Iterate(f func(*File) bool) { } func searchFiles(a []*File, x int) int { - i, found := slices.BinarySearchFunc(a, x, func { a, x | return cmp.Compare(a.base, x) }) + i, found := slices.BinarySearchFunc(a, x, func { a, x -> return cmp.Compare(a.base, x) }) if !found { // We want the File containing x, but if we didn't // find x then i is the next one. diff --git a/src/go/token/position_test.go b/src/go/token/position_test.go index f53837ab2ffc9..d2d13c107cb30 100644 --- a/src/go/token/position_test.go +++ b/src/go/token/position_test.go @@ -179,7 +179,7 @@ func TestFiles(t *testing.T) { } fset.AddFile(test.filename, base, test.size) j := 0 - fset.Iterate(func { f | + fset.Iterate(func { f -> if f.Name() != tests[j].filename { t.Errorf("got filename = %s; want %s", f.Name(), tests[j].filename) } @@ -469,7 +469,7 @@ func TestFileAddLineColumnInfo(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> fs := NewFileSet() f := fs.AddFile(filename, -1, filesize) for _, info := range test.infos { diff --git a/src/go/token/token_test.go b/src/go/token/token_test.go index 88ad40f5e50c2..bb511a05ab9d7 100644 --- a/src/go/token/token_test.go +++ b/src/go/token/token_test.go @@ -24,7 +24,7 @@ func TestIsIdentifier(t *testing.T) { {"LettersUnicode", "fóö", true}, } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> if got := IsIdentifier(test.in); got != test.want { t.Fatalf("IsIdentifier(%q) = %t, want %v", test.in, got, test.want) } diff --git a/src/go/types/api_test.go b/src/go/types/api_test.go index 9592e0529941a..dc7c635bdb553 100644 --- a/src/go/types/api_test.go +++ b/src/go/types/api_test.go @@ -634,7 +634,7 @@ type T[P any] []P makePkg(lib) pkg := makePkg(test.src) - t.Run(pkg.Name(), func { t | + t.Run(pkg.Name(), func { t -> // Sort instances in source order for stability. instances := sortedInstances(instMap) if got, want := len(instances), len(test.instances); got != want { @@ -693,7 +693,7 @@ func sortedInstances(m map[*ast.Ident]Instance) (instances []recordedInstance) { for id, inst := range m { instances = append(instances, recordedInstance{id, inst}) } - slices.SortFunc(instances, func { a, b | return CmpPos(a.Ident.Pos(), b.Ident.Pos()) }) + slices.SortFunc(instances, func { a, b -> return CmpPos(a.Ident.Pos(), b.Ident.Pos()) }) return instances } @@ -852,7 +852,7 @@ func (r *N[C]) n() { } switch fdecl.Name.Name { case "m": dm = def - ast.Inspect(fdecl.Body, func { n | + ast.Inspect(fdecl.Body, func { n -> if call, ok := n.(*ast.CallExpr); ok { sel := call.Fun.(*ast.SelectorExpr) use := info.Uses[sel.Sel].(*Func) @@ -1985,7 +1985,7 @@ func F[T *U, U any](param1, param2 int) /*param1=undef*/ (res1 /*res1=undef*/, r if gotObj != wantObj { // Print the scope tree of mainScope in case of error. var printScopeTree func(indent string, s *Scope) - printScopeTree = func { indent, s | + printScopeTree = func { indent, s -> t.Logf("%sscope %s %v-%v = %v", indent, ScopeComment(s), @@ -2631,7 +2631,7 @@ func fn() { // Collect all identifiers by name. idents := make(map[string][]*ast.Ident) - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> if id, ok := n.(*ast.Ident); ok { idents[id.Name] = append(idents[id.Name], id) } @@ -2640,7 +2640,7 @@ func fn() { for _, test := range tests { test := test - t.Run(test.name, func { t | + t.Run(test.name, func { t -> if got := len(idents[test.name]); got != 1 { t.Fatalf("found %d identifiers named %s, want 1", got, test.name) } @@ -3061,7 +3061,7 @@ type C = int // checking. func TestAnyHijacking_Check(t *testing.T) { for _, enableAlias := range []bool{false, true} { - t.Run(fmt.Sprintf("EnableAlias=%t", enableAlias), func { t | + t.Run(fmt.Sprintf("EnableAlias=%t", enableAlias), func { t -> setGotypesalias(t, enableAlias) var wg sync.WaitGroup for i := 0; i < 10; i++ { @@ -3084,7 +3084,7 @@ func TestAnyHijacking_Check(t *testing.T) { // Scope.Lookup outside of type checking. func TestAnyHijacking_Lookup(t *testing.T) { for _, enableAlias := range []bool{false, true} { - t.Run(fmt.Sprintf("EnableAlias=%t", enableAlias), func { t | + t.Run(fmt.Sprintf("EnableAlias=%t", enableAlias), func { t -> setGotypesalias(t, enableAlias) a := Universe.Lookup("any") if _, gotAlias := a.Type().(*Alias); gotAlias != enableAlias { diff --git a/src/go/types/builtins.go b/src/go/types/builtins.go index 2ccc81e43c694..b6d54475beebb 100644 --- a/src/go/types/builtins.go +++ b/src/go/types/builtins.go @@ -187,7 +187,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b if !isTypeParam(x.typ) { break } - if t.typeSet().underIs(func { t | + if t.typeSet().underIs(func { t -> switch t := arrayPtrDeref(t).(type) { case *Basic: if isString(t) && id == _Len { @@ -231,7 +231,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b // clear(m) check.verifyVersionf(call.Fun, go1_21, "clear") - if !underIs(x.typ, func { u | + if !underIs(x.typ, func { u -> switch u.(type) { case *Map, *Slice: return true @@ -249,7 +249,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b case _Close: // close(c) - if !underIs(x.typ, func { u | + if !underIs(x.typ, func { u -> uch, _ := u.(*Chan) if uch == nil { check.errorf(x, InvalidClose, invalidOp+"cannot close non-channel %s", x) @@ -391,7 +391,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b // The key cannot be a type parameter for now. map_ := x.typ var key Type - if !underIs(map_, func { u | + if !underIs(map_, func { u -> map_, _ := u.(*Map) if map_ == nil { check.errorf(x, InvalidDelete, invalidArg+"%s is not a map", x) @@ -967,7 +967,7 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x *operand, id builtinId) // Test if t satisfies the requirements for the argument // type and collect possible result types at the same time. var terms []*Term - if !tp.is(func { t | + if !tp.is(func { t -> if t == nil { return false } diff --git a/src/go/types/check_test.go b/src/go/types/check_test.go index c16d5363c3331..0f332f2135efd 100644 --- a/src/go/types/check_test.go +++ b/src/go/types/check_test.go @@ -165,7 +165,7 @@ func testFilesImpl(t *testing.T, filenames []string, srcs [][]byte, manual bool, var conf Config *boolFieldAddr(&conf, "_Trace") = manual && testing.Verbose() conf.Importer = importer.Default() - conf.Error = func { err | + conf.Error = func { err -> if *haltOnError { defer panic(err) } @@ -449,7 +449,7 @@ func testDirFiles(t *testing.T, dir string, manual bool) { if fi.IsDir() { testDir(t, path, manual) } else { - t.Run(filepath.Base(path), func { t | testPkg(t, []string{path}, manual) }) + t.Run(filepath.Base(path), func { t -> testPkg(t, []string{path}, manual) }) } } } @@ -468,7 +468,7 @@ func testDir(t *testing.T, dir string, manual bool) { filenames = append(filenames, filepath.Join(dir, fi.Name())) } - t.Run(filepath.Base(dir), func { t | testPkg(t, filenames, manual) }) + t.Run(filepath.Base(dir), func { t -> testPkg(t, filenames, manual) }) } func testPkg(t *testing.T, filenames []string, manual bool) { diff --git a/src/go/types/conversions.go b/src/go/types/conversions.go index 866194f5ec0bb..cf2807c69b414 100644 --- a/src/go/types/conversions.go +++ b/src/go/types/conversions.go @@ -59,7 +59,7 @@ func (check *Checker) conversion(x *operand, T Type) { // If T's type set is empty, or if it doesn't // have specific types, constant x cannot be // converted. - ok = Unalias(T).(*TypeParam).underIs(func { u | + ok = Unalias(T).(*TypeParam).underIs(func { u -> // u is nil if there are no specific type terms if u == nil { cause = check.sprintf("%s does not contain specific types", T) @@ -249,12 +249,12 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { switch { case Vp != nil && Tp != nil: x := *x // don't clobber outer x - return Vp.is(func { V | + return Vp.is(func { V -> if V == nil { return false // no specific types } x.typ = V.typ - return Tp.is(func { T | + return Tp.is(func { T -> if T == nil { return false // no specific types } @@ -267,7 +267,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { }) case Vp != nil: x := *x // don't clobber outer x - return Vp.is(func { V | + return Vp.is(func { V -> if V == nil { return false // no specific types } @@ -279,7 +279,7 @@ func (x *operand) convertibleTo(check *Checker, T Type, cause *string) bool { return true }) case Tp != nil: - return Tp.is(func { T | + return Tp.is(func { T -> if T == nil { return false // no specific types } diff --git a/src/go/types/decl.go b/src/go/types/decl.go index 7276b7a9a2b6d..05ca03e563d00 100644 --- a/src/go/types/decl.go +++ b/src/go/types/decl.go @@ -893,7 +893,7 @@ func (check *Checker) funcDecl(obj *Func, decl *declInfo) { func (check *Checker) declStmt(d ast.Decl) { pkg := check.pkg - check.walkDecl(d, func { d | + check.walkDecl(d, func { d -> switch d := d.(type) { case constDecl: top := len(check.delayed) diff --git a/src/go/types/errorcalls_test.go b/src/go/types/errorcalls_test.go index c728829ed0718..5c94014411591 100644 --- a/src/go/types/errorcalls_test.go +++ b/src/go/types/errorcalls_test.go @@ -27,7 +27,7 @@ func TestErrorCalls(t *testing.T) { } for _, file := range files { - ast.Inspect(file, func { n | + ast.Inspect(file, func { n -> call, _ := n.(*ast.CallExpr) if call == nil { return true @@ -46,7 +46,7 @@ func TestErrorCalls(t *testing.T) { return false } format := call.Args[errorfFormatIndex] - ast.Inspect(format, func { n | + ast.Inspect(format, func { n -> if lit, _ := n.(*ast.BasicLit); lit != nil && lit.Kind == token.STRING { if s, err := strconv.Unquote(lit.Value); err == nil { if !balancedParentheses(s) { diff --git a/src/go/types/expr.go b/src/go/types/expr.go index b242eda9c5dfa..32c903f6399e7 100644 --- a/src/go/types/expr.go +++ b/src/go/types/expr.go @@ -412,7 +412,7 @@ func (check *Checker) implicitTypeAndValue(x *operand, target Type) (Type, const } case *Interface: if isTypeParam(target) { - if !u.typeSet().underIs(func { u | + if !u.typeSet().underIs(func { u -> if u == nil { return false } @@ -579,7 +579,7 @@ func (check *Checker) incomparableCause(typ Type) string { } // see if we can extract a more specific error var cause string - comparable(typ, true, nil, func { format, args | cause = check.sprintf(format, args...) }) + comparable(typ, true, nil, func { format, args -> cause = check.sprintf(format, args...) }) return cause } @@ -1417,7 +1417,7 @@ func (check *Checker) exprInternal(T *target, x *operand, e ast.Expr, hint Type) x.typ = &Pointer{base: x.typ} default: var base Type - if !underIs(x.typ, func { u | + if !underIs(x.typ, func { u -> p, _ := u.(*Pointer) if p == nil { check.errorf(x, InvalidIndirection, invalidOp+"cannot indirect %s", x) diff --git a/src/go/types/generate_test.go b/src/go/types/generate_test.go index 726e2cf9913c5..0e700c4c442f6 100644 --- a/src/go/types/generate_test.go +++ b/src/go/types/generate_test.go @@ -229,7 +229,7 @@ func (m renameMap) renameSel(n *ast.SelectorExpr) { // Note: This doesn't change the use of the identifiers in comments. func renameIdents(f *ast.File, renames ...string) { m := makeRenameMap(renames...) - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.Ident: m.rename(&n.Name) @@ -242,7 +242,7 @@ func renameIdents(f *ast.File, renames ...string) { // renameSelectors is like renameIdents but only looks at selectors. func renameSelectors(f *ast.File, renames ...string) { m := makeRenameMap(renames...) - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.SelectorExpr: m.rename(&n.Sel.Name) @@ -257,7 +257,7 @@ func renameSelectors(f *ast.File, renames ...string) { // Each renames entry must be of the form "x.a->y.b". func renameSelectorExprs(f *ast.File, renames ...string) { m := makeRenameMap(renames...) - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.SelectorExpr: m.renameSel(n) @@ -270,7 +270,7 @@ func renameSelectorExprs(f *ast.File, renames ...string) { // renameImportPath is like renameIdents but renames import paths. func renameImportPath(f *ast.File, renames ...string) { m := makeRenameMap(renames...) - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.ImportSpec: if n.Path.Kind != token.STRING { @@ -299,7 +299,7 @@ func insertImportPath(f *ast.File, path string) { // uses of syntax.Pos to token.Pos, and calls to x.IsKnown() to x.IsValid(). func fixTokenPos(f *ast.File) { m := makeRenameMap(`"cmd/compile/internal/syntax"->"go/token"`, "syntax.Pos->token.Pos", "IsKnown->IsValid") - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.ImportSpec: // rewrite import path "cmd/compile/internal/syntax" to "go/token" @@ -324,7 +324,7 @@ func fixTokenPos(f *ast.File) { // fixSelValue updates the selector x.Sel.Value to x.Sel.Name. func fixSelValue(f *ast.File) { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.SelectorExpr: if n.Sel.Name == "Value" { @@ -342,7 +342,7 @@ func fixSelValue(f *ast.File) { // as first argument, renames the argument from "pos" to "posn", and updates a few internal uses of // "pos" to "posn" and "posn.Pos()" respectively. func fixInferSig(f *ast.File) { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.FuncDecl: if n.Name.Name == "infer" { @@ -392,7 +392,7 @@ func fixInferSig(f *ast.File) { // fixAtPosCall updates calls of the form atPos(x) to x.Pos() in argument lists of (check).dump calls. // TODO(gri) can we avoid this and just use atPos consistently in go/types and types2? func fixAtPosCall(f *ast.File) { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.CallExpr: if selx, _ := n.Fun.(*ast.SelectorExpr); selx != nil && selx.Sel.Name == "dump" { @@ -415,7 +415,7 @@ func fixAtPosCall(f *ast.File) { // fixErrErrorfCall updates calls of the form err.addf(obj, ...) to err.addf(obj.Pos(), ...). func fixErrErrorfCall(f *ast.File) { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.CallExpr: if selx, _ := n.Fun.(*ast.SelectorExpr); selx != nil { @@ -439,7 +439,7 @@ func fixErrErrorfCall(f *ast.File) { // fixCheckErrorfCall updates calls of the form check.errorf(pos, ...) to check.errorf(atPos(pos), ...). func fixCheckErrorfCall(f *ast.File) { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.CallExpr: if selx, _ := n.Fun.(*ast.SelectorExpr); selx != nil { @@ -465,7 +465,7 @@ func fixCheckErrorfCall(f *ast.File) { // (in types2 we use an array for efficiency, in go/types it's a slice and we // cannot change that). func fixGlobalTypVarDecl(f *ast.File) { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.ValueSpec: // rewrite type Typ = [...]Type{...} to type Typ = []Type{...} @@ -480,7 +480,7 @@ func fixGlobalTypVarDecl(f *ast.File) { // fixSprintf adds an extra nil argument for the *token.FileSet parameter in sprintf calls. func fixSprintf(f *ast.File) { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> switch n := n.(type) { case *ast.CallExpr: if isIdent(n.Fun, "sprintf") && len(n.Args) >= 4 /* ... args */{ diff --git a/src/go/types/gotype.go b/src/go/types/gotype.go index d45a6a8839ac5..4af90f6e5c5b8 100644 --- a/src/go/types/gotype.go +++ b/src/go/types/gotype.go @@ -320,7 +320,7 @@ func checkPkgFiles(files []*ast.File) { func printStats(d time.Duration) { fileCount := 0 lineCount := 0 - fset.Iterate(func { f | + fset.Iterate(func { f -> fileCount++ lineCount += f.LineCount() return true diff --git a/src/go/types/index.go b/src/go/types/index.go index 07da76c72205f..f124187ff8ca6 100644 --- a/src/go/types/index.go +++ b/src/go/types/index.go @@ -109,7 +109,7 @@ func (check *Checker) indexExpr(x *operand, e *typeparams.IndexExpr) (isFuncInst var key, elem Type // key != nil: we must have all maps mode := variable // non-maps result mode // TODO(gri) factor out closure and use it for non-typeparam cases as well - if typ.typeSet().underIs(func { u | + if typ.typeSet().underIs(func { u -> l := int64(-1) // valid if >= 0 var k, e Type // k is only set for maps switch t := u.(type) { diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 521d3bfb20546..065c72d5e83cb 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -282,7 +282,7 @@ func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type, // Eventually, unify should return an error with cause. var cause string constraint := tpar.iface() - if m, _ := check.missingMethod(tx, constraint, true, func { x, y | return u.unify(x, y, exact) }, &cause); m != nil { + if m, _ := check.missingMethod(tx, constraint, true, func { x, y -> return u.unify(x, y, exact) }, &cause); m != nil { // TODO(gri) better error message (see TODO above) err.addf(posn, "%s (type %s) does not satisfy %s %s", tpar, tx, tpar.Constraint(), cause) return nil @@ -603,7 +603,7 @@ func (w *tpWalker) isParameterized(typ Type) (res bool) { return true } } - return tset.is(func { t | return t != nil && w.isParameterized(t.typ) }) + return tset.is(func { t -> return t != nil && w.isParameterized(t.typ) }) case *Map: return w.isParameterized(t.key) || w.isParameterized(t.elem) @@ -645,7 +645,7 @@ func coreTerm(tpar *TypeParam) (*term, bool) { n := 0 var single *term // valid if n == 1 var tilde bool - tpar.is(func { t | + tpar.is(func { t -> if t == nil { assert(n == 0) return false // no terms diff --git a/src/go/types/initorder.go b/src/go/types/initorder.go index bab1d1738301e..03eedfaaced82 100644 --- a/src/go/types/initorder.go +++ b/src/go/types/initorder.go @@ -260,7 +260,7 @@ func dependencyGraph(objMap map[Object]*declInfo) []*graphNode { // throughout the function graph, the cost of removing a function at // position X is proportional to cost * (len(funcG)-X). Therefore, we should // remove high-cost functions last. - sort.Slice(funcG, func { i, j | return funcG[i].cost() < funcG[j].cost() }) + sort.Slice(funcG, func { i, j -> return funcG[i].cost() < funcG[j].cost() }) for _, n := range funcG { // connect each predecessor p of n with each successor s // and drop the function node (don't collect it in G) diff --git a/src/go/types/instantiate.go b/src/go/types/instantiate.go index a4f3a78f4ec54..bbca64fc4f792 100644 --- a/src/go/types/instantiate.go +++ b/src/go/types/instantiate.go @@ -334,7 +334,7 @@ func (check *Checker) implements(pos token.Pos, V, T Type, constraint bool, caus // Otherwise, V's type must be included in the iface type set. var alt Type - if Ti.typeSet().is(func { t | + if Ti.typeSet().is(func { t -> if !t.includes(V) { // If V ∉ t.typ but V ∈ ~t.typ then remember this type // so we can suggest it as an alternative in the error diff --git a/src/go/types/instantiate_test.go b/src/go/types/instantiate_test.go index 3b85f900b7c2b..54ec8212777e7 100644 --- a/src/go/types/instantiate_test.go +++ b/src/go/types/instantiate_test.go @@ -112,7 +112,7 @@ func TestInstantiateEquality(t *testing.T) { for _, test := range tests { pkg := mustTypecheck(test.src, nil, nil) - t.Run(pkg.Name(), func { t | + t.Run(pkg.Name(), func { t -> ctxt := NewContext() T1 := pkg.Scope().Lookup(test.name1).Type() diff --git a/src/go/types/issues_test.go b/src/go/types/issues_test.go index 3f556f6fdf6dc..9de255c74bbda 100644 --- a/src/go/types/issues_test.go +++ b/src/go/types/issues_test.go @@ -300,7 +300,7 @@ func TestIssue25627(t *testing.T) { } } - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> if spec, _ := n.(*ast.TypeSpec); spec != nil { if tv, ok := info.Types[spec.Type]; ok && spec.Name.Name == "T" { want := strings.Count(src, ";") + 1 @@ -904,7 +904,7 @@ func _cgoCheckPointer(interface{}, interface{}) //go:linkname _cgoCheckResult runtime.cgoCheckResult func _cgoCheckResult(interface{}) ` - testFiles(t, []string{"p.go", "_cgo_gotypes.go"}, [][]byte{[]byte(src), []byte(cgoTypes)}, false, func { cfg | *boolFieldAddr(cfg, "go115UsesCgo") = true }) + testFiles(t, []string{"p.go", "_cgo_gotypes.go"}, [][]byte{[]byte(src), []byte(cgoTypes)}, false, func { cfg -> *boolFieldAddr(cfg, "go115UsesCgo") = true }) } func TestIssue61931(t *testing.T) { diff --git a/src/go/types/labels.go b/src/go/types/labels.go index 9506d12afc2ef..f5e1f019465a8 100644 --- a/src/go/types/labels.go +++ b/src/go/types/labels.go @@ -126,7 +126,7 @@ func (check *Checker) blockBranches(all *Scope, parent *block, lstmt *ast.Labele } var stmtBranches func(ast.Stmt) - stmtBranches = func { s | + stmtBranches = func { s -> switch s := s.(type) { case *ast.DeclStmt: if d, _ := s.Decl.(*ast.GenDecl); d != nil && d.Tok == token.VAR { diff --git a/src/go/types/methodset.go b/src/go/types/methodset.go index cf7944406db57..905a973561a3a 100644 --- a/src/go/types/methodset.go +++ b/src/go/types/methodset.go @@ -46,7 +46,7 @@ func (s *MethodSet) Lookup(pkg *Package, name string) *Selection { } key := Id(pkg, name) - i := sort.Search(len(s.list), func { i | + i := sort.Search(len(s.list), func { i -> m := s.list[i] return m.obj.Id() >= key }) @@ -201,7 +201,7 @@ func NewMethodSet(T Type) *MethodSet { } } // sort by unique name - sort.Slice(list, func { i, j | return list[i].obj.Id() < list[j].obj.Id() }) + sort.Slice(list, func { i, j -> return list[i].obj.Id() < list[j].obj.Id() }) return &MethodSet{list} } diff --git a/src/go/types/mono.go b/src/go/types/mono.go index 5296b3b5e7af4..cfb3097b75fbf 100644 --- a/src/go/types/mono.go +++ b/src/go/types/mono.go @@ -210,7 +210,7 @@ func (w *monoGraph) assign(pkg *Package, pos token.Pos, tpar *TypeParam, targ Ty // Recursively walk the type argument to find any defined types or // type parameters. var do func(typ Type) - do = func { typ | + do = func { typ -> switch typ := Unalias(typ).(type) { default: panic("unexpected type") diff --git a/src/go/types/named_test.go b/src/go/types/named_test.go index 28e577e91da55..7b3ef8e2737f0 100644 --- a/src/go/types/named_test.go +++ b/src/go/types/named_test.go @@ -51,9 +51,9 @@ type Inst = G[int] {"user instance", UserInst}, } - b.Run("Underlying", func { b | + b.Run("Underlying", func { b -> for _, test := range tests { - b.Run(test.name, func { b | + b.Run(test.name, func { b -> // Access underlying once, to trigger any lazy calculation. _ = test.typ.Underlying() b.ResetTimer() @@ -64,9 +64,9 @@ type Inst = G[int] } }) - b.Run("NewMethodSet", func { b | + b.Run("NewMethodSet", func { b -> for _, test := range tests { - b.Run(test.name, func { b | + b.Run(test.name, func { b -> // Access underlying once, to trigger any lazy calculation. _ = NewMethodSet(test.typ) b.ResetTimer() diff --git a/src/go/types/object_test.go b/src/go/types/object_test.go index e7b0a6276c0b0..0f6bdbcf61b1d 100644 --- a/src/go/types/object_test.go +++ b/src/go/types/object_test.go @@ -112,7 +112,7 @@ func TestObjectString(t *testing.T) { testenv.MustHaveGoBuild(t) for i, test := range testObjects { - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> if test.alias { t.Setenv("GODEBUG", "gotypesalias=1") } diff --git a/src/go/types/operand.go b/src/go/types/operand.go index 6499ebdd32a28..c5e51cbe70807 100644 --- a/src/go/types/operand.go +++ b/src/go/types/operand.go @@ -284,7 +284,7 @@ func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Cod if Tp != nil { // T is a type parameter: x is assignable to T if it is // representable by each specific type in the type set of T. - return Tp.is(func { t | + return Tp.is(func { t -> if t == nil { return false } @@ -364,7 +364,7 @@ func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Cod if !hasName(V) && Tp != nil { ok := false code := IncompatibleAssign - Tp.is(func { T | + Tp.is(func { T -> if T == nil { return false // no specific types } @@ -385,7 +385,7 @@ func (x *operand) assignableTo(check *Checker, T Type, cause *string) (bool, Cod x := *x // don't clobber outer x ok := false code := IncompatibleAssign - Vp.is(func { V | + Vp.is(func { V -> if V == nil { return false // no specific types } diff --git a/src/go/types/predicates.go b/src/go/types/predicates.go index 0b74039ada7ea..feddf4c2a511b 100644 --- a/src/go/types/predicates.go +++ b/src/go/types/predicates.go @@ -54,7 +54,7 @@ func allNumericOrString(t Type) bool { return allBasic(t, IsNumeric|IsString) } // allBasic(t, info) is an optimized version of isBasic(coreType(t), info). func allBasic(t Type, info BasicInfo) bool { if tpar, _ := Unalias(t).(*TypeParam); tpar != nil { - return tpar.is(func { t | return t != nil && isBasic(t.typ, info) }) + return tpar.is(func { t -> return t != nil && isBasic(t.typ, info) }) } return isBasic(t, info) } @@ -212,7 +212,7 @@ func hasNil(t Type) bool { case *Slice, *Pointer, *Signature, *Map, *Chan: return true case *Interface: - return !isTypeParam(t) || u.typeSet().underIs(func { u | return u != nil && hasNil(u) }) + return !isTypeParam(t) || u.typeSet().underIs(func { u -> return u != nil && hasNil(u) }) } return false } diff --git a/src/go/types/resolver.go b/src/go/types/resolver.go index 72eed539f60b9..5c548e3b6c671 100644 --- a/src/go/types/resolver.go +++ b/src/go/types/resolver.go @@ -254,7 +254,7 @@ func (check *Checker) collectObjects() { // we get "." as the directory which is what we would want. fileDir := dir(check.fset.Position(file.Name.Pos()).Filename) - check.walkDecls(file.Decls, func { d | + check.walkDecls(file.Decls, func { d -> switch d := d.(type) { case importDecl: // import package diff --git a/src/go/types/resolver_test.go b/src/go/types/resolver_test.go index 5f9d61211e0d4..02da1e668880b 100644 --- a/src/go/types/resolver_test.go +++ b/src/go/types/resolver_test.go @@ -142,7 +142,7 @@ func TestResolveIdents(t *testing.T) { // check that qualified identifiers are resolved for _, f := range files { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> if s, ok := n.(*ast.SelectorExpr); ok { if x, ok := s.X.(*ast.Ident); ok { obj := uses[x] @@ -171,7 +171,7 @@ func TestResolveIdents(t *testing.T) { // check that each identifier in the source is found in uses or defs or both var both []string for _, f := range files { - ast.Inspect(f, func { n | + ast.Inspect(f, func { n -> if x, ok := n.(*ast.Ident); ok { var objects int if _, found := uses[x]; found { diff --git a/src/go/types/self_test.go b/src/go/types/self_test.go index 2d5b5bc3f11cb..b85e5eb601959 100644 --- a/src/go/types/self_test.go +++ b/src/go/types/self_test.go @@ -44,16 +44,16 @@ func BenchmarkCheck(b *testing.B) { "runtime", filepath.Join("go", "internal", "gcimporter"), } { - b.Run(path.Base(p), func { b | + b.Run(path.Base(p), func { b -> path := filepath.Join("..", "..", p) for _, ignoreFuncBodies := range []bool{false, true} { name := "funcbodies" if ignoreFuncBodies { name = "nofuncbodies" } - b.Run(name, func { b | - b.Run("info", func { b | runbench(b, path, ignoreFuncBodies, true) }) - b.Run("noinfo", func { b | runbench(b, path, ignoreFuncBodies, false) }) + b.Run(name, func { b -> + b.Run("info", func { b -> runbench(b, path, ignoreFuncBodies, true) }) + b.Run("noinfo", func { b -> runbench(b, path, ignoreFuncBodies, false) }) }) } }) @@ -68,7 +68,7 @@ func runbench(b *testing.B, path string, ignoreFuncBodies, writeInfo bool) { } // determine line count lines := 0 - fset.Iterate(func { f | + fset.Iterate(func { f -> lines += f.LineCount() return true }) diff --git a/src/go/types/signature.go b/src/go/types/signature.go index 820e8438bf585..70a3c7cb9be1d 100644 --- a/src/go/types/signature.go +++ b/src/go/types/signature.go @@ -192,7 +192,7 @@ func (check *Checker) funcType(sig *Signature, recvPar *ast.FieldList, ftyp *ast recvList, _ := check.collectParams(scope, recvPar, false, scopePos) params, variadic := check.collectParams(scope, ftyp.Params, true, scopePos) results, _ := check.collectParams(scope, ftyp.Results, false, scopePos) - scope.squash(func { obj, alt | + scope.squash(func { obj, alt -> err := check.newError(DuplicateDecl) err.addf(obj, "%s redeclared in this block", obj.Name()) err.addAltDecl(alt) diff --git a/src/go/types/sizes_test.go b/src/go/types/sizes_test.go index b518028b1b333..5e3d19e65764c 100644 --- a/src/go/types/sizes_test.go +++ b/src/go/types/sizes_test.go @@ -115,7 +115,7 @@ var s struct { want := []int64{0, 8, 16} for _, arch := range []string{"386", "amd64"} { - t.Run(arch, func { t | + t.Run(arch, func { t -> conf := types.Config{ Importer: importer.Default(), Sizes: types.SizesFor("gc", arch), @@ -186,7 +186,7 @@ func TestGCSizes(t *testing.T) { types.DefPredeclaredTestFuncs() for _, tc := range gcSizesTests { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() conf := types.Config{Importer: importer.Default(), Sizes: types.SizesFor("gc", "amd64")} mustTypecheck(tc.src, &conf, nil) diff --git a/src/go/types/stdlib_test.go b/src/go/types/stdlib_test.go index 5adb0205bdfe0..fe2e679f3f4c1 100644 --- a/src/go/types/stdlib_test.go +++ b/src/go/types/stdlib_test.go @@ -48,7 +48,7 @@ func TestStdlib(t *testing.T) { // Collect non-test files. dirFiles := make(map[string][]string) root := filepath.Join(testenv.GOROOT(t), "src") - walkPkgDirs(root, func { dir, filenames | dirFiles[dir] = filenames }, t.Error) + walkPkgDirs(root, func { dir, filenames -> dirFiles[dir] = filenames }, t.Error) c := &stdlibChecker{ dirFiles: dirFiles, diff --git a/src/go/types/stmt.go b/src/go/types/stmt.go index eb61902af99a9..0c9ab3b99d158 100644 --- a/src/go/types/stmt.go +++ b/src/go/types/stmt.go @@ -61,7 +61,7 @@ func (check *Checker) usage(scope *Scope) { unused = append(unused, v) } } - sort.Slice(unused, func { i, j | return cmpPos(unused[i].pos, unused[j].pos) < 0 }) + sort.Slice(unused, func { i, j -> return cmpPos(unused[i].pos, unused[j].pos) < 0 }) for _, v := range unused { check.softErrorf(v, UnusedVar, "declared and not used: %s", v.name) } @@ -861,7 +861,7 @@ func (check *Checker) rangeStmt(inner stmtContext, s *ast.RangeStmt) { var key, val Type if x.mode != invalid { // Ranging over a type parameter is permitted if it has a core type. - k, v, cause, ok := rangeKeyVal(x.typ, func { v | return check.allowVersion(x.expr, v) }) + k, v, cause, ok := rangeKeyVal(x.typ, func { v -> return check.allowVersion(x.expr, v) }) switch { case !ok && cause != "": check.softErrorf(&x, InvalidRangeExpr, "cannot range over %s: %s", &x, cause) diff --git a/src/go/types/typeset.go b/src/go/types/typeset.go index 398cad29a9536..5ae5c80a088a7 100644 --- a/src/go/types/typeset.go +++ b/src/go/types/typeset.go @@ -46,7 +46,7 @@ func (s *_TypeSet) IsComparable(seen map[Type]bool) bool { if s.terms.isAll() { return s.comparable } - return s.is(func { t | return t != nil && comparable(t.typ, false, seen, nil) }) + return s.is(func { t -> return t != nil && comparable(t.typ, false, seen, nil) }) } // NumMethods returns the number of methods available. diff --git a/src/go/types/under.go b/src/go/types/under.go index 628dba5ada184..71ae9cd34a56d 100644 --- a/src/go/types/under.go +++ b/src/go/types/under.go @@ -32,7 +32,7 @@ func coreType(t Type) Type { } var su Type - if tpar.underIs(func { u | + if tpar.underIs(func { u -> if u == nil { return false } @@ -63,7 +63,7 @@ func coreString(t Type) Type { var su Type hasString := false - if tpar.underIs(func { u | + if tpar.underIs(func { u -> if u == nil { return false } diff --git a/src/hash/crc32/crc32.go b/src/hash/crc32/crc32.go index b7fc2a0dbc546..645de239d6734 100644 --- a/src/hash/crc32/crc32.go +++ b/src/hash/crc32/crc32.go @@ -90,7 +90,7 @@ func castagnoliInit() { } else { // Initialize the slicing-by-8 table. castagnoliTable8 = slicingMakeTable(Castagnoli) - updateCastagnoli = func { crc, p | return slicingUpdate(crc, castagnoliTable8, p) } + updateCastagnoli = func { crc, p -> return slicingUpdate(crc, castagnoliTable8, p) } } haveCastagnoli.Store(true) @@ -111,7 +111,7 @@ func ieeeInit() { } else { // Initialize the slicing-by-8 table. ieeeTable8 = slicingMakeTable(IEEE) - updateIEEE = func { crc, p | return slicingUpdate(crc, ieeeTable8, p) } + updateIEEE = func { crc, p -> return slicingUpdate(crc, ieeeTable8, p) } } } diff --git a/src/hash/crc32/crc32_test.go b/src/hash/crc32/crc32_test.go index d0c60e7304b53..f700e673c9473 100644 --- a/src/hash/crc32/crc32_test.go +++ b/src/hash/crc32/crc32_test.go @@ -109,14 +109,14 @@ func testCrossCheck(t *testing.T, crcFunc1, crcFunc2 func(crc uint32, b []byte) // TestSimple tests the simple generic algorithm. func TestSimple(t *testing.T) { tab := simpleMakeTable(IEEE) - testGoldenIEEE(t, func { b | return simpleUpdate(0, tab, b) }) + testGoldenIEEE(t, func { b -> return simpleUpdate(0, tab, b) }) tab = simpleMakeTable(Castagnoli) - testGoldenCastagnoli(t, func { b | return simpleUpdate(0, tab, b) }) + testGoldenCastagnoli(t, func { b -> return simpleUpdate(0, tab, b) }) } func TestGoldenMarshal(t *testing.T) { - t.Run("IEEE", func { t | + t.Run("IEEE", func { t -> for _, g := range golden { h := New(IEEETable) h2 := New(IEEETable) @@ -147,7 +147,7 @@ func TestGoldenMarshal(t *testing.T) { } } }) - t.Run("Castagnoli", func { t | + t.Run("Castagnoli", func { t -> table := MakeTable(Castagnoli) for _, g := range golden { h := New(table) @@ -198,10 +198,10 @@ func TestMarshalTableMismatch(t *testing.T) { // TestSlicing tests the slicing-by-8 algorithm. func TestSlicing(t *testing.T) { tab := slicingMakeTable(IEEE) - testGoldenIEEE(t, func { b | return slicingUpdate(0, tab, b) }) + testGoldenIEEE(t, func { b -> return slicingUpdate(0, tab, b) }) tab = slicingMakeTable(Castagnoli) - testGoldenCastagnoli(t, func { b | return slicingUpdate(0, tab, b) }) + testGoldenCastagnoli(t, func { b -> return slicingUpdate(0, tab, b) }) // Cross-check various polys against the simple algorithm. for _, poly := range []uint32{IEEE, Castagnoli, Koopman, 0xD5828281} { @@ -223,7 +223,7 @@ func TestArchIEEE(t *testing.T) { } archInitIEEE() slicingTable := slicingMakeTable(IEEE) - testCrossCheck(t, archUpdateIEEE, func { crc, b | return slicingUpdate(crc, slicingTable, b) }) + testCrossCheck(t, archUpdateIEEE, func { crc, b -> return slicingUpdate(crc, slicingTable, b) }) } func TestArchCastagnoli(t *testing.T) { @@ -232,7 +232,7 @@ func TestArchCastagnoli(t *testing.T) { } archInitCastagnoli() slicingTable := slicingMakeTable(Castagnoli) - testCrossCheck(t, archUpdateCastagnoli, func { crc, b | return slicingUpdate(crc, slicingTable, b) }) + testCrossCheck(t, archUpdateCastagnoli, func { crc, b -> return slicingUpdate(crc, slicingTable, b) }) } func TestGolden(t *testing.T) { @@ -241,7 +241,7 @@ func TestGolden(t *testing.T) { // Some implementations have special code to deal with misaligned // data; test that as well. for delta := 1; delta <= 7; delta++ { - testGoldenIEEE(t, func { b | + testGoldenIEEE(t, func { b -> ieee := NewIEEE() d := delta if d >= len(b) { @@ -258,7 +258,7 @@ func TestGolden(t *testing.T) { t.Errorf("nil Castagnoli Table") } - testGoldenCastagnoli(t, func { b | + testGoldenCastagnoli(t, func { b -> castagnoli := New(castagnoliTab) castagnoli.Write(b) return castagnoli.Sum32() @@ -267,7 +267,7 @@ func TestGolden(t *testing.T) { // Some implementations have special code to deal with misaligned // data; test that as well. for delta := 1; delta <= 7; delta++ { - testGoldenCastagnoli(t, func { b | + testGoldenCastagnoli(t, func { b -> castagnoli := New(castagnoliTab) d := delta if d >= len(b) { @@ -293,9 +293,9 @@ func benchmarkAll(h hash.Hash32) func(b *testing.B) { if size >= 1024 { name = fmt.Sprintf("%dkB", size/1024) } - b.Run("size="+name, func { b | + b.Run("size="+name, func { b -> for align := 0; align <= 1; align++ { - b.Run(fmt.Sprintf("align=%d", align), func { b | benchmark(b, h, int64(size), int64(align)) }) + b.Run(fmt.Sprintf("align=%d", align), func { b -> benchmark(b, h, int64(size), int64(align)) }) } }) } diff --git a/src/hash/crc64/crc64_test.go b/src/hash/crc64/crc64_test.go index 416a6bb349e60..df22274bd046b 100644 --- a/src/hash/crc64/crc64_test.go +++ b/src/hash/crc64/crc64_test.go @@ -74,7 +74,7 @@ func TestGolden(t *testing.T) { } func TestGoldenMarshal(t *testing.T) { - t.Run("ISO", func { t | + t.Run("ISO", func { t -> table := MakeTable(ISO) for _, g := range golden { h := New(table) @@ -106,7 +106,7 @@ func TestGoldenMarshal(t *testing.T) { } } }) - t.Run("ECMA", func { t | + t.Run("ECMA", func { t -> table := MakeTable(ECMA) for _, g := range golden { h := New(table) @@ -172,10 +172,10 @@ func bench(b *testing.B, poly uint64, size int64) { } func BenchmarkCrc64(b *testing.B) { - b.Run("ISO64KB", func { b | bench(b, ISO, 64<<10) }) - b.Run("ISO4KB", func { b | bench(b, ISO, 4<<10) }) - b.Run("ISO1KB", func { b | bench(b, ISO, 1<<10) }) - b.Run("ECMA64KB", func { b | bench(b, ECMA, 64<<10) }) - b.Run("Random64KB", func { b | bench(b, 0x777, 64<<10) }) - b.Run("Random16KB", func { b | bench(b, 0x777, 16<<10) }) + b.Run("ISO64KB", func { b -> bench(b, ISO, 64<<10) }) + b.Run("ISO4KB", func { b -> bench(b, ISO, 4<<10) }) + b.Run("ISO1KB", func { b -> bench(b, ISO, 1<<10) }) + b.Run("ECMA64KB", func { b -> bench(b, ECMA, 64<<10) }) + b.Run("Random64KB", func { b -> bench(b, 0x777, 64<<10) }) + b.Run("Random16KB", func { b -> bench(b, 0x777, 16<<10) }) } diff --git a/src/hash/fnv/fnv_test.go b/src/hash/fnv/fnv_test.go index 6a6a3a5cc39cc..e21cf9eeeb96e 100644 --- a/src/hash/fnv/fnv_test.go +++ b/src/hash/fnv/fnv_test.go @@ -115,7 +115,7 @@ func TestGoldenMarshal(t *testing.T) { {"128a", func() hash.Hash { return New128a() }, golden128a}, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> for _, g := range tt.gold { h := tt.newHash() h2 := tt.newHash() diff --git a/src/hash/maphash/maphash_test.go b/src/hash/maphash/maphash_test.go index 508b4ef54e270..cb5af3683520c 100644 --- a/src/hash/maphash/maphash_test.go +++ b/src/hash/maphash/maphash_test.go @@ -219,7 +219,7 @@ func benchmarkSize(b *testing.B, size int) { buf := make([]byte, size) s := string(buf) - b.Run("Write", func { b | + b.Run("Write", func { b -> b.SetBytes(int64(size)) for i := 0; i < b.N; i++ { h.Reset() @@ -228,7 +228,7 @@ func benchmarkSize(b *testing.B, size int) { } }) - b.Run("Bytes", func { b | + b.Run("Bytes", func { b -> b.SetBytes(int64(size)) seed := h.Seed() for i := 0; i < b.N; i++ { @@ -236,7 +236,7 @@ func benchmarkSize(b *testing.B, size int) { } }) - b.Run("String", func { b | + b.Run("String", func { b -> b.SetBytes(int64(size)) seed := h.Seed() for i := 0; i < b.N; i++ { @@ -248,6 +248,6 @@ func benchmarkSize(b *testing.B, size int) { func BenchmarkHash(b *testing.B) { sizes := []int{4, 8, 16, 32, 64, 256, 320, 1024, 4096, 16384} for _, size := range sizes { - b.Run(fmt.Sprint("n=", size), func { b | benchmarkSize(b, size) }) + b.Run(fmt.Sprint("n=", size), func { b -> benchmarkSize(b, size) }) } } diff --git a/src/hash/marshal_test.go b/src/hash/marshal_test.go index d329671780e97..93dfde78b7365 100644 --- a/src/hash/marshal_test.go +++ b/src/hash/marshal_test.go @@ -58,7 +58,7 @@ var marshalTests = []struct { func TestMarshalHash(t *testing.T) { for _, tt := range marshalTests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> buf := make([]byte, 256) for i := range buf { buf[i] = byte(i) diff --git a/src/html/fuzz_test.go b/src/html/fuzz_test.go index bf16acef29e7c..f0631359c1fa6 100644 --- a/src/html/fuzz_test.go +++ b/src/html/fuzz_test.go @@ -7,7 +7,7 @@ package html import "testing" func FuzzEscapeUnescape(f *testing.F) { - f.Fuzz(func { t, v | + f.Fuzz(func { t, v -> e := EscapeString(v) u := UnescapeString(e) if u != v { diff --git a/src/html/template/escape_test.go b/src/html/template/escape_test.go index a37fbb53fbc5a..05757990076da 100644 --- a/src/html/template/escape_test.go +++ b/src/html/template/escape_test.go @@ -737,7 +737,7 @@ func TestEscape(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> tmpl := New(test.name) tmpl = Must(tmpl.Parse(test.input)) // Check for bug 6459: Tree field was not set in Parse. diff --git a/src/html/template/exec_test.go b/src/html/template/exec_test.go index 8705a62364974..0f931bf1ff6c9 100644 --- a/src/html/template/exec_test.go +++ b/src/html/template/exec_test.go @@ -1490,7 +1490,7 @@ func TestEvalFieldErrors(t *testing.T) { }, } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> tmpl := Must(New("tmpl").Parse(tc.src)) err := tmpl.Execute(io.Discard, tc.value) got := "" diff --git a/src/html/template/template_test.go b/src/html/template/template_test.go index 3dfef3cd33da7..feea918df8ba0 100644 --- a/src/html/template/template_test.go +++ b/src/html/template/template_test.go @@ -144,7 +144,7 @@ func TestStringsInScriptsWithJsonContentTypeAreCorrectlyEscaped(t *testing.T) { ) tpl := Must(New("JS string is JSON string").Parse(templ)) for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> var buf bytes.Buffer if err := tpl.Execute(&buf, tt.in); err != nil { t.Fatalf("Cannot render template: %v", err) diff --git a/src/image/color/ycbcr_test.go b/src/image/color/ycbcr_test.go index 33e9c1bcaed4a..6e0d3b6df9580 100644 --- a/src/image/color/ycbcr_test.go +++ b/src/image/color/ycbcr_test.go @@ -179,13 +179,13 @@ func BenchmarkYCbCrToRGB(b *testing.B) { // YCbCrToRGB does saturating arithmetic. // Low, middle, and high values can take // different paths through the generated code. - b.Run("0", func { b | for i := 0; i < b.N; i++ { + b.Run("0", func { b -> for i := 0; i < b.N; i++ { sink8, sink8, sink8 = YCbCrToRGB(0, 0, 0) } }) - b.Run("128", func { b | for i := 0; i < b.N; i++ { + b.Run("128", func { b -> for i := 0; i < b.N; i++ { sink8, sink8, sink8 = YCbCrToRGB(128, 128, 128) } }) - b.Run("255", func { b | for i := 0; i < b.N; i++ { + b.Run("255", func { b -> for i := 0; i < b.N; i++ { sink8, sink8, sink8 = YCbCrToRGB(255, 255, 255) } }) } @@ -194,13 +194,13 @@ func BenchmarkRGBToYCbCr(b *testing.B) { // RGBToYCbCr does saturating arithmetic. // Different values can take different paths // through the generated code. - b.Run("0", func { b | for i := 0; i < b.N; i++ { + b.Run("0", func { b -> for i := 0; i < b.N; i++ { sink8, sink8, sink8 = RGBToYCbCr(0, 0, 0) } }) - b.Run("Cb", func { b | for i := 0; i < b.N; i++ { + b.Run("Cb", func { b -> for i := 0; i < b.N; i++ { sink8, sink8, sink8 = RGBToYCbCr(0, 0, 255) } }) - b.Run("Cr", func { b | for i := 0; i < b.N; i++ { + b.Run("Cr", func { b -> for i := 0; i < b.N; i++ { sink8, sink8, sink8 = RGBToYCbCr(255, 0, 0) } }) } @@ -209,19 +209,19 @@ func BenchmarkYCbCrToRGBA(b *testing.B) { // RGB does saturating arithmetic. // Low, middle, and high values can take // different paths through the generated code. - b.Run("0", func { b | + b.Run("0", func { b -> c := YCbCr{0, 0, 0} for i := 0; i < b.N; i++ { sink32, sink32, sink32, sink32 = c.RGBA() } }) - b.Run("128", func { b | + b.Run("128", func { b -> c := YCbCr{128, 128, 128} for i := 0; i < b.N; i++ { sink32, sink32, sink32, sink32 = c.RGBA() } }) - b.Run("255", func { b | + b.Run("255", func { b -> c := YCbCr{255, 255, 255} for i := 0; i < b.N; i++ { sink32, sink32, sink32, sink32 = c.RGBA() @@ -233,19 +233,19 @@ func BenchmarkNYCbCrAToRGBA(b *testing.B) { // RGBA does saturating arithmetic. // Low, middle, and high values can take // different paths through the generated code. - b.Run("0", func { b | + b.Run("0", func { b -> c := NYCbCrA{YCbCr{0, 0, 0}, 0xff} for i := 0; i < b.N; i++ { sink32, sink32, sink32, sink32 = c.RGBA() } }) - b.Run("128", func { b | + b.Run("128", func { b -> c := NYCbCrA{YCbCr{128, 128, 128}, 0xff} for i := 0; i < b.N; i++ { sink32, sink32, sink32, sink32 = c.RGBA() } }) - b.Run("255", func { b | + b.Run("255", func { b -> c := NYCbCrA{YCbCr{255, 255, 255}, 0xff} for i := 0; i < b.N; i++ { sink32, sink32, sink32, sink32 = c.RGBA() diff --git a/src/image/gif/fuzz_test.go b/src/image/gif/fuzz_test.go index b0ae2988c9f13..fb1c884f79b3e 100644 --- a/src/image/gif/fuzz_test.go +++ b/src/image/gif/fuzz_test.go @@ -33,7 +33,7 @@ func FuzzDecode(f *testing.F) { f.Add(b) } - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> cfg, _, err := image.DecodeConfig(bytes.NewReader(b)) if err != nil { return diff --git a/src/image/gif/reader_test.go b/src/image/gif/reader_test.go index df677a3e51dcb..e4a1e74f63215 100644 --- a/src/image/gif/reader_test.go +++ b/src/image/gif/reader_test.go @@ -354,7 +354,7 @@ func TestLoopCount(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> img, err := DecodeAll(bytes.NewReader(tc.data)) if err != nil { t.Fatal("DecodeAll:", err) diff --git a/src/image/image_test.go b/src/image/image_test.go index 7df27140769b9..198f037ca4275 100644 --- a/src/image/image_test.go +++ b/src/image/image_test.go @@ -280,7 +280,7 @@ func TestRGBA64Image(t *testing.T) { func BenchmarkAt(b *testing.B) { for _, tc := range testImages { - b.Run(tc.name, func { b | + b.Run(tc.name, func { b -> m := tc.image() b.ReportAllocs() b.ResetTimer() @@ -294,7 +294,7 @@ func BenchmarkAt(b *testing.B) { func BenchmarkSet(b *testing.B) { c := color.Gray{0xff} for _, tc := range testImages { - b.Run(tc.name, func { b | + b.Run(tc.name, func { b -> m := tc.image() b.ReportAllocs() b.ResetTimer() diff --git a/src/image/jpeg/fuzz_test.go b/src/image/jpeg/fuzz_test.go index a4787a91ce970..2926f115e8ad0 100644 --- a/src/image/jpeg/fuzz_test.go +++ b/src/image/jpeg/fuzz_test.go @@ -33,7 +33,7 @@ func FuzzDecode(f *testing.F) { f.Add(b) } - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> cfg, _, err := image.DecodeConfig(bytes.NewReader(b)) if err != nil { return diff --git a/src/image/png/fuzz_test.go b/src/image/png/fuzz_test.go index 14e018fb28e98..c25dc89b35c62 100644 --- a/src/image/png/fuzz_test.go +++ b/src/image/png/fuzz_test.go @@ -33,7 +33,7 @@ func FuzzDecode(f *testing.F) { f.Add(b) } - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> cfg, _, err := image.DecodeConfig(bytes.NewReader(b)) if err != nil { return diff --git a/src/image/png/writer_test.go b/src/image/png/writer_test.go index e1a8e7bac448a..111fb00c85066 100644 --- a/src/image/png/writer_test.go +++ b/src/image/png/writer_test.go @@ -128,7 +128,7 @@ func TestWriterPaletted(t *testing.T) { } for _, tc := range testCases { - t.Run(fmt.Sprintf("plen-%d", tc.plen), func { t | + t.Run(fmt.Sprintf("plen-%d", tc.plen), func { t -> // Create a paletted image with the correct palette length palette := make(color.Palette, tc.plen) for i := range palette { @@ -264,7 +264,7 @@ func TestWriteRGBA(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> m0 := tc.img m1, err := encodeDecode(m0) if err != nil { diff --git a/src/index/suffixarray/suffixarray.go b/src/index/suffixarray/suffixarray.go index f325ab7b7b2f8..7f5f440f3963b 100644 --- a/src/index/suffixarray/suffixarray.go +++ b/src/index/suffixarray/suffixarray.go @@ -243,9 +243,9 @@ func (x *Index) at(i int) []byte { func (x *Index) lookupAll(s []byte) ints { // find matching suffix index range [i:j] // find the first index where s would be the prefix - i := sort.Search(x.sa.len(), func { i | return bytes.Compare(x.at(i), s) >= 0 }) + i := sort.Search(x.sa.len(), func { i -> return bytes.Compare(x.at(i), s) >= 0 }) // starting at i, find the first index at which s is not a prefix - j := i + sort.Search(x.sa.len()-i, func { j | return !bytes.HasPrefix(x.at(j+i), s) }) + j := i + sort.Search(x.sa.len()-i, func { j -> return !bytes.HasPrefix(x.at(j+i), s) }) return x.sa.slice(i, j) } diff --git a/src/index/suffixarray/suffixarray_test.go b/src/index/suffixarray/suffixarray_test.go index 9de6f2b3150e0..97c5182d7284f 100644 --- a/src/index/suffixarray/suffixarray_test.go +++ b/src/index/suffixarray/suffixarray_test.go @@ -316,7 +316,7 @@ func TestIndex64(t *testing.T) { } func TestNew32(t *testing.T) { - test(t, func { x | + test(t, func { x -> sa := make([]int32, len(x)) text_32(x, sa) out := make([]int, len(sa)) @@ -328,7 +328,7 @@ func TestNew32(t *testing.T) { } func TestNew64(t *testing.T) { - test(t, func { x | + test(t, func { x -> sa := make([]int64, len(x)) text_64(x, sa) out := make([]int, len(sa)) @@ -342,7 +342,7 @@ func TestNew64(t *testing.T) { // test tests an arbitrary suffix array construction function. // Generates many inputs, builds and checks suffix arrays. func test(t *testing.T, build func([]byte) []int) { - t.Run("ababab...", func { t | + t.Run("ababab...", func { t -> // Very repetitive input has numLMS = len(x)/2-1 // at top level, the largest it can be. // But maxID is only two (aba and ab$). @@ -357,7 +357,7 @@ func test(t *testing.T, build func([]byte) []int) { testSA(t, x, build) }) - t.Run("forcealloc", func { t | + t.Run("forcealloc", func { t -> // Construct a pathological input that forces // recurse_32 to allocate a new temporary buffer. // The input must have more than N/3 LMS-substrings, @@ -391,7 +391,7 @@ func test(t *testing.T, build func([]byte) []int) { testSA(t, x, build) }) - t.Run("exhaustive2", func { t | + t.Run("exhaustive2", func { t -> // All inputs over {0,1} up to length 21. // Runs in about 10 seconds on my laptop. x := make([]byte, 30) @@ -405,7 +405,7 @@ func test(t *testing.T, build func([]byte) []int) { } }) - t.Run("exhaustive3", func { t | + t.Run("exhaustive3", func { t -> // All inputs over {0,1,2} up to length 14. // Runs in about 10 seconds on my laptop. x := make([]byte, 30) @@ -504,7 +504,7 @@ func makeText(name string) ([]byte, error) { return nil, err } case "go": - err := filepath.WalkDir("../..", func { path, info, err | + err := filepath.WalkDir("../..", func { path, info, err -> if err == nil && strings.HasSuffix(path, ".go") && !info.IsDir() { file, err := os.ReadFile(path) if err != nil { @@ -541,7 +541,7 @@ func setBits(bits int) (cleanup func()) { func BenchmarkNew(b *testing.B) { for _, text := range []string{"opticks", "go", "zero", "rand"} { - b.Run("text="+text, func { b | + b.Run("text="+text, func { b -> data, err := makeText(text) if err != nil { b.Fatal(err) @@ -558,12 +558,12 @@ func BenchmarkNew(b *testing.B) { if size >= 1e6 { name = fmt.Sprintf("%dM", size/1e6) } - b.Run("size="+name, func { b | + b.Run("size="+name, func { b -> for _, bits := range []int{32, 64} { if ^uint(0) == 0xffffffff && bits == 64 { continue } - b.Run(fmt.Sprintf("bits=%d", bits), func { b | + b.Run(fmt.Sprintf("bits=%d", bits), func { b -> cleanup := setBits(bits) defer cleanup() @@ -590,7 +590,7 @@ func BenchmarkSaveRestore(b *testing.B) { if ^uint(0) == 0xffffffff && bits == 64 { continue } - b.Run(fmt.Sprintf("bits=%d", bits), func { b | + b.Run(fmt.Sprintf("bits=%d", bits), func { b -> cleanup := setBits(bits) defer cleanup() diff --git a/src/internal/buildcfg/cfg.go b/src/internal/buildcfg/cfg.go index 8a69399d16a9c..a9ec0e300633a 100644 --- a/src/internal/buildcfg/cfg.go +++ b/src/internal/buildcfg/cfg.go @@ -268,7 +268,7 @@ func goriscv64() int { } Error = fmt.Errorf("invalid GORISCV64: must be rva20u64, rva22u64") v := defaultGORISCV64[len("rva"):] - i := strings.IndexFunc(v, func { r | return r < '0' || r > '9' }) + i := strings.IndexFunc(v, func { r -> return r < '0' || r > '9' }) year, _ := strconv.Atoi(v[:i]) return year } diff --git a/src/internal/buildcfg/exp.go b/src/internal/buildcfg/exp.go index fe05cf40bb5c9..c67ddf60ec485 100644 --- a/src/internal/buildcfg/exp.go +++ b/src/internal/buildcfg/exp.go @@ -96,7 +96,7 @@ func ParseGOEXPERIMENT(goos, goarch, goexp string) (*ExperimentFlags, error) { // subexperiments, and not an experiment itself. Doing // this as an alias make both "regabi" and "noregabi" // do the right thing. - names["regabi"] = func { v | + names["regabi"] = func { v -> flags.RegabiWrappers = v flags.RegabiArgs = v } diff --git a/src/internal/concurrent/hashtriemap_bench_test.go b/src/internal/concurrent/hashtriemap_bench_test.go index 10701066cab01..b9c3ae8762248 100644 --- a/src/internal/concurrent/hashtriemap_bench_test.go +++ b/src/internal/concurrent/hashtriemap_bench_test.go @@ -25,7 +25,7 @@ func benchmarkHashTrieMapLoad(b *testing.B, data []string) { m.LoadOrStore(data[i], i) } b.ResetTimer() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := 0 for pb.Next() { _, _ = m.Load(data[i]) @@ -49,7 +49,7 @@ func benchmarkHashTrieMapLoadOrStore(b *testing.B, data []string) { b.ReportAllocs() m := NewHashTrieMap[string, int]() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := 0 for pb.Next() { _, _ = m.LoadOrStore(data[i], i) diff --git a/src/internal/concurrent/hashtriemap_test.go b/src/internal/concurrent/hashtriemap_test.go index 43cc810288451..281830212f1db 100644 --- a/src/internal/concurrent/hashtriemap_test.go +++ b/src/internal/concurrent/hashtriemap_test.go @@ -24,20 +24,20 @@ func TestHashTrieMapBadHash(t *testing.T) { // Stub out the good hash function with a terrible one. // Everything should still work as expected. m := NewHashTrieMap[string, int]() - m.keyHash = func { _, _ | return 0 } + m.keyHash = func { _, _ -> return 0 } return m }) } func testHashTrieMap(t *testing.T, newMap func() *HashTrieMap[string, int]) { - t.Run("LoadEmpty", func { t | + t.Run("LoadEmpty", func { t -> m := newMap() for _, s := range testData { expectMissing(t, s, 0)(m.Load(s)) } }) - t.Run("LoadOrStore", func { t | + t.Run("LoadOrStore", func { t -> m := newMap() for i, s := range testData { @@ -51,7 +51,7 @@ func testHashTrieMap(t *testing.T, newMap func() *HashTrieMap[string, int]) { expectLoaded(t, s, i)(m.LoadOrStore(s, 0)) } }) - t.Run("CompareAndDeleteAll", func { t | + t.Run("CompareAndDeleteAll", func { t -> m := newMap() for range 3 { @@ -73,7 +73,7 @@ func testHashTrieMap(t *testing.T, newMap func() *HashTrieMap[string, int]) { } } }) - t.Run("CompareAndDeleteOne", func { t | + t.Run("CompareAndDeleteOne", func { t -> m := newMap() for i, s := range testData { @@ -93,7 +93,7 @@ func testHashTrieMap(t *testing.T, newMap func() *HashTrieMap[string, int]) { } } }) - t.Run("DeleteMultiple", func { t | + t.Run("DeleteMultiple", func { t -> m := newMap() for i, s := range testData { @@ -115,15 +115,15 @@ func testHashTrieMap(t *testing.T, newMap func() *HashTrieMap[string, int]) { } } }) - t.Run("All", func { t | + t.Run("All", func { t -> m := newMap() - testAll(t, m, testDataMap(testData[:]), func { _, _ | return true }) + testAll(t, m, testDataMap(testData[:]), func { _, _ -> return true }) }) - t.Run("AllDelete", func { t | + t.Run("AllDelete", func { t -> m := newMap() - testAll(t, m, testDataMap(testData[:]), func { s, i | + testAll(t, m, testDataMap(testData[:]), func { s, i -> expectDeleted(t, s, i)(m.CompareAndDelete(s, i)) return true }) @@ -131,7 +131,7 @@ func testHashTrieMap(t *testing.T, newMap func() *HashTrieMap[string, int]) { expectMissing(t, s, 0)(m.Load(s)) } }) - t.Run("ConcurrentLifecycleUnsharedKeys", func { t | + t.Run("ConcurrentLifecycleUnsharedKeys", func { t -> m := newMap() gmp := runtime.GOMAXPROCS(-1) @@ -165,7 +165,7 @@ func testHashTrieMap(t *testing.T, newMap func() *HashTrieMap[string, int]) { } wg.Wait() }) - t.Run("ConcurrentDeleteSharedKeys", func { t | + t.Run("ConcurrentDeleteSharedKeys", func { t -> m := newMap() // Load up the map. @@ -199,7 +199,7 @@ func testAll[K, V comparable](t *testing.T, m *HashTrieMap[K, V], testData map[K expectStored(t, k, v)(m.LoadOrStore(k, v)) } visited := make(map[K]int) - m.All()(func { key, got | + m.All()(func { key, got -> want, ok := testData[key] if !ok { t.Errorf("unexpected key %v in map", key) diff --git a/src/internal/coverage/cfile/emitdata_test.go b/src/internal/coverage/cfile/emitdata_test.go index 21abf6a9e1024..bafa8709b105a 100644 --- a/src/internal/coverage/cfile/emitdata_test.go +++ b/src/internal/coverage/cfile/emitdata_test.go @@ -54,39 +54,39 @@ func TestCoverageApis(t *testing.T) { // Sub-tests for each API we want to inspect, plus // extras for error testing. - t.Run("emitToDir", func { t | + t.Run("emitToDir", func { t -> t.Parallel() testEmitToDir(t, atomicHarnessPath, dir) }) - t.Run("emitToWriter", func { t | + t.Run("emitToWriter", func { t -> t.Parallel() testEmitToWriter(t, atomicHarnessPath, dir) }) - t.Run("emitToNonexistentDir", func { t | + t.Run("emitToNonexistentDir", func { t -> t.Parallel() testEmitToNonexistentDir(t, atomicHarnessPath, dir) }) - t.Run("emitToNilWriter", func { t | + t.Run("emitToNilWriter", func { t -> t.Parallel() testEmitToNilWriter(t, atomicHarnessPath, dir) }) - t.Run("emitToFailingWriter", func { t | + t.Run("emitToFailingWriter", func { t -> t.Parallel() testEmitToFailingWriter(t, atomicHarnessPath, dir) }) - t.Run("emitWithCounterClear", func { t | + t.Run("emitWithCounterClear", func { t -> t.Parallel() testEmitWithCounterClear(t, atomicHarnessPath, dir) }) - t.Run("emitToDirNonAtomic", func { t | + t.Run("emitToDirNonAtomic", func { t -> t.Parallel() testEmitToDirNonAtomic(t, nonAtomicHarnessPath, nonAtomicMode, dir) }) - t.Run("emitToWriterNonAtomic", func { t | + t.Run("emitToWriterNonAtomic", func { t -> t.Parallel() testEmitToWriterNonAtomic(t, nonAtomicHarnessPath, nonAtomicMode, dir) }) - t.Run("emitWithCounterClearNonAtomic", func { t | + t.Run("emitWithCounterClearNonAtomic", func { t -> t.Parallel() testEmitWithCounterClearNonAtomic(t, nonAtomicHarnessPath, nonAtomicMode, dir) }) @@ -223,7 +223,7 @@ func mktestdirs(t *testing.T, tag, tp, dir string) (string, string) { } func testEmitToDir(t *testing.T, harnessPath string, dir string) { - withAndWithoutRunner(func { setGoCoverDir, tag | + withAndWithoutRunner(func { setGoCoverDir, tag -> tp := "emitToDir" rdir, edir := mktestdirs(t, tag, tp, dir) output, err := runHarness(t, harnessPath, tp, @@ -266,7 +266,7 @@ func testEmitToDir(t *testing.T, harnessPath string, dir string) { } func testEmitToWriter(t *testing.T, harnessPath string, dir string) { - withAndWithoutRunner(func { setGoCoverDir, tag | + withAndWithoutRunner(func { setGoCoverDir, tag -> tp := "emitToWriter" rdir, edir := mktestdirs(t, tag, tp, dir) output, err := runHarness(t, harnessPath, tp, setGoCoverDir, rdir, edir) @@ -285,7 +285,7 @@ func testEmitToWriter(t *testing.T, harnessPath string, dir string) { } func testEmitToNonexistentDir(t *testing.T, harnessPath string, dir string) { - withAndWithoutRunner(func { setGoCoverDir, tag | + withAndWithoutRunner(func { setGoCoverDir, tag -> tp := "emitToNonexistentDir" rdir, edir := mktestdirs(t, tag, tp, dir) output, err := runHarness(t, harnessPath, tp, setGoCoverDir, rdir, edir) @@ -299,7 +299,7 @@ func testEmitToNonexistentDir(t *testing.T, harnessPath string, dir string) { } func testEmitToUnwritableDir(t *testing.T, harnessPath string, dir string) { - withAndWithoutRunner(func { setGoCoverDir, tag | + withAndWithoutRunner(func { setGoCoverDir, tag -> tp := "emitToUnwritableDir" rdir, edir := mktestdirs(t, tag, tp, dir) @@ -321,7 +321,7 @@ func testEmitToUnwritableDir(t *testing.T, harnessPath string, dir string) { } func testEmitToNilWriter(t *testing.T, harnessPath string, dir string) { - withAndWithoutRunner(func { setGoCoverDir, tag | + withAndWithoutRunner(func { setGoCoverDir, tag -> tp := "emitToNilWriter" rdir, edir := mktestdirs(t, tag, tp, dir) output, err := runHarness(t, harnessPath, tp, setGoCoverDir, rdir, edir) @@ -335,7 +335,7 @@ func testEmitToNilWriter(t *testing.T, harnessPath string, dir string) { } func testEmitToFailingWriter(t *testing.T, harnessPath string, dir string) { - withAndWithoutRunner(func { setGoCoverDir, tag | + withAndWithoutRunner(func { setGoCoverDir, tag -> tp := "emitToFailingWriter" rdir, edir := mktestdirs(t, tag, tp, dir) output, err := runHarness(t, harnessPath, tp, setGoCoverDir, rdir, edir) @@ -349,7 +349,7 @@ func testEmitToFailingWriter(t *testing.T, harnessPath string, dir string) { } func testEmitWithCounterClear(t *testing.T, harnessPath string, dir string) { - withAndWithoutRunner(func { setGoCoverDir, tag | + withAndWithoutRunner(func { setGoCoverDir, tag -> tp := "emitWithCounterClear" rdir, edir := mktestdirs(t, tag, tp, dir) output, err := runHarness(t, harnessPath, tp, diff --git a/src/internal/coverage/cformat/format.go b/src/internal/coverage/cformat/format.go index aa6ab295e6f8a..88584fbbbbb64 100644 --- a/src/internal/coverage/cformat/format.go +++ b/src/internal/coverage/cformat/format.go @@ -138,7 +138,7 @@ func (fm *Formatter) AddUnit(file string, fname string, isfnlit bool, unit cover // include function name as part of the sorting criteria, the thinking // being that is better to provide things in the original source order. func (p *pstate) sortUnits(units []extcu) { - slices.SortFunc(units, func { ui, uj | + slices.SortFunc(units, func { ui, uj -> ifile := p.funcs[ui.fnfid].file jfile := p.funcs[uj.fnfid].file if r := strings.Compare(ifile, jfile); r != 0 { diff --git a/src/internal/coverage/pods/pods.go b/src/internal/coverage/pods/pods.go index a274284b3e282..cabcd43a1e35c 100644 --- a/src/internal/coverage/pods/pods.go +++ b/src/internal/coverage/pods/pods.go @@ -167,7 +167,7 @@ func collectPodsImpl(files []string, dirIndices []int, warn bool) []Pod { } pods := make([]Pod, 0, len(mm)) for _, p := range mm { - slices.SortFunc(p.elements, func { a, b | + slices.SortFunc(p.elements, func { a, b -> if r := cmp.Compare(a.origin, b.origin); r != 0 { return r } @@ -186,7 +186,7 @@ func collectPodsImpl(files []string, dirIndices []int, warn bool) []Pod { } pods = append(pods, pod) } - slices.SortFunc(pods, func { a, b | return strings.Compare(a.MetaFile, b.MetaFile) }) + slices.SortFunc(pods, func { a, b -> return strings.Compare(a.MetaFile, b.MetaFile) }) return pods } diff --git a/src/internal/dag/alg.go b/src/internal/dag/alg.go index 07f3a43e92eaa..3ad7ab96103ce 100644 --- a/src/internal/dag/alg.go +++ b/src/internal/dag/alg.go @@ -26,7 +26,7 @@ func (g *Graph) Topo() []string { marks := make(map[string]bool) var visit func(n string) - visit = func { n | + visit = func { n -> if marks[n] { return } diff --git a/src/internal/dag/alg_test.go b/src/internal/dag/alg_test.go index 22c59815f1eb6..d5e9e6c2458a9 100644 --- a/src/internal/dag/alg_test.go +++ b/src/internal/dag/alg_test.go @@ -32,12 +32,12 @@ func TestTopo(t *testing.T) { } func TestTransitiveReduction(t *testing.T) { - t.Run("diamond", func { t | + t.Run("diamond", func { t -> g := mustParse(t, diamond) g.TransitiveReduction() wantEdges(t, g, "b->a c->a d->b d->c") }) - t.Run("chain", func { t | + t.Run("chain", func { t -> const chain = `NONE < a < b < c < d; a, d < e;` g := mustParse(t, chain) g.TransitiveReduction() diff --git a/src/internal/dag/parse.go b/src/internal/dag/parse.go index 09fb9560150ff..eb7650d60dc94 100644 --- a/src/internal/dag/parse.go +++ b/src/internal/dag/parse.go @@ -85,7 +85,7 @@ func (g *Graph) Edges(from string) []string { for k := range g.edges[from] { edges = append(edges, k) } - slices.SortFunc(edges, func { a, b | return cmp.Compare(g.byLabel[a], g.byLabel[b]) }) + slices.SortFunc(edges, func { a, b -> return cmp.Compare(g.byLabel[a], g.byLabel[b]) }) return edges } diff --git a/src/internal/diff/diff.go b/src/internal/diff/diff.go index 114f409753dd8..67bc0f4e7ce7a 100644 --- a/src/internal/diff/diff.go +++ b/src/internal/diff/diff.go @@ -235,7 +235,7 @@ func tgs(x, y []string) []pair { T[i] = n + 1 } for i := 0; i < n; i++ { - k := sort.Search(n, func { k | return T[k] >= J[i] }) + k := sort.Search(n, func { k -> return T[k] >= J[i] }) T[k] = J[i] L[i] = k + 1 } diff --git a/src/internal/diff/diff_test.go b/src/internal/diff/diff_test.go index a5cd98a03c11b..aded9d83e427b 100644 --- a/src/internal/diff/diff_test.go +++ b/src/internal/diff/diff_test.go @@ -24,7 +24,7 @@ func Test(t *testing.T) { } for _, file := range files { - t.Run(filepath.Base(file), func { t | + t.Run(filepath.Base(file), func { t -> a, err := txtar.ParseFile(file) if err != nil { t.Fatal(err) diff --git a/src/internal/fmtsort/sort.go b/src/internal/fmtsort/sort.go index de9e26db9676f..c6d03f8a960bc 100644 --- a/src/internal/fmtsort/sort.go +++ b/src/internal/fmtsort/sort.go @@ -59,7 +59,7 @@ func Sort(mapValue reflect.Value) SortedMap { for iter.Next() { sorted = append(sorted, KeyValue{iter.Key(), iter.Value()}) } - slices.SortStableFunc(sorted, func { a, b | return compare(a.Key, b.Key) }) + slices.SortStableFunc(sorted, func { a, b -> return compare(a.Key, b.Key) }) return sorted } diff --git a/src/internal/fmtsort/sort_test.go b/src/internal/fmtsort/sort_test.go index 9c57fbe497ead..9686852f5e11a 100644 --- a/src/internal/fmtsort/sort_test.go +++ b/src/internal/fmtsort/sort_test.go @@ -197,7 +197,7 @@ func makeChans() []chan int { for i := range cs { pin.Pin(reflect.ValueOf(cs[i]).UnsafePointer()) } - slices.SortFunc(cs, func { a, b | return cmp.Compare(reflect.ValueOf(a).Pointer(), reflect.ValueOf(b).Pointer()) }) + slices.SortFunc(cs, func { a, b -> return cmp.Compare(reflect.ValueOf(a).Pointer(), reflect.ValueOf(b).Pointer()) }) return cs } diff --git a/src/internal/fuzz/encoding_test.go b/src/internal/fuzz/encoding_test.go index 687cbc7d2eb66..436daf1a2dcfe 100644 --- a/src/internal/fuzz/encoding_test.go +++ b/src/internal/fuzz/encoding_test.go @@ -221,7 +221,7 @@ uint(18446744073709551615)` }, } for _, test := range tests { - t.Run(test.desc, func { t | + t.Run(test.desc, func { t -> vals, err := unmarshalCorpusFile([]byte(test.in)) if test.reject { if err == nil { @@ -261,7 +261,7 @@ func BenchmarkMarshalCorpusFile(b *testing.B) { for sz := 1; sz <= len(buf); sz <<= 1 { sz := sz - b.Run(strconv.Itoa(sz), func { b | for i := 0; i < b.N; i++ { + b.Run(strconv.Itoa(sz), func { b -> for i := 0; i < b.N; i++ { b.SetBytes(int64(sz)) marshalCorpusFile(buf[:sz]) } }) @@ -280,7 +280,7 @@ func BenchmarkUnmarshalCorpusFile(b *testing.B) { for sz := 1; sz <= len(buf); sz <<= 1 { sz := sz data := marshalCorpusFile(buf[:sz]) - b.Run(strconv.Itoa(sz), func { b | for i := 0; i < b.N; i++ { + b.Run(strconv.Itoa(sz), func { b -> for i := 0; i < b.N; i++ { b.SetBytes(int64(sz)) unmarshalCorpusFile(data) } }) @@ -327,7 +327,7 @@ func FuzzFloat64RoundTrip(f *testing.F) { f.Add(math.Float64bits(math.Inf(1))) f.Add(math.Float64bits(math.Inf(-1))) - f.Fuzz(func { t, u1 | + f.Fuzz(func { t, u1 -> x1 := math.Float64frombits(u1) b := marshalCorpusFile(x1) @@ -360,7 +360,7 @@ func FuzzRuneRoundTrip(f *testing.F) { f.Add(rune(-0x80000000)) f.Add(rune(0x7fffffff)) - f.Fuzz(func { t, r1 | + f.Fuzz(func { t, r1 -> b := marshalCorpusFile(r1) t.Logf("marshaled rune(0x%x):\n%s", r1, b) @@ -383,7 +383,7 @@ func FuzzStringRoundTrip(f *testing.F) { f.Add("\x00") f.Add(string([]rune{unicode.ReplacementChar})) - f.Fuzz(func { t, s1 | + f.Fuzz(func { t, s1 -> b := marshalCorpusFile(s1) t.Logf("marshaled %q:\n%s", s1, b) diff --git a/src/internal/fuzz/minimize_test.go b/src/internal/fuzz/minimize_test.go index 18f2c08b1eaa7..e0e3e03d2feac 100644 --- a/src/internal/fuzz/minimize_test.go +++ b/src/internal/fuzz/minimize_test.go @@ -133,7 +133,7 @@ func TestMinimizeInput(t *testing.T) { for _, tc := range cases { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() ws := &workerServer{ fuzzFn: func(e CorpusEntry) (time.Duration, error) { diff --git a/src/internal/fuzz/mutator_test.go b/src/internal/fuzz/mutator_test.go index 21560559bae84..4eb1771d08ef8 100644 --- a/src/internal/fuzz/mutator_test.go +++ b/src/internal/fuzz/mutator_test.go @@ -26,7 +26,7 @@ func BenchmarkMutatorBytes(b *testing.B) { 10000, 100000, } { - b.Run(strconv.Itoa(size), func { b | + b.Run(strconv.Itoa(size), func { b -> buf := make([]byte, size) b.ResetTimer() @@ -54,7 +54,7 @@ func BenchmarkMutatorString(b *testing.B) { 10000, 100000, } { - b.Run(strconv.Itoa(size), func { b | + b.Run(strconv.Itoa(size), func { b -> buf := make([]byte, size) b.ResetTimer() @@ -92,7 +92,7 @@ func BenchmarkMutatorAllBasicTypes(b *testing.B) { } for _, t := range types { - b.Run(fmt.Sprintf("%T", t), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%T", t), func { b -> for i := 0; i < b.N; i++ { m.r = newPcgRand() m.mutate([]any{t}, workerSharedMemSize) } }) diff --git a/src/internal/fuzz/mutators_byteslice_test.go b/src/internal/fuzz/mutators_byteslice_test.go index d5e01dd833a0f..ff47456a311ad 100644 --- a/src/internal/fuzz/mutators_byteslice_test.go +++ b/src/internal/fuzz/mutators_byteslice_test.go @@ -171,7 +171,7 @@ func TestByteSliceMutators(t *testing.T) { expected: []byte{3, 2, 1, 4}, }, } { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> r := &mockRand{values: []int{0, 1, 2, 3, 4, 5}} if tc.randVals != nil { r.values = tc.randVals diff --git a/src/internal/fuzz/worker_test.go b/src/internal/fuzz/worker_test.go index 88b71338bfa80..5d419a68c31ad 100644 --- a/src/internal/fuzz/worker_test.go +++ b/src/internal/fuzz/worker_test.go @@ -188,9 +188,9 @@ func BenchmarkWorkerMinimize(b *testing.B) { mem = <-ws.memMu mem.setValue(encodedVals) ws.memMu <- mem - b.Run(strconv.Itoa(sz), func { b | + b.Run(strconv.Itoa(sz), func { b -> i := 0 - ws.fuzzFn = func { _ | + ws.fuzzFn = func { _ -> if i == 0 { i++ return time.Second, errors.New("initial failure for deflake") diff --git a/src/internal/godebug/godebug.go b/src/internal/godebug/godebug.go index dab8b80e48aef..36f49ad18fe2d 100644 --- a/src/internal/godebug/godebug.go +++ b/src/internal/godebug/godebug.go @@ -243,7 +243,7 @@ func update(def, env string) { parse(did, def) // Clear any cached values that are no longer present. - cache.Range(func { name, s | + cache.Range(func { name, s -> if !did[name.(string)] { s.(*setting).value.Store(&empty) } diff --git a/src/internal/pkgbits/sync.go b/src/internal/pkgbits/sync.go index 5063c69f04c6e..07f4b92acfa8f 100644 --- a/src/internal/pkgbits/sync.go +++ b/src/internal/pkgbits/sync.go @@ -13,7 +13,7 @@ import ( // fmtFrames formats a backtrace for reporting reader/writer desyncs. func fmtFrames(pcs ...uintptr) []string { res := make([]string, 0, len(pcs)) - walkFrames(pcs, func { file, line, name, offset | + walkFrames(pcs, func { file, line, name, offset -> // Trim package from function name. It's just redundant noise. name = strings.TrimPrefix(name, "cmd/compile/internal/noder.") diff --git a/src/internal/poll/error_test.go b/src/internal/poll/error_test.go index 6c91056a54065..b46e743d52e44 100644 --- a/src/internal/poll/error_test.go +++ b/src/internal/poll/error_test.go @@ -14,7 +14,7 @@ import ( ) func TestReadError(t *testing.T) { - t.Run("ErrNotPollable", func { t | + t.Run("ErrNotPollable", func { t -> f, err := badStateFile() if err != nil { t.Skip(err) diff --git a/src/internal/poll/fd_windows.go b/src/internal/poll/fd_windows.go index 174e61b5d54d9..e2ffe0024f133 100644 --- a/src/internal/poll/fd_windows.go +++ b/src/internal/poll/fd_windows.go @@ -435,7 +435,7 @@ func (fd *FD) Read(buf []byte) (int, error) { } else { o := &fd.rop o.InitBuf(buf) - n, err = execIO(o, func { o | return syscall.WSARecv(o.fd.Sysfd, &o.buf, 1, &o.qty, &o.flags, &o.o, nil) }) + n, err = execIO(o, func { o -> return syscall.WSARecv(o.fd.Sysfd, &o.buf, 1, &o.qty, &o.flags, &o.o, nil) }) if race.Enabled { race.Acquire(unsafe.Pointer(&ioSync)) } @@ -576,7 +576,7 @@ func (fd *FD) ReadFrom(buf []byte) (int, syscall.Sockaddr, error) { defer fd.readUnlock() o := &fd.rop o.InitBuf(buf) - n, err := execIO(o, func { o | + n, err := execIO(o, func { o -> if o.rsa == nil { o.rsa = new(syscall.RawSockaddrAny) } @@ -605,7 +605,7 @@ func (fd *FD) ReadFromInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error) defer fd.readUnlock() o := &fd.rop o.InitBuf(buf) - n, err := execIO(o, func { o | + n, err := execIO(o, func { o -> if o.rsa == nil { o.rsa = new(syscall.RawSockaddrAny) } @@ -634,7 +634,7 @@ func (fd *FD) ReadFromInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error) defer fd.readUnlock() o := &fd.rop o.InitBuf(buf) - n, err := execIO(o, func { o | + n, err := execIO(o, func { o -> if o.rsa == nil { o.rsa = new(syscall.RawSockaddrAny) } @@ -690,7 +690,7 @@ func (fd *FD) Write(buf []byte) (int, error) { } o := &fd.wop o.InitBuf(b) - n, err = execIO(o, func { o | return syscall.WSASend(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, &o.o, nil) }) + n, err = execIO(o, func { o -> return syscall.WSASend(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, &o.o, nil) }) } ntotal += n if err != nil { @@ -801,7 +801,7 @@ func (fd *FD) Writev(buf *[][]byte) (int64, error) { } o := &fd.wop o.InitBufs(buf) - n, err := execIO(o, func { o | return syscall.WSASend(o.fd.Sysfd, &o.bufs[0], uint32(len(o.bufs)), &o.qty, 0, &o.o, nil) }) + n, err := execIO(o, func { o -> return syscall.WSASend(o.fd.Sysfd, &o.bufs[0], uint32(len(o.bufs)), &o.qty, 0, &o.o, nil) }) o.ClearBufs() TestHookDidWritev(n) consume(buf, int64(n)) @@ -820,7 +820,7 @@ func (fd *FD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error) { o := &fd.wop o.InitBuf(buf) o.sa = sa - n, err := execIO(o, func { o | return syscall.WSASendto(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil) }) + n, err := execIO(o, func { o -> return syscall.WSASendto(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil) }) return n, err } @@ -833,7 +833,7 @@ func (fd *FD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error) { o := &fd.wop o.InitBuf(b) o.sa = sa - n, err := execIO(o, func { o | return syscall.WSASendto(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil) }) + n, err := execIO(o, func { o -> return syscall.WSASendto(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, o.sa, &o.o, nil) }) ntotal += int(n) if err != nil { return ntotal, err @@ -854,7 +854,7 @@ func (fd *FD) WriteToInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error) // handle zero-byte payload o := &fd.wop o.InitBuf(buf) - n, err := execIO(o, func { o | return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa4, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa4, &o.o, nil) }) return n, err } @@ -866,7 +866,7 @@ func (fd *FD) WriteToInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error) } o := &fd.wop o.InitBuf(b) - n, err := execIO(o, func { o | return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa4, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSASendtoInet4(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa4, &o.o, nil) }) ntotal += int(n) if err != nil { return ntotal, err @@ -887,7 +887,7 @@ func (fd *FD) WriteToInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error) // handle zero-byte payload o := &fd.wop o.InitBuf(buf) - n, err := execIO(o, func { o | return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa6, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa6, &o.o, nil) }) return n, err } @@ -899,7 +899,7 @@ func (fd *FD) WriteToInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error) } o := &fd.wop o.InitBuf(b) - n, err := execIO(o, func { o | return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa6, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSASendtoInet6(o.fd.Sysfd, &o.buf, 1, &o.qty, 0, sa6, &o.o, nil) }) ntotal += int(n) if err != nil { return ntotal, err @@ -915,7 +915,7 @@ func (fd *FD) WriteToInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error) func (fd *FD) ConnectEx(ra syscall.Sockaddr) error { o := &fd.wop o.sa = ra - _, err := execIO(o, func { o | return ConnectExFunc(o.fd.Sysfd, o.sa, nil, 0, nil, &o.o) }) + _, err := execIO(o, func { o -> return ConnectExFunc(o.fd.Sysfd, o.sa, nil, 0, nil, &o.o) }) return err } @@ -923,7 +923,7 @@ func (fd *FD) acceptOne(s syscall.Handle, rawsa []syscall.RawSockaddrAny, o *ope // Submit accept request. o.handle = s o.rsan = int32(unsafe.Sizeof(rawsa[0])) - _, err := execIO(o, func { o | + _, err := execIO(o, func { o -> return AcceptFunc(o.fd.Sysfd, o.handle, (*byte)(unsafe.Pointer(&rawsa[0])), 0, uint32(o.rsan), uint32(o.rsan), &o.qty, &o.o) }) if err != nil { @@ -1067,7 +1067,7 @@ func (fd *FD) RawRead(f func(uintptr) bool) error { if !fd.IsStream { o.flags |= windows.MSG_PEEK } - _, err := execIO(o, func { o | return syscall.WSARecv(o.fd.Sysfd, &o.buf, 1, &o.qty, &o.flags, &o.o, nil) }) + _, err := execIO(o, func { o -> return syscall.WSARecv(o.fd.Sysfd, &o.buf, 1, &o.qty, &o.flags, &o.o, nil) }) if err == windows.WSAEMSGSIZE { // expected with a 0-byte peek, ignore. } else if err != nil { @@ -1161,7 +1161,7 @@ func (fd *FD) ReadMsg(p []byte, oob []byte, flags int) (int, int, int, syscall.S o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = int32(unsafe.Sizeof(*o.rsa)) o.msg.Flags = uint32(flags) - n, err := execIO(o, func { o | return windows.WSARecvMsg(o.fd.Sysfd, &o.msg, &o.qty, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSARecvMsg(o.fd.Sysfd, &o.msg, &o.qty, &o.o, nil) }) err = fd.eofError(n, err) var sa syscall.Sockaddr if err == nil { @@ -1189,7 +1189,7 @@ func (fd *FD) ReadMsgInet4(p []byte, oob []byte, flags int, sa4 *syscall.Sockadd o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = int32(unsafe.Sizeof(*o.rsa)) o.msg.Flags = uint32(flags) - n, err := execIO(o, func { o | return windows.WSARecvMsg(o.fd.Sysfd, &o.msg, &o.qty, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSARecvMsg(o.fd.Sysfd, &o.msg, &o.qty, &o.o, nil) }) err = fd.eofError(n, err) if err == nil { rawToSockaddrInet4(o.rsa, sa4) @@ -1216,7 +1216,7 @@ func (fd *FD) ReadMsgInet6(p []byte, oob []byte, flags int, sa6 *syscall.Sockadd o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = int32(unsafe.Sizeof(*o.rsa)) o.msg.Flags = uint32(flags) - n, err := execIO(o, func { o | return windows.WSARecvMsg(o.fd.Sysfd, &o.msg, &o.qty, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSARecvMsg(o.fd.Sysfd, &o.msg, &o.qty, &o.o, nil) }) err = fd.eofError(n, err) if err == nil { rawToSockaddrInet6(o.rsa, sa6) @@ -1248,7 +1248,7 @@ func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, err o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = len } - n, err := execIO(o, func { o | return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) }) return n, int(o.msg.Control.Len), err } @@ -1271,7 +1271,7 @@ func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (in len := sockaddrInet4ToRaw(o.rsa, sa) o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = len - n, err := execIO(o, func { o | return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) }) return n, int(o.msg.Control.Len), err } @@ -1294,7 +1294,7 @@ func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (in len := sockaddrInet6ToRaw(o.rsa, sa) o.msg.Name = (syscall.Pointer)(unsafe.Pointer(o.rsa)) o.msg.Namelen = len - n, err := execIO(o, func { o | return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) }) + n, err := execIO(o, func { o -> return windows.WSASendMsg(o.fd.Sysfd, &o.msg, 0, &o.qty, &o.o, nil) }) return n, int(o.msg.Control.Len), err } diff --git a/src/internal/poll/fd_windows_test.go b/src/internal/poll/fd_windows_test.go index 9275de33a6f68..fd768556f95bd 100644 --- a/src/internal/poll/fd_windows_test.go +++ b/src/internal/poll/fd_windows_test.go @@ -85,7 +85,7 @@ func TestFileFdsAreInitialised(t *testing.T) { func TestSerialFdsAreInitialised(t *testing.T) { for _, name := range []string{"COM1", "COM2", "COM3", "COM4"} { - t.Run(name, func { t | + t.Run(name, func { t -> h, err := syscall.CreateFile(syscall.StringToUTF16Ptr(name), syscall.GENERIC_READ|syscall.GENERIC_WRITE, 0, diff --git a/src/internal/poll/read_test.go b/src/internal/poll/read_test.go index 29664fe10d3ee..157a748a341ec 100644 --- a/src/internal/poll/read_test.go +++ b/src/internal/poll/read_test.go @@ -13,7 +13,7 @@ import ( ) func TestRead(t *testing.T) { - t.Run("SpecialFile", func { t | + t.Run("SpecialFile", func { t -> var wg sync.WaitGroup for _, p := range specialFiles() { for i := 0; i < 4; i++ { diff --git a/src/internal/poll/sendfile_windows.go b/src/internal/poll/sendfile_windows.go index a3db7f17236d2..ab609c839b80f 100644 --- a/src/internal/poll/sendfile_windows.go +++ b/src/internal/poll/sendfile_windows.go @@ -63,7 +63,7 @@ func SendFile(fd *FD, src syscall.Handle, n int64) (written int64, err error) { o.o.Offset = uint32(curpos) o.o.OffsetHigh = uint32(curpos >> 32) - nw, err := execIO(o, func { o | return syscall.TransmitFile(o.fd.Sysfd, o.handle, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND) }) + nw, err := execIO(o, func { o -> return syscall.TransmitFile(o.fd.Sysfd, o.handle, o.qty, 0, &o.o, nil, syscall.TF_WRITE_BEHIND) }) if err != nil { return written, err } diff --git a/src/internal/poll/splice_linux_test.go b/src/internal/poll/splice_linux_test.go index b3718dc48baab..3ea3f92bf76d6 100644 --- a/src/internal/poll/splice_linux_test.go +++ b/src/internal/poll/splice_linux_test.go @@ -37,7 +37,7 @@ func TestSplicePipePool(t *testing.T) { err error ) - closeHook.Store(func { fd | pendingFDs.Delete(fd) }) + closeHook.Store(func { fd -> pendingFDs.Delete(fd) }) t.Cleanup(func() { closeHook.Store((func(int))(nil)) }) for i := 0; i < N; i++ { @@ -73,7 +73,7 @@ func TestSplicePipePool(t *testing.T) { // Detect whether all pipes are closed properly. var leakedFDs []int - pendingFDs.Range(func { k, v | + pendingFDs.Range(func { k, v -> leakedFDs = append(leakedFDs, k.(int)) return true }) @@ -91,7 +91,7 @@ func TestSplicePipePool(t *testing.T) { } func BenchmarkSplicePipe(b *testing.B) { - b.Run("SplicePipeWithPool", func { b | + b.Run("SplicePipeWithPool", func { b -> for i := 0; i < b.N; i++ { p, err := poll.GetPipe() if err != nil { @@ -100,7 +100,7 @@ func BenchmarkSplicePipe(b *testing.B) { poll.PutPipe(p) } }) - b.Run("SplicePipeWithoutPool", func { b | + b.Run("SplicePipeWithoutPool", func { b -> for i := 0; i < b.N; i++ { p := poll.NewPipe() if p == nil { @@ -112,7 +112,7 @@ func BenchmarkSplicePipe(b *testing.B) { } func BenchmarkSplicePipePoolParallel(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { p, err := poll.GetPipe() if err != nil { @@ -124,7 +124,7 @@ func BenchmarkSplicePipePoolParallel(b *testing.B) { } func BenchmarkSplicePipeNativeParallel(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { p := poll.NewPipe() if p == nil { diff --git a/src/internal/reflectlite/all_test.go b/src/internal/reflectlite/all_test.go index 16b789f468e65..08455db9bce60 100644 --- a/src/internal/reflectlite/all_test.go +++ b/src/internal/reflectlite/all_test.go @@ -347,7 +347,7 @@ func TestCanSetField(t *testing.T) { }} for _, tt := range tests { - t.Run(tt.val.Type().Name(), func { t | + t.Run(tt.val.Type().Name(), func { t -> for _, tc := range tt.cases { f := tt.val for _, i := range tc.index { @@ -805,7 +805,7 @@ func noAlloc(t *testing.T, n int, f func(int)) { } func TestAllocations(t *testing.T) { - noAlloc(t, 100, func { j | + noAlloc(t, 100, func { j -> var i any var v Value @@ -815,11 +815,11 @@ func TestAllocations(t *testing.T) { panic("wrong length") } }) - noAlloc(t, 100, func { j | + noAlloc(t, 100, func { j -> var i any var v Value - i = func { j | return j } + i = func { j -> return j } v = ValueOf(i) if ToInterface(v).(func(int) int)(j) != j { panic("wrong result") diff --git a/src/internal/runtime/atomic/atomic_andor_test.go b/src/internal/runtime/atomic/atomic_andor_test.go index 4dcaefb5a6227..f46dabd853cbf 100644 --- a/src/internal/runtime/atomic/atomic_andor_test.go +++ b/src/internal/runtime/atomic/atomic_andor_test.go @@ -178,7 +178,7 @@ func BenchmarkAnd32(b *testing.B) { func BenchmarkAnd32Parallel(b *testing.B) { var x [128]uint32 // give x its own cache line sink = &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := uint32(0) for pb.Next() { atomic.And32(&x[63], i) @@ -198,7 +198,7 @@ func BenchmarkAnd64(b *testing.B) { func BenchmarkAnd64Parallel(b *testing.B) { var x [128]uint64 // give x its own cache line sink = &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := uint64(0) for pb.Next() { atomic.And64(&x[63], i) @@ -218,7 +218,7 @@ func BenchmarkOr32(b *testing.B) { func BenchmarkOr32Parallel(b *testing.B) { var x [128]uint32 // give x its own cache line sink = &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := uint32(0) for pb.Next() { atomic.Or32(&x[63], i) @@ -238,7 +238,7 @@ func BenchmarkOr64(b *testing.B) { func BenchmarkOr64Parallel(b *testing.B) { var x [128]uint64 // give x its own cache line sink = &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := uint64(0) for pb.Next() { atomic.Or64(&x[63], i) diff --git a/src/internal/runtime/atomic/bench_test.go b/src/internal/runtime/atomic/bench_test.go index 42c5a634f93c5..7eac49c2b29e1 100644 --- a/src/internal/runtime/atomic/bench_test.go +++ b/src/internal/runtime/atomic/bench_test.go @@ -62,7 +62,7 @@ func BenchmarkAnd(b *testing.B) { func BenchmarkAnd8Parallel(b *testing.B) { var x [512]uint8 // give byte its own cache line sink = &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := uint8(0) for pb.Next() { atomic.And8(&x[255], i) @@ -74,7 +74,7 @@ func BenchmarkAnd8Parallel(b *testing.B) { func BenchmarkAndParallel(b *testing.B) { var x [128]uint32 // give x its own cache line sink = &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := uint32(0) for pb.Next() { atomic.And(&x[63], i) @@ -102,7 +102,7 @@ func BenchmarkOr(b *testing.B) { func BenchmarkOr8Parallel(b *testing.B) { var x [512]uint8 // give byte its own cache line sink = &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := uint8(0) for pb.Next() { atomic.Or8(&x[255], i) @@ -114,7 +114,7 @@ func BenchmarkOr8Parallel(b *testing.B) { func BenchmarkOrParallel(b *testing.B) { var x [128]uint32 // give x its own cache line sink = &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := uint32(0) for pb.Next() { atomic.Or(&x[63], i) @@ -126,7 +126,7 @@ func BenchmarkOrParallel(b *testing.B) { func BenchmarkXadd(b *testing.B) { var x uint32 ptr := &x - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { atomic.Xadd(ptr, 1) } }) } @@ -134,7 +134,7 @@ func BenchmarkXadd(b *testing.B) { func BenchmarkXadd64(b *testing.B) { var x uint64 ptr := &x - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { atomic.Xadd64(ptr, 1) } }) } @@ -143,7 +143,7 @@ func BenchmarkCas(b *testing.B) { var x uint32 x = 1 ptr := &x - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { atomic.Cas(ptr, 1, 0) atomic.Cas(ptr, 0, 1) } }) @@ -153,7 +153,7 @@ func BenchmarkCas64(b *testing.B) { var x uint64 x = 1 ptr := &x - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { atomic.Cas64(ptr, 1, 0) atomic.Cas64(ptr, 0, 1) } }) @@ -162,7 +162,7 @@ func BenchmarkXchg(b *testing.B) { var x uint32 x = 1 ptr := &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var y uint32 y = 1 for pb.Next() { @@ -176,7 +176,7 @@ func BenchmarkXchg64(b *testing.B) { var x uint64 x = 1 ptr := &x - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var y uint64 y = 1 for pb.Next() { diff --git a/src/internal/saferio/io_test.go b/src/internal/saferio/io_test.go index 06367765f5eef..750dd67c300a1 100644 --- a/src/internal/saferio/io_test.go +++ b/src/internal/saferio/io_test.go @@ -14,7 +14,7 @@ func TestReadData(t *testing.T) { const count = 100 input := bytes.Repeat([]byte{'a'}, count) - t.Run("small", func { t | + t.Run("small", func { t -> got, err := ReadData(bytes.NewReader(input), count) if err != nil { t.Fatal(err) @@ -24,35 +24,35 @@ func TestReadData(t *testing.T) { } }) - t.Run("large", func { t | + t.Run("large", func { t -> _, err := ReadData(bytes.NewReader(input), 10<<30) if err == nil { t.Error("large read succeeded unexpectedly") } }) - t.Run("maxint", func { t | + t.Run("maxint", func { t -> _, err := ReadData(bytes.NewReader(input), 1<<62) if err == nil { t.Error("large read succeeded unexpectedly") } }) - t.Run("small-EOF", func { t | + t.Run("small-EOF", func { t -> _, err := ReadData(bytes.NewReader(nil), chunk-1) if err != io.EOF { t.Errorf("ReadData = %v, want io.EOF", err) } }) - t.Run("large-EOF", func { t | + t.Run("large-EOF", func { t -> _, err := ReadData(bytes.NewReader(nil), chunk+1) if err != io.EOF { t.Errorf("ReadData = %v, want io.EOF", err) } }) - t.Run("large-UnexpectedEOF", func { t | + t.Run("large-UnexpectedEOF", func { t -> _, err := ReadData(bytes.NewReader(make([]byte, chunk)), chunk+1) if err != io.ErrUnexpectedEOF { t.Errorf("ReadData = %v, want io.ErrUnexpectedEOF", err) @@ -64,7 +64,7 @@ func TestReadDataAt(t *testing.T) { const count = 100 input := bytes.Repeat([]byte{'a'}, count) - t.Run("small", func { t | + t.Run("small", func { t -> got, err := ReadDataAt(bytes.NewReader(input), count, 0) if err != nil { t.Fatal(err) @@ -74,21 +74,21 @@ func TestReadDataAt(t *testing.T) { } }) - t.Run("large", func { t | + t.Run("large", func { t -> _, err := ReadDataAt(bytes.NewReader(input), 10<<30, 0) if err == nil { t.Error("large read succeeded unexpectedly") } }) - t.Run("maxint", func { t | + t.Run("maxint", func { t -> _, err := ReadDataAt(bytes.NewReader(input), 1<<62, 0) if err == nil { t.Error("large read succeeded unexpectedly") } }) - t.Run("SectionReader", func { t | + t.Run("SectionReader", func { t -> // Reading 0 bytes from an io.SectionReader at the end // of the section will return EOF, but ReadDataAt // should succeed and return 0 bytes. @@ -104,14 +104,14 @@ func TestReadDataAt(t *testing.T) { } func TestSliceCap(t *testing.T) { - t.Run("small", func { t | + t.Run("small", func { t -> c := SliceCap[int](10) if c != 10 { t.Errorf("got capacity %d, want %d", c, 10) } }) - t.Run("large", func { t | + t.Run("large", func { t -> c := SliceCap[byte](1 << 30) if c < 0 { t.Error("SliceCap failed unexpectedly") @@ -120,14 +120,14 @@ func TestSliceCap(t *testing.T) { } }) - t.Run("maxint", func { t | + t.Run("maxint", func { t -> c := SliceCap[byte](1 << 63) if c >= 0 { t.Errorf("SliceCap returned %d, expected failure", c) } }) - t.Run("overflow", func { t | + t.Run("overflow", func { t -> c := SliceCap[int64](1 << 62) if c >= 0 { t.Errorf("SliceCap returned %d, expected failure", c) diff --git a/src/internal/testenv/testenv_test.go b/src/internal/testenv/testenv_test.go index 1cc0d14a603b9..497b456e6ee16 100644 --- a/src/internal/testenv/testenv_test.go +++ b/src/internal/testenv/testenv_test.go @@ -111,11 +111,11 @@ func TestHasGoBuild(t *testing.T) { hasExec := false hasExecGo := false - t.Run("MustHaveExec", func { t | + t.Run("MustHaveExec", func { t -> testenv.MustHaveExec(t) hasExec = true }) - t.Run("MustHaveExecPath", func { t | + t.Run("MustHaveExecPath", func { t -> testenv.MustHaveExecPath(t, "go") hasExecGo = true }) @@ -140,7 +140,7 @@ func TestHasGoBuild(t *testing.T) { func TestMustHaveExec(t *testing.T) { hasExec := false - t.Run("MustHaveExec", func { t | + t.Run("MustHaveExec", func { t -> testenv.MustHaveExec(t) t.Logf("MustHaveExec did not skip") hasExec = true diff --git a/src/internal/trace/event.go b/src/internal/trace/event.go index 311bb1e4d3b50..a7bc50aef646e 100644 --- a/src/internal/trace/event.go +++ b/src/internal/trace/event.go @@ -795,7 +795,7 @@ func (e Event) String() string { if s.Stack != NoStack { fmt.Fprintln(&sb) fmt.Fprintln(&sb, "TransitionStack=") - s.Stack.Frames(func { f | + s.Stack.Frames(func { f -> fmt.Fprintf(&sb, "\t%s @ 0x%x\n", f.Func, f.PC) fmt.Fprintf(&sb, "\t\t%s:%d\n", f.File, f.Line) return true @@ -808,7 +808,7 @@ func (e Event) String() string { if stk := e.Stack(); stk != NoStack { fmt.Fprintln(&sb) fmt.Fprintln(&sb, "Stack=") - stk.Frames(func { f | + stk.Frames(func { f -> fmt.Fprintf(&sb, "\t%s @ 0x%x\n", f.Func, f.PC) fmt.Fprintf(&sb, "\t\t%s:%d\n", f.File, f.Line) return true diff --git a/src/internal/trace/gc_test.go b/src/internal/trace/gc_test.go index 7c7f018517a69..383c56f9c76e3 100644 --- a/src/internal/trace/gc_test.go +++ b/src/internal/trace/gc_test.go @@ -116,7 +116,7 @@ func TestMMUTrace(t *testing.T) { } } } - t.Run("V2", func { t | + t.Run("V2", func { t -> testPath := "testdata/tests/go122-gc-stress.test" r, _, err := testtrace.ParseFile(testPath) if err != nil { diff --git a/src/internal/trace/generation.go b/src/internal/trace/generation.go index bff7b714a1095..801326b8a450c 100644 --- a/src/internal/trace/generation.go +++ b/src/internal/trace/generation.go @@ -129,7 +129,7 @@ func readGeneration(r *bufio.Reader, spill *spilledBatch) (*generation, *spilled s.time = g.freq.mul(timestamp(s.time)) } // Sort the CPU samples. - slices.SortFunc(g.cpuSamples, func { a, b | return cmp.Compare(a.time, b.time) }) + slices.SortFunc(g.cpuSamples, func { a, b -> return cmp.Compare(a.time, b.time) }) return g, spill, spillErr } @@ -180,7 +180,7 @@ func validateStackStrings( frames map[uint64]frame, ) error { var err error - stacks.forEach(func { id, stk | + stacks.forEach(func { id, stk -> for _, pc := range stk.pcs { frame, ok := frames[pc] if !ok { diff --git a/src/internal/trace/internal/oldtrace/parser.go b/src/internal/trace/internal/oldtrace/parser.go index 26918e2642f18..19d649068f5d9 100644 --- a/src/internal/trace/internal/oldtrace/parser.go +++ b/src/internal/trace/internal/oldtrace/parser.go @@ -370,7 +370,7 @@ func (p *parser) parseEventBatches() (Events, error) { // with original timestamps corresponding to when ReadTrace pulled the data // off of the profBuf queue. Re-sort them by the timestamp we captured // inside the signal handler. - slices.SortFunc(p.cpuSamples, func { a, b | return cmp.Compare(a.Ts, b.Ts) }) + slices.SortFunc(p.cpuSamples, func { a, b -> return cmp.Compare(a.Ts, b.Ts) }) allProcs := make([]proc, 0, len(p.batchOffsets)) for pid := range p.batchOffsets { diff --git a/src/internal/trace/internal/oldtrace/parser_test.go b/src/internal/trace/internal/oldtrace/parser_test.go index e20216ed84787..b71037af949ad 100644 --- a/src/internal/trace/internal/oldtrace/parser_test.go +++ b/src/internal/trace/internal/oldtrace/parser_test.go @@ -103,7 +103,7 @@ func TestBuckets(t *testing.T) { } var n int - evs.All()(func { ev | + evs.All()(func { ev -> n++ return true }) diff --git a/src/internal/trace/mud.go b/src/internal/trace/mud.go index 812beb5b5081c..23900209af68d 100644 --- a/src/internal/trace/mud.go +++ b/src/internal/trace/mud.go @@ -167,7 +167,7 @@ func (d *mud) invCumulativeSum(y float64) (float64, bool) { // Sort edges. edges := d.unsorted - slices.SortFunc(edges, func { a, b | return cmp.Compare(a.x, b.x) }) + slices.SortFunc(edges, func { a, b -> return cmp.Compare(a.x, b.x) }) // Merge with sorted edges. d.unsorted = nil if d.sorted == nil { diff --git a/src/internal/trace/oldtrace.go b/src/internal/trace/oldtrace.go index 9f1ab4f80bbc2..d514145147a11 100644 --- a/src/internal/trace/oldtrace.go +++ b/src/internal/trace/oldtrace.go @@ -406,7 +406,7 @@ func (it *oldTraceConverter) convertEvent(ev *oldtrace.Event) (OUT Event, ERR er // Look for the next event for the same G to determine if the syscall // blocked. blocked := false - it.events.All()(func { nev | + it.events.All()(func { nev -> if nev.G != ev.G { return true } diff --git a/src/internal/trace/oldtrace_test.go b/src/internal/trace/oldtrace_test.go index 36c5a965ba8c8..f958865bc94b6 100644 --- a/src/internal/trace/oldtrace_test.go +++ b/src/internal/trace/oldtrace_test.go @@ -25,7 +25,7 @@ func TestOldtrace(t *testing.T) { if err != nil { t.Fatalf("failed to relativize testdata path: %s", err) } - t.Run(testName, func { t | + t.Run(testName, func { t -> f, err := os.Open(p) if err != nil { t.Fatalf("failed to open test %q: %s", p, err) diff --git a/src/internal/trace/reader_test.go b/src/internal/trace/reader_test.go index 38857481f4778..134e20b52cb22 100644 --- a/src/internal/trace/reader_test.go +++ b/src/internal/trace/reader_test.go @@ -36,7 +36,7 @@ func TestReaderGolden(t *testing.T) { if err != nil { t.Fatalf("failed to relativize testdata path: %v", err) } - t.Run(testName, func { t | + t.Run(testName, func { t -> tr, exp, err := testtrace.ParseFile(testPath) if err != nil { t.Fatalf("failed to parse test file at %s: %v", testPath, err) @@ -52,7 +52,7 @@ func FuzzReader(f *testing.F) { // reject invalid traces. const testGetters = false - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> r, err := trace.NewReader(bytes.NewReader(b)) if err != nil { return diff --git a/src/internal/trace/summary.go b/src/internal/trace/summary.go index cab5098d1ada5..0ed30eaeeefcb 100644 --- a/src/internal/trace/summary.go +++ b/src/internal/trace/summary.go @@ -394,7 +394,7 @@ func (s *Summarizer) Event(ev *Event) { if stk != NoStack { var frame StackFrame var ok bool - stk.Frames(func { f | + stk.Frames(func { f -> frame = f ok = true return true @@ -594,7 +594,7 @@ func (s *Summarizer) Finalize() *Summary { g.finalize(s.lastTs, nil) // Sort based on region start time. - slices.SortFunc(g.Regions, func { a, b | + slices.SortFunc(g.Regions, func { a, b -> x := a.Start y := b.Start if x == nil { diff --git a/src/internal/trace/testtrace/validation.go b/src/internal/trace/testtrace/validation.go index 92d7437d06e4b..43b6119b498e0 100644 --- a/src/internal/trace/testtrace/validation.go +++ b/src/internal/trace/testtrace/validation.go @@ -351,7 +351,7 @@ func (v *Validator) getOrCreateThread(e *errAccumulator, ev trace.Event, m trace func checkStack(e *errAccumulator, stk trace.Stack) { // Check for non-empty values, but we also check for crashes due to incorrect validation. i := 0 - stk.Frames(func { f | + stk.Frames(func { f -> if i == 0 { // Allow for one fully zero stack. // diff --git a/src/internal/trace/trace_test.go b/src/internal/trace/trace_test.go index e6b58e3df95af..48b4b354f8485 100644 --- a/src/internal/trace/trace_test.go +++ b/src/internal/trace/trace_test.go @@ -21,7 +21,7 @@ import ( ) func TestTraceAnnotations(t *testing.T) { - testTraceProg(t, "annotations.go", func { t, tb, _, _ | + testTraceProg(t, "annotations.go", func { t, tb, _, _ -> type evDesc struct { kind trace.EventKind task trace.TaskID @@ -96,7 +96,7 @@ func TestTraceCgoCallback(t *testing.T) { } func TestTraceCPUProfile(t *testing.T) { - testTraceProg(t, "cpu-profile.go", func { t, tb, stderr, _ | + testTraceProg(t, "cpu-profile.go", func { t, tb, stderr, _ -> // Parse stderr which has a CPU profile summary, if everything went well. // (If it didn't, we shouldn't even make it here.) scanner := bufio.NewScanner(bytes.NewReader(stderr)) @@ -148,7 +148,7 @@ func TestTraceCPUProfile(t *testing.T) { if hogRegion != nil && ev.Goroutine() == hogRegion.Goroutine() { traceSamples++ var fns []string - ev.Stack().Frames(func { frame | + ev.Stack().Frames(func { frame -> if frame.Func != "runtime.goexit" { fns = append(fns, fmt.Sprintf("%s:%d", frame.Func, frame.Line)) } @@ -210,7 +210,7 @@ func TestTraceCPUProfile(t *testing.T) { } func TestTraceFutileWakeup(t *testing.T) { - testTraceProg(t, "futile-wakeup.go", func { t, tb, _, _ | + testTraceProg(t, "futile-wakeup.go", func { t, tb, _, _ -> // Check to make sure that no goroutine in the "special" trace region // ends up blocking, unblocking, then immediately blocking again. // @@ -311,7 +311,7 @@ func TestTraceGOMAXPROCS(t *testing.T) { } func TestTraceStacks(t *testing.T) { - testTraceProg(t, "stacks.go", func { t, tb, _, stress | + testTraceProg(t, "stacks.go", func { t, tb, _, stress -> type frame struct { fn string line int @@ -438,7 +438,7 @@ func TestTraceStacks(t *testing.T) { stackMatches := func(stk trace.Stack, frames []frame) bool { i := 0 match := true - stk.Frames(func { f | + stk.Frames(func { f -> if f.Func != frames[i].fn { match = false return false @@ -611,14 +611,14 @@ func testTraceProg(t *testing.T, progName string, extra func(t *testing.T, trace t.Logf("wrote trace to file: %s", dumpTraceToFile(t, testName, stress, tb)) } } - t.Run("Default", func { t | runTest(t, false, "") }) - t.Run("Stress", func { t | + t.Run("Default", func { t -> runTest(t, false, "") }) + t.Run("Stress", func { t -> if testing.Short() { t.Skip("skipping trace stress tests in short mode") } runTest(t, true, "") }) - t.Run("AllocFree", func { t | + t.Run("AllocFree", func { t -> if testing.Short() { t.Skip("skipping trace alloc/free tests in short mode") } diff --git a/src/internal/trace/traceviewer/emitter.go b/src/internal/trace/traceviewer/emitter.go index 1f0275c384445..609dd41c8b90b 100644 --- a/src/internal/trace/traceviewer/emitter.go +++ b/src/internal/trace/traceviewer/emitter.go @@ -44,11 +44,11 @@ func ViewerDataTraceConsumer(w io.Writer, startIdx, endIdx int64) TraceConsumer // not in the range. Skip! return } - WalkStackFrames(allFrames, v.Stack, func { id | + WalkStackFrames(allFrames, v.Stack, func { id -> s := strconv.Itoa(id) requiredFrames[s] = allFrames[s] }) - WalkStackFrames(allFrames, v.EndStack, func { id | + WalkStackFrames(allFrames, v.EndStack, func { id -> s := strconv.Itoa(id) requiredFrames[s] = allFrames[s] }) @@ -103,11 +103,11 @@ func SplittingTraceConsumer(max int) (*splitter, TraceConsumer) { // can include them in the required part of the // trace. data.Events = append(data.Events, v) - WalkStackFrames(allFrames, v.Stack, func { id | + WalkStackFrames(allFrames, v.Stack, func { id -> s := strconv.Itoa(id) data.Frames[s] = allFrames[s] }) - WalkStackFrames(allFrames, v.EndStack, func { id | + WalkStackFrames(allFrames, v.EndStack, func { id -> s := strconv.Itoa(id) data.Frames[s] = allFrames[s] }) @@ -118,8 +118,8 @@ func SplittingTraceConsumer(max int) (*splitter, TraceConsumer) { size := eventSz{Time: v.Time, Sz: cw.size + 1} // +1 for ",". // Add referenced stack frames. Their size is computed // in flush, where we can dedup across events. - WalkStackFrames(allFrames, v.Stack, func { id | size.Frames = append(size.Frames, id) }) - WalkStackFrames(allFrames, v.EndStack, func { id | size.Frames = append(size.Frames, id) })// This may add duplicates. We'll dedup later. + WalkStackFrames(allFrames, v.Stack, func { id -> size.Frames = append(size.Frames, id) }) + WalkStackFrames(allFrames, v.EndStack, func { id -> size.Frames = append(size.Frames, id) })// This may add duplicates. We'll dedup later. sizes = append(sizes, size) cw.size = 0 diff --git a/src/internal/trace/traceviewer/http.go b/src/internal/trace/traceviewer/http.go index 84e76fbb15a62..614dbd9f0221b 100644 --- a/src/internal/trace/traceviewer/http.go +++ b/src/internal/trace/traceviewer/http.go @@ -13,7 +13,7 @@ import ( ) func MainHandler(views []View) http.Handler { - return http.HandlerFunc(func { w, _ | + return http.HandlerFunc(func { w, _ -> if err := templMain.Execute(w, views); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return @@ -276,7 +276,7 @@ func (r Range) URL(viewType ViewType) string { } func TraceHandler() http.Handler { - return http.HandlerFunc(func { w, r | + return http.HandlerFunc(func { w, r -> if err := r.ParseForm(); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return diff --git a/src/internal/types/errors/codes_test.go b/src/internal/types/errors/codes_test.go index 909e242af1ad0..19bc499c3722c 100644 --- a/src/internal/types/errors/codes_test.go +++ b/src/internal/types/errors/codes_test.go @@ -22,8 +22,8 @@ import ( func TestErrorCodeExamples(t *testing.T) { testenv.MustHaveGoBuild(t) // go command needed to resolve std .a files for importer.Default(). - walkCodes(t, func { name, value, spec | - t.Run(name, func { t | + walkCodes(t, func { name, value, spec -> + t.Run(name, func { t -> doc := spec.Doc.Text() examples := strings.Split(doc, "Example:") for i := 1; i < len(examples); i++ { @@ -148,7 +148,7 @@ func TestErrorCodeStyle(t *testing.T) { longestName := "" maxValue := 0 - walkCodes(t, func { name, value, spec | + walkCodes(t, func { name, value, spec -> if name == "_" { return } diff --git a/src/internal/types/errors/generrordocs.go b/src/internal/types/errors/generrordocs.go index 02abb5f70a231..41a6e02fc4437 100644 --- a/src/internal/types/errors/generrordocs.go +++ b/src/internal/types/errors/generrordocs.go @@ -37,7 +37,7 @@ func main() { if err := os.MkdirAll(outDir, 0755); err != nil { log.Fatal("unable to create output directory: %s", err) } - walkCodes(func { name, vs | + walkCodes(func { name, vs -> // ignore unused errors if name == "_" { return diff --git a/src/internal/unsafeheader/unsafeheader_test.go b/src/internal/unsafeheader/unsafeheader_test.go index 8919f94961406..27234d89bdfe1 100644 --- a/src/internal/unsafeheader/unsafeheader_test.go +++ b/src/internal/unsafeheader/unsafeheader_test.go @@ -16,9 +16,9 @@ import ( // unsafeheader types matches the corresponding Header types in the reflect // package. func TestTypeMatchesReflectType(t *testing.T) { - t.Run("Slice", func { t | testHeaderMatchesReflect(t, unsafeheader.Slice{}, reflect.SliceHeader{}) }) + t.Run("Slice", func { t -> testHeaderMatchesReflect(t, unsafeheader.Slice{}, reflect.SliceHeader{}) }) - t.Run("String", func { t | testHeaderMatchesReflect(t, unsafeheader.String{}, reflect.StringHeader{}) }) + t.Run("String", func { t -> testHeaderMatchesReflect(t, unsafeheader.String{}, reflect.StringHeader{}) }) } func testHeaderMatchesReflect(t *testing.T, header, reflectHeader any) { @@ -64,7 +64,7 @@ func typeCompatible(t, rt reflect.Type) bool { // -d=checkptr) if the runtime views the header types as incompatible with the // underlying built-in types. func TestWriteThroughHeader(t *testing.T) { - t.Run("Slice", func { t | + t.Run("Slice", func { t -> s := []byte("Hello, checkptr!")[:5] var alias []byte @@ -81,7 +81,7 @@ func TestWriteThroughHeader(t *testing.T) { } }) - t.Run("String", func { t | + t.Run("String", func { t -> s := "Hello, checkptr!" var alias string diff --git a/src/internal/weak/pointer_test.go b/src/internal/weak/pointer_test.go index 1a644f050e424..443e7dcd776ec 100644 --- a/src/internal/weak/pointer_test.go +++ b/src/internal/weak/pointer_test.go @@ -100,7 +100,7 @@ func TestPointerFinalizer(t *testing.T) { bt := new(T) wt := weak.Make(bt) done := make(chan struct{}, 1) - runtime.SetFinalizer(bt, func { bt | + runtime.SetFinalizer(bt, func { bt -> if wt.Strong() != nil { t.Errorf("weak pointer did not go nil before finalizer ran") } diff --git a/src/internal/zstd/fse_test.go b/src/internal/zstd/fse_test.go index 3240dbc3bfd87..ec0f5fdbe33e8 100644 --- a/src/internal/zstd/fse_test.go +++ b/src/internal/zstd/fse_test.go @@ -69,7 +69,7 @@ func TestPredefinedTables(t *testing.T) { } for _, test := range tests { test := test - t.Run(test.name, func { t | + t.Run(test.name, func { t -> var r Reader table := make([]fseEntry, 1< r := NewReader(bytes.NewReader(b)) io.Copy(io.Discard, r) }) @@ -62,7 +62,7 @@ func FuzzDecompressor(f *testing.F) { f.Add(bytes.Repeat(buf.Bytes(), 64)) f.Add(bigData(f)) - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> cmd := exec.Command(zstd, "-z") cmd.Stdin = bytes.NewReader(b) var compressed bytes.Buffer @@ -96,7 +96,7 @@ func FuzzReverse(f *testing.F) { fuzzing = true defer func() { fuzzing = false }() - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> r := NewReader(bytes.NewReader(b)) goExp, goErr := io.ReadAll(r) diff --git a/src/internal/zstd/window_test.go b/src/internal/zstd/window_test.go index 256b31d8b4c19..7dac5d0bc382a 100644 --- a/src/internal/zstd/window_test.go +++ b/src/internal/zstd/window_test.go @@ -26,7 +26,7 @@ func TestWindow(t *testing.T) { for k := 0; k <= 2*size; k++ { c := makeSequence('a'+i+j, k) - t.Run(fmt.Sprintf("%d-%d-%d-%d", size, i, j, k), func { t | testWindow(t, size, a, b, c) }) + t.Run(fmt.Sprintf("%d-%d-%d-%d", size, i, j, k), func { t -> testWindow(t, size, a, b, c) }) } } } diff --git a/src/internal/zstd/xxhash_test.go b/src/internal/zstd/xxhash_test.go index c0682f420f3d0..e5638b6d0231e 100644 --- a/src/internal/zstd/xxhash_test.go +++ b/src/internal/zstd/xxhash_test.go @@ -89,7 +89,7 @@ func FuzzXXHash(f *testing.F) { f.Add(bytes.Repeat(buf.Bytes(), 64)) f.Add(bigData(f)) - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> cmd := exec.Command(xxhsum, "-H64") cmd.Stdin = bytes.NewReader(b) var hhsumHash bytes.Buffer diff --git a/src/internal/zstd/zstd_test.go b/src/internal/zstd/zstd_test.go index b34d499d5dc33..e7a2d11050516 100644 --- a/src/internal/zstd/zstd_test.go +++ b/src/internal/zstd/zstd_test.go @@ -113,7 +113,7 @@ var tests = []struct { func TestSamples(t *testing.T) { for _, test := range tests { test := test - t.Run(test.name, func { t | + t.Run(test.name, func { t -> r := NewReader(strings.NewReader(test.compressed)) got, err := io.ReadAll(r) if err != nil { @@ -132,7 +132,7 @@ func TestReset(t *testing.T) { r := NewReader(input) for _, test := range tests { test := test - t.Run(test.name, func { t | + t.Run(test.name, func { t -> input.Reset(test.compressed) r.Reset(input) got, err := io.ReadAll(r) @@ -283,7 +283,7 @@ func TestFileSamples(t *testing.T) { continue } - t.Run(name, func { t | + t.Run(name, func { t -> f, err := os.Open(filepath.Join("testdata", name)) if err != nil { t.Fatal(err) @@ -306,7 +306,7 @@ func TestFileSamples(t *testing.T) { func TestReaderBad(t *testing.T) { for i, s := range badStrings { - t.Run(fmt.Sprintf("badStrings#%d", i), func { t | + t.Run(fmt.Sprintf("badStrings#%d", i), func { t -> _, err := io.Copy(io.Discard, NewReader(strings.NewReader(s))) if err == nil { t.Error("expected error") diff --git a/src/io/fs/example_test.go b/src/io/fs/example_test.go index e6179bf6d13fd..bb72320e1b69c 100644 --- a/src/io/fs/example_test.go +++ b/src/io/fs/example_test.go @@ -15,7 +15,7 @@ func ExampleWalkDir() { root := "/usr/local/go/bin" fileSystem := os.DirFS(root) - fs.WalkDir(fileSystem, ".", func { path, d, err | + fs.WalkDir(fileSystem, ".", func { path, d, err -> if err != nil { log.Fatal(err) } diff --git a/src/io/fs/readdir.go b/src/io/fs/readdir.go index e831c7a90a7fa..80998187a17a5 100644 --- a/src/io/fs/readdir.go +++ b/src/io/fs/readdir.go @@ -43,7 +43,7 @@ func ReadDir(fsys FS, name string) ([]DirEntry, error) { } list, err := dir.ReadDir(-1) - slices.SortFunc(list, func { a, b | return bytealg.CompareString(a.Name(), b.Name()) }) + slices.SortFunc(list, func { a, b -> return bytealg.CompareString(a.Name(), b.Name()) }) return list, err } diff --git a/src/io/fs/readdir_test.go b/src/io/fs/readdir_test.go index 5f6a13bf5430d..c5e78e691c285 100644 --- a/src/io/fs/readdir_test.go +++ b/src/io/fs/readdir_test.go @@ -73,7 +73,7 @@ func TestFileInfoToDirEntry(t *testing.T) { for _, test := range tests { test := test - t.Run(test.path, func { t | + t.Run(test.path, func { t -> fi, err := Stat(testFs, test.path) if err != nil { t.Fatal(err) diff --git a/src/io/fs/walk_test.go b/src/io/fs/walk_test.go index 9f12a7e74982b..1249292eee67a 100644 --- a/src/io/fs/walk_test.go +++ b/src/io/fs/walk_test.go @@ -55,7 +55,7 @@ func walkTree(n *Node, path string, f func(path string, n *Node)) { func makeTree() FS { fsys := fstest.MapFS{} - walkTree(tree, tree.name, func { path, n | + walkTree(tree, tree.name, func { path, n -> if n.entries == nil { fsys[path] = &fstest.MapFile{} } else { @@ -70,7 +70,7 @@ func makeTree() FS { // are always accumulated, though. func mark(entry DirEntry, err error, errors *[]error, clear bool) error { name := entry.Name() - walkTree(tree, tree.name, func { path, n | if n.name == name { + walkTree(tree, tree.name, func { path, n -> if n.name == name { n.mark++ } }) if err != nil { @@ -109,7 +109,7 @@ func TestWalkDir(t *testing.T) { if len(errors) != 0 { t.Fatalf("unexpected errors: %s", errors) } - walkTree(tree, tree.name, func { path, n | + walkTree(tree, tree.name, func { path, n -> if n.mark != 1 { t.Errorf("node %s mark = %d; expected 1", path, n.mark) } @@ -130,7 +130,7 @@ func TestIssue51617(t *testing.T) { } defer os.Chmod(bad, 0700) // avoid errors on cleanup var saw []string - err := WalkDir(os.DirFS(dir), ".", func { path, d, err | + err := WalkDir(os.DirFS(dir), ".", func { path, d, err -> if err != nil { return filepath.SkipDir } diff --git a/src/io/io_test.go b/src/io/io_test.go index 6688a14e1ade5..fab27c85b8643 100644 --- a/src/io/io_test.go +++ b/src/io/io_test.go @@ -512,7 +512,7 @@ func TestOffsetWriter_Seek(t *testing.T) { w := NewOffsetWriter(tmpfile, 0) // Should throw error errWhence if whence is not valid - t.Run("errWhence", func { t | + t.Run("errWhence", func { t -> for _, whence := range []int{-3, -2, -1, 3, 4, 5} { var offset int64 = 0 gotOff, gotErr := w.Seek(offset, whence) @@ -524,7 +524,7 @@ func TestOffsetWriter_Seek(t *testing.T) { }) // Should throw error errOffset if offset is negative - t.Run("errOffset", func { t | + t.Run("errOffset", func { t -> for _, whence := range []int{SeekStart, SeekCurrent} { for offset := int64(-3); offset < 0; offset++ { gotOff, gotErr := w.Seek(offset, whence) @@ -537,7 +537,7 @@ func TestOffsetWriter_Seek(t *testing.T) { }) // Normal tests - t.Run("normal", func { t | + t.Run("normal", func { t -> tests := []struct { offset int64 whence int @@ -663,7 +663,7 @@ func TestOffsetWriter_Write(t *testing.T) { var name string name = "Write" - t.Run(name, func { t | + t.Run(name, func { t -> // Write directly (off: 0, at: 0) // Write content to file w, f := makeOffsetWriter(name) @@ -688,7 +688,7 @@ func TestOffsetWriter_Write(t *testing.T) { // Copy -> WriteTo -> Write // Note: strings.Reader implements the io.WriterTo interface. name = "Write_Of_Copy_WriteTo" - t.Run(name, func { t | + t.Run(name, func { t -> w, f := makeOffsetWriter(name) defer f.Close() Copy(w, strings.NewReader(content)) diff --git a/src/io/ioutil/ioutil.go b/src/io/ioutil/ioutil.go index 6fc8f8a6e1b11..206e233b695db 100644 --- a/src/io/ioutil/ioutil.go +++ b/src/io/ioutil/ioutil.go @@ -77,7 +77,7 @@ func ReadDir(dirname string) ([]fs.FileInfo, error) { if err != nil { return nil, err } - slices.SortFunc(list, func { a, b | return strings.Compare(a.Name(), b.Name()) }) + slices.SortFunc(list, func { a, b -> return strings.Compare(a.Name(), b.Name()) }) return list, nil } diff --git a/src/io/ioutil/tempfile_test.go b/src/io/ioutil/tempfile_test.go index 4ae015f45e620..1c703e2fde585 100644 --- a/src/io/ioutil/tempfile_test.go +++ b/src/io/ioutil/tempfile_test.go @@ -74,7 +74,7 @@ func TestTempFile_BadPattern(t *testing.T) { {"ioutil_test*foo" + sep, true}, } for _, tt := range tests { - t.Run(tt.pattern, func { t | + t.Run(tt.pattern, func { t -> tmpfile, err := TempFile(tmpDir, tt.pattern) defer func() { if tmpfile != nil { @@ -125,7 +125,7 @@ func TestTempDir(t *testing.T) { } for _, tt := range tests { - t.Run(tt.pattern, func { t | + t.Run(tt.pattern, func { t -> wantRePat := "^" + regexp.QuoteMeta(filepath.Join(dir, tt.wantPrefix)) + "[0-9]+" + regexp.QuoteMeta(tt.wantSuffix) + "$" runTestTempDir(t, tt.pattern, wantRePat) }) @@ -137,7 +137,7 @@ func TestTempDir(t *testing.T) { // ^[0-9]+xyz$ // yet we just want to match // "^/[0-9]+xyz" - t.Run("*xyz", func { t | + t.Run("*xyz", func { t -> wantRePat := "^" + regexp.QuoteMeta(filepath.Join(dir)) + regexp.QuoteMeta(string(filepath.Separator)) + "[0-9]+xyz$" runTestTempDir(t, "*xyz", wantRePat) }) @@ -180,7 +180,7 @@ func TestTempDir_BadPattern(t *testing.T) { {"ioutil_test*foo" + sep, true}, } for _, tt := range tests { - t.Run(tt.pattern, func { t | + t.Run(tt.pattern, func { t -> _, err := TempDir(tmpDir, tt.pattern) if tt.wantErr { if err == nil { diff --git a/src/io/multi_test.go b/src/io/multi_test.go index 1c46aa63e2141..989c65baf42be 100644 --- a/src/io/multi_test.go +++ b/src/io/multi_test.go @@ -179,7 +179,7 @@ func TestMultiWriterSingleChainFlatten(t *testing.T) { n := runtime.Callers(0, pc) var myDepth = callDepth(pc[:n]) var writeDepth int // will contain the depth from which writerFunc.Writer was called - var w Writer = MultiWriter(writerFunc(func { p | + var w Writer = MultiWriter(writerFunc(func { p -> n := runtime.Callers(1, pc) writeDepth += callDepth(pc[:n]) return 0, nil @@ -201,8 +201,8 @@ func TestMultiWriterSingleChainFlatten(t *testing.T) { } func TestMultiWriterError(t *testing.T) { - f1 := writerFunc(func { p | return len(p) / 2, ErrShortWrite }) - f2 := writerFunc(func { p | + f1 := writerFunc(func { p -> return len(p) / 2, ErrShortWrite }) + f2 := writerFunc(func { p -> t.Errorf("MultiWriter called f2.Write") return len(p), nil }) @@ -263,7 +263,7 @@ func TestMultiReaderFlatten(t *testing.T) { n := runtime.Callers(0, pc) var myDepth = callDepth(pc[:n]) var readDepth int // will contain the depth from which fakeReader.Read was called - var r Reader = MultiReader(readerFunc(func { p | + var r Reader = MultiReader(readerFunc(func { p -> n := runtime.Callers(1, pc) readDepth = callDepth(pc[:n]) return 0, errors.New("irrelevant") diff --git a/src/io/pipe_test.go b/src/io/pipe_test.go index 8e3ee5c675581..7c7b1993eda6a 100644 --- a/src/io/pipe_test.go +++ b/src/io/pipe_test.go @@ -348,7 +348,7 @@ func TestPipeConcurrent(t *testing.T) { readSize = 2 ) - t.Run("Write", func { t | + t.Run("Write", func { t -> r, w := Pipe() for i := 0; i < count; i++ { @@ -376,7 +376,7 @@ func TestPipeConcurrent(t *testing.T) { } }) - t.Run("Read", func { t | + t.Run("Read", func { t -> r, w := Pipe() c := make(chan []byte, count*len(input)/readSize) diff --git a/src/iter/iter.go b/src/iter/iter.go index 418c761251d50..c033b61dd0966 100644 --- a/src/iter/iter.go +++ b/src/iter/iter.go @@ -248,7 +248,7 @@ func Pull[V any](seq Seq[V]) (next func() (V, bool), stop func()) { panicValue any seqDone bool // to detect Goexit ) - c := newcoro(func { c | + c := newcoro(func { c -> race.Acquire(unsafe.Pointer(&racer)) if done { race.Release(unsafe.Pointer(&racer)) @@ -364,7 +364,7 @@ func Pull2[K, V any](seq Seq2[K, V]) (next func() (K, V, bool), stop func()) { panicValue any seqDone bool ) - c := newcoro(func { c | + c := newcoro(func { c -> race.Acquire(unsafe.Pointer(&racer)) if done { race.Release(unsafe.Pointer(&racer)) diff --git a/src/iter/pull_test.go b/src/iter/pull_test.go index 845f5bfafcfb1..586f28e92e29e 100644 --- a/src/iter/pull_test.go +++ b/src/iter/pull_test.go @@ -33,7 +33,7 @@ func squares(n int) Seq2[int, int64] { func TestPull(t *testing.T) { for end := 0; end <= 3; end++ { - t.Run(fmt.Sprint(end), func { t | + t.Run(fmt.Sprint(end), func { t -> ng := stableNumGoroutine() wantNG := func(want int) { if xg := runtime.NumGoroutine() - ng; xg != want { @@ -75,7 +75,7 @@ func TestPull(t *testing.T) { func TestPull2(t *testing.T) { for end := 0; end <= 3; end++ { - t.Run(fmt.Sprint(end), func { t | + t.Run(fmt.Sprint(end), func { t -> ng := stableNumGoroutine() wantNG := func(want int) { if xg := runtime.NumGoroutine() - ng; xg != want { @@ -243,7 +243,7 @@ func storeYield2() Seq2[int, int] { var yieldSlot2 func(int, int) bool func TestPullPanic(t *testing.T) { - t.Run("next", func { t | + t.Run("next", func { t -> next, stop := Pull(panicSeq()) if !panicsWith("boom", func() { next() }) { t.Fatal("failed to propagate panic on first next") @@ -255,7 +255,7 @@ func TestPullPanic(t *testing.T) { // Calling stop again should be a no-op. stop() }) - t.Run("stop", func { t | + t.Run("stop", func { t -> next, stop := Pull(panicCleanupSeq()) x, ok := next() if !ok || x != 55 { @@ -290,7 +290,7 @@ func panicCleanupSeq() Seq[int] { } func TestPull2Panic(t *testing.T) { - t.Run("next", func { t | + t.Run("next", func { t -> next, stop := Pull2(panicSeq2()) if !panicsWith("boom", func() { next() }) { t.Fatal("failed to propagate panic on first next") @@ -302,7 +302,7 @@ func TestPull2Panic(t *testing.T) { // Calling stop again should be a no-op. stop() }) - t.Run("stop", func { t | + t.Run("stop", func { t -> next, stop := Pull2(panicCleanupSeq2()) x, y, ok := next() if !ok || x != 55 || y != 100 { @@ -350,7 +350,7 @@ func panicsWith(v any, f func()) (panicked bool) { } func TestPullGoexit(t *testing.T) { - t.Run("next", func { t | + t.Run("next", func { t -> var next func() (int, bool) var stop func() if !goexits(t, func() { @@ -364,7 +364,7 @@ func TestPullGoexit(t *testing.T) { } stop() }) - t.Run("stop", func { t | + t.Run("stop", func { t -> next, stop := Pull(goexitCleanupSeq()) x, ok := next() if !ok || x != 55 { @@ -401,7 +401,7 @@ func goexitCleanupSeq() Seq[int] { } func TestPull2Goexit(t *testing.T) { - t.Run("next", func { t | + t.Run("next", func { t -> var next func() (int, int, bool) var stop func() if !goexits(t, func() { @@ -415,7 +415,7 @@ func TestPull2Goexit(t *testing.T) { } stop() }) - t.Run("stop", func { t | + t.Run("stop", func { t -> next, stop := Pull2(goexitCleanupSeq2()) x, y, ok := next() if !ok || x != 55 || y != 100 { diff --git a/src/log/log.go b/src/log/log.go index 12f6e4c002fcd..3dd7115d1c29d 100644 --- a/src/log/log.go +++ b/src/log/log.go @@ -192,7 +192,7 @@ func putBuffer(p *[]byte) { // paths it will be 2. func (l *Logger) Output(calldepth int, s string) error { calldepth++ // +1 for this frame. - return l.output(0, calldepth, func { b | return append(b, s...) }) + return l.output(0, calldepth, func { b -> return append(b, s...) }) } // output can take either a calldepth or a pc to get source line information. @@ -245,25 +245,25 @@ func (l *Logger) output(pc uintptr, calldepth int, appendOutput func([]byte) []b } func init() { - internal.DefaultOutput = func { pc, data | return std.output(pc, 0, func { buf | return append(buf, data...) }) } + internal.DefaultOutput = func { pc, data -> return std.output(pc, 0, func { buf -> return append(buf, data...) }) } } // Print calls l.Output to print to the logger. // Arguments are handled in the manner of [fmt.Print]. func (l *Logger) Print(v ...any) { - l.output(0, 2, func { b | return fmt.Append(b, v...) }) + l.output(0, 2, func { b -> return fmt.Append(b, v...) }) } // Printf calls l.Output to print to the logger. // Arguments are handled in the manner of [fmt.Printf]. func (l *Logger) Printf(format string, v ...any) { - l.output(0, 2, func { b | return fmt.Appendf(b, format, v...) }) + l.output(0, 2, func { b -> return fmt.Appendf(b, format, v...) }) } // Println calls l.Output to print to the logger. // Arguments are handled in the manner of [fmt.Println]. func (l *Logger) Println(v ...any) { - l.output(0, 2, func { b | return fmt.Appendln(b, v...) }) + l.output(0, 2, func { b -> return fmt.Appendln(b, v...) }) } // Fatal is equivalent to l.Print() followed by a call to [os.Exit](1). @@ -374,19 +374,19 @@ func Writer() io.Writer { // Print calls Output to print to the standard logger. // Arguments are handled in the manner of [fmt.Print]. func Print(v ...any) { - std.output(0, 2, func { b | return fmt.Append(b, v...) }) + std.output(0, 2, func { b -> return fmt.Append(b, v...) }) } // Printf calls Output to print to the standard logger. // Arguments are handled in the manner of [fmt.Printf]. func Printf(format string, v ...any) { - std.output(0, 2, func { b | return fmt.Appendf(b, format, v...) }) + std.output(0, 2, func { b -> return fmt.Appendf(b, format, v...) }) } // Println calls Output to print to the standard logger. // Arguments are handled in the manner of [fmt.Println]. func Println(v ...any) { - std.output(0, 2, func { b | return fmt.Appendln(b, v...) }) + std.output(0, 2, func { b -> return fmt.Appendln(b, v...) }) } // Fatal is equivalent to [Print] followed by a call to [os.Exit](1). diff --git a/src/log/slog/handler.go b/src/log/slog/handler.go index 66a61057d3e65..12b89f19d10d1 100644 --- a/src/log/slog/handler.go +++ b/src/log/slog/handler.go @@ -338,7 +338,7 @@ func (s *handleState) appendNonBuiltIns(r Record) { s.openGroups() nOpenGroups = len(s.h.groups) empty := true - r.Attrs(func { a | + r.Attrs(func { a -> if s.appendAttr(a) { empty = false } diff --git a/src/log/slog/handler_test.go b/src/log/slog/handler_test.go index 12f7334f24e11..06af77c8188ce 100644 --- a/src/log/slog/handler_test.go +++ b/src/log/slog/handler_test.go @@ -85,9 +85,9 @@ func TestDefaultHandle(t *testing.T) { want: "INFO message p1=1 s1.s2.a=1 s1.s2.b=two", }, } { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> var got string - var h Handler = newDefaultHandler(func { _, b | + var h Handler = newDefaultHandler(func { _, b -> got = string(b) return nil }) @@ -110,7 +110,7 @@ func TestConcurrentWrites(t *testing.T) { ctx := context.Background() count := 1000 for _, handlerType := range []string{"text", "json"} { - t.Run(handlerType, func { t | + t.Run(handlerType, func { t -> var buf bytes.Buffer var h Handler switch handlerType { @@ -534,7 +534,7 @@ func TestJSONAndTextHandlers(t *testing.T) { r.AddAttrs(test.attrs...) var buf bytes.Buffer opts := HandlerOptions{ReplaceAttr: test.replace, AddSource: test.addSource} - t.Run(test.name, func { t | + t.Run(test.name, func { t -> for _, handler := range []struct { name string h Handler @@ -543,7 +543,7 @@ func TestJSONAndTextHandlers(t *testing.T) { {"text", NewTextHandler(&buf, &opts), test.wantText}, {"json", NewJSONHandler(&buf, &opts), test.wantJSON}, } { - t.Run(handler.name, func { t | + t.Run(handler.name, func { t -> h := handler.h if test.with != nil { h = test.with(h) diff --git a/src/log/slog/internal/benchmarks/benchmarks_test.go b/src/log/slog/internal/benchmarks/benchmarks_test.go index 5571898f3826e..6a1c67d9706e2 100644 --- a/src/log/slog/internal/benchmarks/benchmarks_test.go +++ b/src/log/slog/internal/benchmarks/benchmarks_test.go @@ -36,7 +36,7 @@ func BenchmarkAttrs(b *testing.B) { {"JSON discard", slog.NewJSONHandler(io.Discard, nil), false}, } { logger := slog.New(handler.h) - b.Run(handler.name, func { b | + b.Run(handler.name, func { b -> if handler.skipRace && race.Enabled { b.Skip("skipping benchmark in race mode") } @@ -138,9 +138,9 @@ func BenchmarkAttrs(b *testing.B) { }, }, } { - b.Run(call.name, func { b | + b.Run(call.name, func { b -> b.ReportAllocs() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { call.f() } }) }) diff --git a/src/log/slog/internal/benchmarks/handlers.go b/src/log/slog/internal/benchmarks/handlers.go index 8f3270eeafcb0..f6431d0629f69 100644 --- a/src/log/slog/internal/benchmarks/handlers.go +++ b/src/log/slog/internal/benchmarks/handlers.go @@ -47,7 +47,7 @@ func (h *fastTextHandler) Handle(_ context.Context, r slog.Record) error { buf.WriteByte(' ') buf.WriteString("msg=") buf.WriteString(r.Message) - r.Attrs(func { a | + r.Attrs(func { a -> buf.WriteByte(' ') buf.WriteString(a.Key) buf.WriteByte('=') diff --git a/src/log/slog/internal/benchmarks/handlers_test.go b/src/log/slog/internal/benchmarks/handlers_test.go index 5c641b72c3684..3096e5397edb6 100644 --- a/src/log/slog/internal/benchmarks/handlers_test.go +++ b/src/log/slog/internal/benchmarks/handlers_test.go @@ -16,7 +16,7 @@ func TestHandlers(t *testing.T) { ctx := context.Background() r := slog.NewRecord(testTime, slog.LevelInfo, testMessage, 0) r.AddAttrs(testAttrs...) - t.Run("text", func { t | + t.Run("text", func { t -> var b bytes.Buffer h := newFastTextHandler(&b) if err := h.Handle(ctx, r); err != nil { @@ -27,7 +27,7 @@ func TestHandlers(t *testing.T) { t.Errorf("\ngot %q\nwant %q", got, wantText) } }) - t.Run("async", func { t | + t.Run("async", func { t -> h := newAsyncHandler() if err := h.Handle(ctx, r); err != nil { t.Fatal(err) @@ -41,7 +41,7 @@ func TestHandlers(t *testing.T) { func attrSlice(r slog.Record) []slog.Attr { var as []slog.Attr - r.Attrs(func { a | + r.Attrs(func { a -> as = append(as, a) return true }) diff --git a/src/log/slog/json_handler_test.go b/src/log/slog/json_handler_test.go index a8c00e689a5eb..b044de74261fd 100644 --- a/src/log/slog/json_handler_test.go +++ b/src/log/slog/json_handler_test.go @@ -37,7 +37,7 @@ func TestJSONHandler(t *testing.T) { `{"TIME":"2000-01-02T03:04:05Z","LEVEL":"INFO","MSG":"m","A":1,"M":{"b":2}}`, }, } { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> var buf bytes.Buffer h := NewJSONHandler(&buf, &test.opts) r := NewRecord(testTime, LevelInfo, "m", 0) @@ -173,7 +173,7 @@ func BenchmarkJSONHandler(b *testing.B) { }, }}, } { - b.Run(bench.name, func { b | + b.Run(bench.name, func { b -> ctx := context.Background() l := New(NewJSONHandler(io.Discard, &bench.opts)).With( String("program", "my-test-program"), @@ -240,7 +240,7 @@ func BenchmarkPreformatting(b *testing.B) { {"struct file", outFile, structAttrs}, } { ctx := context.Background() - b.Run(bench.name, func { b | + b.Run(bench.name, func { b -> l := New(NewJSONHandler(bench.wc, nil)).With(bench.attrs...) b.ReportAllocs() b.ResetTimer() @@ -260,7 +260,7 @@ func BenchmarkJSONEncoding(b *testing.B) { value := 3.14 buf := buffer.New() defer buf.Free() - b.Run("json.Marshal", func { b | + b.Run("json.Marshal", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { by, err := json.Marshal(value) @@ -271,7 +271,7 @@ func BenchmarkJSONEncoding(b *testing.B) { *buf = (*buf)[:0] } }) - b.Run("Encoder.Encode", func { b | + b.Run("Encoder.Encode", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { if err := json.NewEncoder(buf).Encode(value); err != nil { diff --git a/src/log/slog/logger_test.go b/src/log/slog/logger_test.go index 7f38abe10caf0..92a6957cc32f3 100644 --- a/src/log/slog/logger_test.go +++ b/src/log/slog/logger_test.go @@ -111,7 +111,7 @@ func TestConnections(t *testing.T) { Debug("msg", "c", 3) checkLogOutput(t, logbuf.String(), "") - t.Run("wrap default handler", func { t | + t.Run("wrap default handler", func { t -> // It should be possible to wrap the default handler and get the right output. // This works because the default handler uses the pc in the Record // to get the source line, rather than a call depth. @@ -233,11 +233,11 @@ func TestAlloc(t *testing.T) { defer SetDefault(Default()) // restore SetDefault(dl) - t.Run("Info", func { t | wantAllocs(t, 0, func() { Info("hello") }) }) - t.Run("Error", func { t | wantAllocs(t, 0, func() { Error("hello") }) }) - t.Run("logger.Info", func { t | wantAllocs(t, 0, func() { dl.Info("hello") }) }) - t.Run("logger.Log", func { t | wantAllocs(t, 0, func() { dl.Log(ctx, LevelDebug, "hello") }) }) - t.Run("2 pairs", func { t | + t.Run("Info", func { t -> wantAllocs(t, 0, func() { Info("hello") }) }) + t.Run("Error", func { t -> wantAllocs(t, 0, func() { Error("hello") }) }) + t.Run("logger.Info", func { t -> wantAllocs(t, 0, func() { dl.Info("hello") }) }) + t.Run("logger.Log", func { t -> wantAllocs(t, 0, func() { dl.Log(ctx, LevelDebug, "hello") }) }) + t.Run("2 pairs", func { t -> s := "abc" i := 2000 wantAllocs(t, 2, func() { @@ -247,7 +247,7 @@ func TestAlloc(t *testing.T) { ) }) }) - t.Run("2 pairs disabled inline", func { t | + t.Run("2 pairs disabled inline", func { t -> l := New(discardHandler{disabled: true}) s := "abc" i := 2000 @@ -258,7 +258,7 @@ func TestAlloc(t *testing.T) { ) }) }) - t.Run("2 pairs disabled", func { t | + t.Run("2 pairs disabled", func { t -> l := New(discardHandler{disabled: true}) s := "abc" i := 2000 @@ -271,7 +271,7 @@ func TestAlloc(t *testing.T) { } }) }) - t.Run("9 kvs", func { t | + t.Run("9 kvs", func { t -> s := "abc" i := 2000 d := time.Second @@ -282,30 +282,30 @@ func TestAlloc(t *testing.T) { "n", i, "s", s, "d", d) }) }) - t.Run("pairs", func { t | wantAllocs(t, 0, func() { dl.Info("", "error", io.EOF) }) }) - t.Run("attrs1", func { t | + t.Run("pairs", func { t -> wantAllocs(t, 0, func() { dl.Info("", "error", io.EOF) }) }) + t.Run("attrs1", func { t -> wantAllocs(t, 0, func() { dl.LogAttrs(ctx, LevelInfo, "", Int("a", 1)) }) wantAllocs(t, 0, func() { dl.LogAttrs(ctx, LevelInfo, "", Any("error", io.EOF)) }) }) - t.Run("attrs3", func { t | + t.Run("attrs3", func { t -> wantAllocs(t, 0, func() { dl.LogAttrs(ctx, LevelInfo, "hello", Int("a", 1), String("b", "two"), Duration("c", time.Second)) }) }) - t.Run("attrs3 disabled", func { t | + t.Run("attrs3 disabled", func { t -> logger := New(discardHandler{disabled: true}) wantAllocs(t, 0, func() { logger.LogAttrs(ctx, LevelInfo, "hello", Int("a", 1), String("b", "two"), Duration("c", time.Second)) }) }) - t.Run("attrs6", func { t | + t.Run("attrs6", func { t -> wantAllocs(t, 1, func() { dl.LogAttrs(ctx, LevelInfo, "hello", Int("a", 1), String("b", "two"), Duration("c", time.Second), Int("d", 1), String("e", "two"), Duration("f", time.Second)) }) }) - t.Run("attrs9", func { t | + t.Run("attrs9", func { t -> wantAllocs(t, 1, func() { dl.LogAttrs(ctx, LevelInfo, "hello", Int("a", 1), String("b", "two"), Duration("c", time.Second), @@ -584,41 +584,41 @@ func concat[T any](s1, s2 []T) []T { func BenchmarkNopLog(b *testing.B) { ctx := context.Background() l := New(&captureHandler{}) - b.Run("no attrs", func { b | + b.Run("no attrs", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { l.LogAttrs(ctx, LevelInfo, "msg") } }) - b.Run("attrs", func { b | + b.Run("attrs", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { l.LogAttrs(ctx, LevelInfo, "msg", Int("a", 1), String("b", "two"), Bool("c", true)) } }) - b.Run("attrs-parallel", func { b | + b.Run("attrs-parallel", func { b -> b.ReportAllocs() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { l.LogAttrs(ctx, LevelInfo, "msg", Int("a", 1), String("b", "two"), Bool("c", true)) } }) }) - b.Run("keys-values", func { b | + b.Run("keys-values", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { l.Log(ctx, LevelInfo, "msg", "a", 1, "b", "two", "c", true) } }) - b.Run("WithContext", func { b | + b.Run("WithContext", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { l.LogAttrs(ctx, LevelInfo, "msg2", Int("a", 1), String("b", "two"), Bool("c", true)) } }) - b.Run("WithContext-parallel", func { b | + b.Run("WithContext-parallel", func { b -> b.ReportAllocs() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { l.LogAttrs(ctx, LevelInfo, "msg", Int("a", 1), String("b", "two"), Bool("c", true)) } diff --git a/src/log/slog/record_test.go b/src/log/slog/record_test.go index b0987bc87d6f6..5baf9a88e52f8 100644 --- a/src/log/slog/record_test.go +++ b/src/log/slog/record_test.go @@ -27,7 +27,7 @@ func TestRecordAttrs(t *testing.T) { // Hit both loops in Record.Attrs: front and back. for _, stop := range []int{2, 6} { var got []Attr - r.Attrs(func { a | + r.Attrs(func { a -> got = append(got, a) return len(got) < stop }) @@ -121,7 +121,7 @@ func newRecordWithAttrs(as []Attr) Record { func attrsSlice(r Record) []Attr { s := make([]Attr, 0, r.NumAttrs()) - r.Attrs(func { a | + r.Attrs(func { a -> s = append(s, a) return true }) @@ -136,7 +136,7 @@ func attrsEqual(as1, as2 []Attr) bool { // to call it for every log message. func BenchmarkPC(b *testing.B) { for depth := 0; depth < 5; depth++ { - b.Run(strconv.Itoa(depth), func { b | + b.Run(strconv.Itoa(depth), func { b -> b.ReportAllocs() var x uintptr for i := 0; i < b.N; i++ { @@ -156,7 +156,7 @@ func BenchmarkRecord(b *testing.B) { for j := 0; j < nAttrs; j++ { r.AddAttrs(Int("k", j)) } - r.Attrs(func { b | + r.Attrs(func { b -> a = b return true }) diff --git a/src/log/slog/slogtest_test.go b/src/log/slog/slogtest_test.go index 5bfc28d38736c..19483c9774e59 100644 --- a/src/log/slog/slogtest_test.go +++ b/src/log/slog/slogtest_test.go @@ -24,7 +24,7 @@ func TestSlogtest(t *testing.T) { {"JSON", func(w io.Writer) slog.Handler { return slog.NewJSONHandler(w, nil) }, parseJSON}, {"Text", func(w io.Writer) slog.Handler { return slog.NewTextHandler(w, nil) }, parseText}, } { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> var buf bytes.Buffer h := test.new(&buf) results := func { diff --git a/src/log/slog/text_handler_test.go b/src/log/slog/text_handler_test.go index 9c74393bc68a5..4f57a0eb75edd 100644 --- a/src/log/slog/text_handler_test.go +++ b/src/log/slog/text_handler_test.go @@ -60,7 +60,7 @@ func TestTextHandler(t *testing.T) { `a`, ``, }, } { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> for _, opts := range []struct { name string opts HandlerOptions @@ -80,7 +80,7 @@ func TestTextHandler(t *testing.T) { strings.ToUpper, }, } { - t.Run(opts.name, func { t | + t.Run(opts.name, func { t -> var buf bytes.Buffer h := NewTextHandler(&buf, &opts.opts) r := NewRecord(testTime, LevelInfo, "a message", 0) diff --git a/src/log/slog/value_access_benchmark_test.go b/src/log/slog/value_access_benchmark_test.go index 583f064a4966f..11bbb17a83754 100644 --- a/src/log/slog/value_access_benchmark_test.go +++ b/src/log/slog/value_access_benchmark_test.go @@ -35,7 +35,7 @@ func BenchmarkDispatch(b *testing.B) { f float64 a any ) - b.Run("switch-checked", func { b | + b.Run("switch-checked", func { b -> for i := 0; i < b.N; i++ { for _, v := range vs { switch v.Kind() { @@ -66,7 +66,7 @@ func BenchmarkDispatch(b *testing.B) { _ = f _ = a }) - b.Run("As", func { b | + b.Run("As", func { b -> for i := 0; i < b.N; i++ { for _, kv := range vs { if v, ok := kv.AsString(); ok { @@ -97,7 +97,7 @@ func BenchmarkDispatch(b *testing.B) { _ = a }) - b.Run("Visit", func { b | + b.Run("Visit", func { b -> v := &setVisitor{} b.ResetTimer() for i := 0; i < b.N; i++ { diff --git a/src/log/syslog/syslog_test.go b/src/log/syslog/syslog_test.go index a1615cbfa4db0..342b378508981 100644 --- a/src/log/syslog/syslog_test.go +++ b/src/log/syslog/syslog_test.go @@ -146,7 +146,7 @@ func TestWithSimulated(t *testing.T) { } tr := tr - t.Run(tr, func { t | + t.Run(tr, func { t -> t.Parallel() done := make(chan string) diff --git a/src/maps/example_test.go b/src/maps/example_test.go index d1f7264981f08..6eaa8f182bc2b 100644 --- a/src/maps/example_test.go +++ b/src/maps/example_test.go @@ -83,7 +83,7 @@ func ExampleDeleteFunc() { "three": 3, "four": 4, } - maps.DeleteFunc(m, func { k, v | return v%2 != 0 })// delete odd values + maps.DeleteFunc(m, func { k, v -> return v%2 != 0 })// delete odd values fmt.Println(m) // Output: @@ -125,7 +125,7 @@ func ExampleEqualFunc() { 10: []byte("Ten"), 1000: []byte("Thousand"), } - eq := maps.EqualFunc(m1, m2, func { v1, v2 | return strings.ToLower(v1) == strings.ToLower(string(v2)) }) + eq := maps.EqualFunc(m1, m2, func { v1, v2 -> return strings.ToLower(v1) == strings.ToLower(string(v2)) }) fmt.Println(eq) // Output: // true diff --git a/src/maps/iter_test.go b/src/maps/iter_test.go index c4f461d133f46..8dbcd732aef71 100644 --- a/src/maps/iter_test.go +++ b/src/maps/iter_test.go @@ -74,7 +74,7 @@ func TestInsert(t *testing.T) { 1: 1, 2: 1, } - Insert(got, func { yield | for i := 0; i < 10; i += 2 { + Insert(got, func { yield -> for i := 0; i < 10; i += 2 { if !yield(i, i+1) { return } diff --git a/src/maps/maps_test.go b/src/maps/maps_test.go index 202118eab8377..c870f1c83d6fb 100644 --- a/src/maps/maps_test.go +++ b/src/maps/maps_test.go @@ -127,7 +127,7 @@ func TestDeleteFunc(t *testing.T) { if !Equal(mc, m1) { t.Errorf("DeleteFunc(%v, true) = %v, want %v", m1, mc, m1) } - DeleteFunc(mc, func { k, v | return k > 3 }) + DeleteFunc(mc, func { k, v -> return k > 3 }) want := map[int]int{1: 2, 2: 4} if !Equal(mc, want) { t.Errorf("DeleteFunc result = %v, want %v", mc, want) diff --git a/src/math/big/alias_test.go b/src/math/big/alias_test.go index 3a7b92964d722..fa8f6bdc9a301 100644 --- a/src/math/big/alias_test.go +++ b/src/math/big/alias_test.go @@ -196,33 +196,33 @@ func TestAliasing(t *testing.T) { return checkAliasingTwoArgs(t, (*big.Int).Div, v.Int, x.Int, y.Int) }, "Exp-XY": func(v, x, y bigInt, z notZeroInt) bool { - return checkAliasingTwoArgs(t, func { v, x, y | return v.Exp(x, y, z.Int) }, v.Int, x.Int, y.Int) + return checkAliasingTwoArgs(t, func { v, x, y -> return v.Exp(x, y, z.Int) }, v.Int, x.Int, y.Int) }, "Exp-XZ": func(v, x, y bigInt, z notZeroInt) bool { - return checkAliasingTwoArgs(t, func { v, x, z | return v.Exp(x, y.Int, z) }, v.Int, x.Int, z.Int) + return checkAliasingTwoArgs(t, func { v, x, z -> return v.Exp(x, y.Int, z) }, v.Int, x.Int, z.Int) }, "Exp-YZ": func(v, x, y bigInt, z notZeroInt) bool { - return checkAliasingTwoArgs(t, func { v, y, z | return v.Exp(x.Int, y, z) }, v.Int, y.Int, z.Int) + return checkAliasingTwoArgs(t, func { v, y, z -> return v.Exp(x.Int, y, z) }, v.Int, y.Int, z.Int) }, "GCD": func(v, x, y bigInt) bool { - return checkAliasingTwoArgs(t, func { v, x, y | return v.GCD(nil, nil, x, y) }, v.Int, x.Int, y.Int) + return checkAliasingTwoArgs(t, func { v, x, y -> return v.GCD(nil, nil, x, y) }, v.Int, x.Int, y.Int) }, "GCD-X": func(v, x, y bigInt) bool { a, b := new(big.Int), new(big.Int) - return checkAliasingTwoArgs(t, func { v, x, y | + return checkAliasingTwoArgs(t, func { v, x, y -> a.GCD(v, b, x, y) return v }, v.Int, x.Int, y.Int) }, "GCD-Y": func(v, x, y bigInt) bool { a, b := new(big.Int), new(big.Int) - return checkAliasingTwoArgs(t, func { v, x, y | + return checkAliasingTwoArgs(t, func { v, x, y -> a.GCD(b, v, x, y) return v }, v.Int, x.Int, y.Int) }, "Lsh": func(v, x bigInt, n smallUint) bool { - return checkAliasingOneArg(t, func { v, x | return v.Lsh(x, n.uint) }, v.Int, x.Int) + return checkAliasingOneArg(t, func { v, x -> return v.Lsh(x, n.uint) }, v.Int, x.Int) }, "Mod": func(v, x bigInt, y notZeroInt) bool { return checkAliasingTwoArgs(t, (*big.Int).Mod, v.Int, x.Int, y.Int) @@ -249,7 +249,7 @@ func TestAliasing(t *testing.T) { return checkAliasingTwoArgs(t, (*big.Int).Quo, v.Int, x.Int, y.Int) }, "Rand": func(v, x bigInt, seed int64) bool { - return checkAliasingOneArg(t, func { v, x | + return checkAliasingOneArg(t, func { v, x -> rnd := rand.New(rand.NewSource(seed)) return v.Rand(rnd, x) }, v.Int, x.Int) @@ -258,13 +258,13 @@ func TestAliasing(t *testing.T) { return checkAliasingTwoArgs(t, (*big.Int).Rem, v.Int, x.Int, y.Int) }, "Rsh": func(v, x bigInt, n smallUint) bool { - return checkAliasingOneArg(t, func { v, x | return v.Rsh(x, n.uint) }, v.Int, x.Int) + return checkAliasingOneArg(t, func { v, x -> return v.Rsh(x, n.uint) }, v.Int, x.Int) }, "Set": func(v, x bigInt) bool { return checkAliasingOneArg(t, (*big.Int).Set, v.Int, x.Int) }, "SetBit": func(v, x bigInt, i smallUint, b zeroOrOne) bool { - return checkAliasingOneArg(t, func { v, x | return v.SetBit(x, int(i.uint), b.uint) }, v.Int, x.Int) + return checkAliasingOneArg(t, func { v, x -> return v.SetBit(x, int(i.uint), b.uint) }, v.Int, x.Int) }, "Sqrt": func(v bigInt, x positiveInt) bool { return checkAliasingOneArg(t, (*big.Int).Sqrt, v.Int, x.Int) @@ -276,7 +276,7 @@ func TestAliasing(t *testing.T) { return checkAliasingTwoArgs(t, (*big.Int).Xor, v.Int, x.Int, y.Int) }, } { - t.Run(name, func { t | + t.Run(name, func { t -> scale := 1.0 switch name { case "ModInverse", "GCD-Y", "GCD-X": diff --git a/src/math/big/arith_test.go b/src/math/big/arith_test.go index 77abcb2daace1..5c5d0b9cfbd3a 100644 --- a/src/math/big/arith_test.go +++ b/src/math/big/arith_test.go @@ -92,7 +92,7 @@ func BenchmarkAddVV(b *testing.B) { x := rndV(n) y := rndV(n) z := make([]Word, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _W)) for i := 0; i < b.N; i++ { addVV(z, x, y) @@ -109,7 +109,7 @@ func BenchmarkSubVV(b *testing.B) { x := rndV(n) y := rndV(n) z := make([]Word, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _W)) for i := 0; i < b.N; i++ { subVV(z, x, y) @@ -400,7 +400,7 @@ func BenchmarkAddVW(b *testing.B) { x := rndV(n) y := rndW() z := make([]Word, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _S)) for i := 0; i < b.N; i++ { addVW(z, x, y) @@ -418,7 +418,7 @@ func BenchmarkAddVWext(b *testing.B) { y := ^Word(0) x := makeWordVec(y, n) z := make([]Word, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _S)) for i := 0; i < b.N; i++ { addVW(z, x, y) @@ -435,7 +435,7 @@ func BenchmarkSubVW(b *testing.B) { x := rndV(n) y := rndW() z := make([]Word, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _S)) for i := 0; i < b.N; i++ { subVW(z, x, y) @@ -453,7 +453,7 @@ func BenchmarkSubVWext(b *testing.B) { x := makeWordVec(0, n) y := Word(1) z := make([]Word, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _S)) for i := 0; i < b.N; i++ { subVW(z, x, y) @@ -630,7 +630,7 @@ func BenchmarkMulAddVWW(b *testing.B) { x := rndV(n) y := rndW() r := rndW() - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _W)) for i := 0; i < b.N; i++ { mulAddVWW(z, x, y, r) @@ -647,7 +647,7 @@ func BenchmarkAddMulVVW(b *testing.B) { x := rndV(n) y := rndW() z := make([]Word, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _W)) for i := 0; i < b.N; i++ { addMulVVW(z, x, y) @@ -663,7 +663,7 @@ func BenchmarkDivWVW(b *testing.B) { x := rndV(n) y := rndW() z := make([]Word, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _W)) for i := 0; i < b.N; i++ { divWVW(z, 0, x, y) @@ -680,12 +680,12 @@ func BenchmarkNonZeroShifts(b *testing.B) { x := rndV(n) s := uint(rand.Int63n(_W-2)) + 1 // avoid 0 and over-large shifts z := make([]Word, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n * _W)) - b.Run("shrVU", func { b | for i := 0; i < b.N; i++ { + b.Run("shrVU", func { b -> for i := 0; i < b.N; i++ { _ = shrVU(z, x, s) } }) - b.Run("shlVU", func { b | for i := 0; i < b.N; i++ { + b.Run("shlVU", func { b -> for i := 0; i < b.N; i++ { _ = shlVU(z, x, s) } }) }) diff --git a/src/math/big/calibrate_test.go b/src/math/big/calibrate_test.go index d93a92c1cc7b4..1c84d63bb5cdd 100644 --- a/src/math/big/calibrate_test.go +++ b/src/math/big/calibrate_test.go @@ -132,7 +132,7 @@ func measureSqr(words, nruns int, mode string) time.Duration { var testval int64 for i := 0; i < nruns; i++ { - res := testing.Benchmark(func { b | benchmarkNatSqr(b, words) }) + res := testing.Benchmark(func { b -> benchmarkNatSqr(b, words) }) testval += res.NsPerOp() } testval /= int64(nruns) diff --git a/src/math/big/decimal_test.go b/src/math/big/decimal_test.go index ecaa9075e92b0..7e5cc38acceae 100644 --- a/src/math/big/decimal_test.go +++ b/src/math/big/decimal_test.go @@ -124,7 +124,7 @@ func BenchmarkFloatString(b *testing.B) { x := new(Float) for _, prec := range []uint{1e2, 1e3, 1e4, 1e5} { x.SetPrec(prec).SetRat(NewRat(1, 3)) - b.Run(fmt.Sprintf("%v", prec), func { b | + b.Run(fmt.Sprintf("%v", prec), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sink = x.String() diff --git a/src/math/big/float_test.go b/src/math/big/float_test.go index b23231d4e81a9..60807163720fa 100644 --- a/src/math/big/float_test.go +++ b/src/math/big/float_test.go @@ -1827,7 +1827,7 @@ func BenchmarkFloatAdd(b *testing.B) { y.SetPrec(prec).SetRat(NewRat(1, 6)) z.SetPrec(prec) - b.Run(fmt.Sprintf("%v", prec), func { b | + b.Run(fmt.Sprintf("%v", prec), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { z.Add(x, y) @@ -1846,7 +1846,7 @@ func BenchmarkFloatSub(b *testing.B) { y.SetPrec(prec).SetRat(NewRat(1, 6)) z.SetPrec(prec) - b.Run(fmt.Sprintf("%v", prec), func { b | + b.Run(fmt.Sprintf("%v", prec), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { z.Sub(x, y) diff --git a/src/math/big/gcd_test.go b/src/math/big/gcd_test.go index 9b7edcc0c8d66..b96ab8a03b7b5 100644 --- a/src/math/big/gcd_test.go +++ b/src/math/big/gcd_test.go @@ -23,8 +23,8 @@ func runGCD(b *testing.B, aSize, bSize uint) { if isRaceBuilder && (aSize > 1000 || bSize > 1000) { b.Skip("skipping on race builder") } - b.Run("WithoutXY", func { b | runGCDExt(b, aSize, bSize, false) }) - b.Run("WithXY", func { b | runGCDExt(b, aSize, bSize, true) }) + b.Run("WithoutXY", func { b -> runGCDExt(b, aSize, bSize, false) }) + b.Run("WithXY", func { b -> runGCDExt(b, aSize, bSize, true) }) } func runGCDExt(b *testing.B, aSize, bSize uint, calcXY bool) { diff --git a/src/math/big/int_test.go b/src/math/big/int_test.go index 49d14279f63e7..9bbf82fbdfd3d 100644 --- a/src/math/big/int_test.go +++ b/src/math/big/int_test.go @@ -697,7 +697,7 @@ func BenchmarkExpMont(b *testing.B) { for _, mod := range mods { n, _ := new(Int).SetString(mod.val, 0) out := new(Int) - b.Run(mod.name, func { b | + b.Run(mod.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { out.Exp(x, y, n) @@ -1849,7 +1849,7 @@ func BenchmarkIntSqr(b *testing.B) { if isRaceBuilder && n > 1e3 { continue } - b.Run(fmt.Sprintf("%d", n), func { b | benchmarkIntSqr(b, n) }) + b.Run(fmt.Sprintf("%d", n), func { b -> benchmarkIntSqr(b, n) }) } } @@ -1876,7 +1876,7 @@ func BenchmarkDiv(b *testing.B) { } for _, i := range sizes { j := 2 * i - b.Run(fmt.Sprintf("%d/%d", j, i), func { b | benchmarkDiv(b, j, i) }) + b.Run(fmt.Sprintf("%d/%d", j, i), func { b -> benchmarkDiv(b, j, i) }) } } @@ -1904,7 +1904,7 @@ func TestFillBytes(t *testing.T) { "0xabababababababababababababababababababababababababa", "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff", } { - t.Run(n, func { t | + t.Run(n, func { t -> t.Log(n) x, ok := new(Int).SetString(n, 0) if !ok { diff --git a/src/math/big/nat_test.go b/src/math/big/nat_test.go index 543a4f85451e7..e469d698b1372 100644 --- a/src/math/big/nat_test.go +++ b/src/math/big/nat_test.go @@ -240,7 +240,7 @@ func BenchmarkNatMul(b *testing.B) { if isRaceBuilder && n > 1e3 { continue } - b.Run(fmt.Sprintf("%d", n), func { b | benchmarkNatMul(b, n) }) + b.Run(fmt.Sprintf("%d", n), func { b -> benchmarkNatMul(b, n) }) } } @@ -308,19 +308,19 @@ func TestShiftRight(t *testing.T) { func BenchmarkZeroShifts(b *testing.B) { x := rndNat(800) - b.Run("Shl", func { b | for i := 0; i < b.N; i++ { + b.Run("Shl", func { b -> for i := 0; i < b.N; i++ { var z nat z.shl(x, 0) } }) - b.Run("ShlSame", func { b | for i := 0; i < b.N; i++ { + b.Run("ShlSame", func { b -> for i := 0; i < b.N; i++ { x.shl(x, 0) } }) - b.Run("Shr", func { b | for i := 0; i < b.N; i++ { + b.Run("Shr", func { b -> for i := 0; i < b.N; i++ { var z nat z.shr(x, 0) } }) - b.Run("ShrSame", func { b | for i := 0; i < b.N; i++ { + b.Run("ShrSame", func { b -> for i := 0; i < b.N; i++ { x.shr(x, 0) } }) } @@ -545,7 +545,7 @@ func TestExpNN(t *testing.T) { } func FuzzExpMont(f *testing.F) { - f.Fuzz(func { t, x1, x2, x3, y1, y2, y3, m1, m2, m3 | + f.Fuzz(func { t, x1, x2, x3, y1, y2, y3, m1, m2, m3 -> if m1 == 0 && m2 == 0 && m3 == 0 { return } @@ -565,7 +565,7 @@ func BenchmarkExp3Power(b *testing.B) { for _, y := range []Word{ 0x10, 0x40, 0x100, 0x400, 0x1000, 0x4000, 0x10000, 0x40000, 0x100000, 0x400000, } { - b.Run(fmt.Sprintf("%#x", y), func { b | + b.Run(fmt.Sprintf("%#x", y), func { b -> var z nat for i := 0; i < b.N; i++ { z.expWW(x, y) @@ -744,7 +744,7 @@ func BenchmarkNatSqr(b *testing.B) { if isRaceBuilder && n > 1e3 { continue } - b.Run(fmt.Sprintf("%d", n), func { b | benchmarkNatSqr(b, n) }) + b.Run(fmt.Sprintf("%d", n), func { b -> benchmarkNatSqr(b, n) }) } } @@ -767,7 +767,7 @@ var subMod2NTests = []struct { func TestNatSubMod2N(t *testing.T) { for _, mode := range []string{"noalias", "aliasX", "aliasY"} { - t.Run(mode, func { t | + t.Run(mode, func { t -> for _, tt := range subMod2NTests { x0 := natFromString(tt.x) y0 := natFromString(tt.y) @@ -807,7 +807,7 @@ func BenchmarkNatSetBytes(b *testing.B) { n := make(nat, maxLength/_W) // ensure n doesn't need to grow during the test buf := make([]byte, maxLength) for _, l := range lengths { - b.Run(fmt.Sprint(l), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprint(l), func { b -> for i := 0; i < b.N; i++ { n.setBytes(buf[:l]) } }) } diff --git a/src/math/big/natconv_test.go b/src/math/big/natconv_test.go index 54de36a218af8..a21b14d36a4c0 100644 --- a/src/math/big/natconv_test.go +++ b/src/math/big/natconv_test.go @@ -342,7 +342,7 @@ func BenchmarkStringPiParallel(b *testing.B) { if string(x.utoa(10)) != pi { panic("benchmark incorrect: conversion failed") } - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { x.utoa(10) } }) } @@ -354,7 +354,7 @@ func BenchmarkScan(b *testing.B) { if isRaceBuilder && y > 1000 { continue } - b.Run(fmt.Sprintf("%d/Base%d", y, base), func { b | + b.Run(fmt.Sprintf("%d/Base%d", y, base), func { b -> b.StopTimer() var z nat z = z.expWW(x, y) @@ -380,7 +380,7 @@ func BenchmarkString(b *testing.B) { if isRaceBuilder && y > 1000 { continue } - b.Run(fmt.Sprintf("%d/Base%d", y, base), func { b | + b.Run(fmt.Sprintf("%d/Base%d", y, base), func { b -> b.StopTimer() var z nat z = z.expWW(x, y) @@ -397,11 +397,11 @@ func BenchmarkString(b *testing.B) { func BenchmarkLeafSize(b *testing.B) { for n := 0; n <= 16; n++ { - b.Run(fmt.Sprint(n), func { b | LeafSizeHelper(b, 10, n) }) + b.Run(fmt.Sprint(n), func { b -> LeafSizeHelper(b, 10, n) }) } // Try some large lengths for _, n := range []int{32, 64} { - b.Run(fmt.Sprint(n), func { b | LeafSizeHelper(b, 10, n) }) + b.Run(fmt.Sprint(n), func { b -> LeafSizeHelper(b, 10, n) }) } } diff --git a/src/math/big/prime_test.go b/src/math/big/prime_test.go index 305cd3a916218..7fedb48ab0365 100644 --- a/src/math/big/prime_test.go +++ b/src/math/big/prime_test.go @@ -161,29 +161,29 @@ func TestProbablyPrime(t *testing.T) { func BenchmarkProbablyPrime(b *testing.B) { p, _ := new(Int).SetString("203956878356401977405765866929034577280193993314348263094772646453283062722701277632936616063144088173312372882677123879538709400158306567338328279154499698366071906766440037074217117805690872792848149112022286332144876183376326512083574821647933992961249917319836219304274280243803104015000563790123", 10) for _, n := range []int{0, 1, 5, 10, 20} { - b.Run(fmt.Sprintf("n=%d", n), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("n=%d", n), func { b -> for i := 0; i < b.N; i++ { p.ProbablyPrime(n) } }) } - b.Run("Lucas", func { b | for i := 0; i < b.N; i++ { + b.Run("Lucas", func { b -> for i := 0; i < b.N; i++ { p.abs.probablyPrimeLucas() } }) - b.Run("MillerRabinBase2", func { b | for i := 0; i < b.N; i++ { + b.Run("MillerRabinBase2", func { b -> for i := 0; i < b.N; i++ { p.abs.probablyPrimeMillerRabin(1, true) } }) } func TestMillerRabinPseudoprimes(t *testing.T) { testPseudoprimes(t, "probablyPrimeMillerRabin", - func { n | return n.probablyPrimeMillerRabin(1, true) && !n.probablyPrimeLucas() }, + func { n -> return n.probablyPrimeMillerRabin(1, true) && !n.probablyPrimeLucas() }, // https://oeis.org/A001262 []int{2047, 3277, 4033, 4681, 8321, 15841, 29341, 42799, 49141, 52633, 65281, 74665, 80581, 85489, 88357, 90751}) } func TestLucasPseudoprimes(t *testing.T) { testPseudoprimes(t, "probablyPrimeLucas", - func { n | return n.probablyPrimeLucas() && !n.probablyPrimeMillerRabin(1, true) }, + func { n -> return n.probablyPrimeLucas() && !n.probablyPrimeMillerRabin(1, true) }, // https://oeis.org/A217719 []int{989, 3239, 5777, 10877, 27971, 29681, 30739, 31631, 39059, 72389, 73919, 75077}) } diff --git a/src/math/big/ratconv_test.go b/src/math/big/ratconv_test.go index 9644ba57c3804..bd11fb1a871b7 100644 --- a/src/math/big/ratconv_test.go +++ b/src/math/big/ratconv_test.go @@ -708,7 +708,7 @@ func BenchmarkFloatPrecExact(b *testing.B) { var r Rat r.SetFrac(NewInt(1), d) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> for i := 0; i < b.N; i++ { prec, ok := r.FloatPrec() if prec != n || !ok { @@ -730,7 +730,7 @@ func BenchmarkFloatPrecMixed(b *testing.B) { var r Rat r.SetFrac(NewInt(1), d) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> for i := 0; i < b.N; i++ { prec, ok := r.FloatPrec() if prec != n || ok { @@ -753,7 +753,7 @@ func BenchmarkFloatPrecInexact(b *testing.B) { var r Rat r.SetFrac(NewInt(1), d) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> for i := 0; i < b.N; i++ { _, ok := r.FloatPrec() if ok { diff --git a/src/math/big/sqrt_test.go b/src/math/big/sqrt_test.go index 7db276d253427..2a640282db527 100644 --- a/src/math/big/sqrt_test.go +++ b/src/math/big/sqrt_test.go @@ -116,7 +116,7 @@ func BenchmarkFloatSqrt(b *testing.B) { for _, prec := range []uint{64, 128, 256, 1e3, 1e4, 1e5, 1e6} { x := NewFloat(2) z := new(Float).SetPrec(prec) - b.Run(fmt.Sprintf("%v", prec), func { b | + b.Run(fmt.Sprintf("%v", prec), func { b -> b.ReportAllocs() for n := 0; n < b.N; n++ { z.Sqrt(x) diff --git a/src/math/bits/bits_test.go b/src/math/bits/bits_test.go index 92666886769f4..45147af1a779e 100644 --- a/src/math/bits/bits_test.go +++ b/src/math/bits/bits_test.go @@ -738,10 +738,10 @@ func TestAddSubUint(t *testing.T) { test("Sub symmetric", Sub, a.z, a.y, a.c, a.x, a.cout) // The above code can't test intrinsic implementation, because the passed function is not called directly. // The following code uses a closure to test the intrinsic version in case the function is intrinsified. - test("Add intrinsic", func { x, y, c | return Add(x, y, c) }, a.x, a.y, a.c, a.z, a.cout) - test("Add intrinsic symmetric", func { x, y, c | return Add(x, y, c) }, a.y, a.x, a.c, a.z, a.cout) - test("Sub intrinsic", func { x, y, c | return Sub(x, y, c) }, a.z, a.x, a.c, a.y, a.cout) - test("Sub intrinsic symmetric", func { x, y, c | return Sub(x, y, c) }, a.z, a.y, a.c, a.x, a.cout) + test("Add intrinsic", func { x, y, c -> return Add(x, y, c) }, a.x, a.y, a.c, a.z, a.cout) + test("Add intrinsic symmetric", func { x, y, c -> return Add(x, y, c) }, a.y, a.x, a.c, a.z, a.cout) + test("Sub intrinsic", func { x, y, c -> return Sub(x, y, c) }, a.z, a.x, a.c, a.y, a.cout) + test("Sub intrinsic symmetric", func { x, y, c -> return Sub(x, y, c) }, a.z, a.y, a.c, a.x, a.cout) } } @@ -799,10 +799,10 @@ func TestAddSubUint64(t *testing.T) { test("Sub64 symmetric", Sub64, a.z, a.y, a.c, a.x, a.cout) // The above code can't test intrinsic implementation, because the passed function is not called directly. // The following code uses a closure to test the intrinsic version in case the function is intrinsified. - test("Add64 intrinsic", func { x, y, c | return Add64(x, y, c) }, a.x, a.y, a.c, a.z, a.cout) - test("Add64 intrinsic symmetric", func { x, y, c | return Add64(x, y, c) }, a.y, a.x, a.c, a.z, a.cout) - test("Sub64 intrinsic", func { x, y, c | return Sub64(x, y, c) }, a.z, a.x, a.c, a.y, a.cout) - test("Sub64 intrinsic symmetric", func { x, y, c | return Sub64(x, y, c) }, a.z, a.y, a.c, a.x, a.cout) + test("Add64 intrinsic", func { x, y, c -> return Add64(x, y, c) }, a.x, a.y, a.c, a.z, a.cout) + test("Add64 intrinsic symmetric", func { x, y, c -> return Add64(x, y, c) }, a.y, a.x, a.c, a.z, a.cout) + test("Sub64 intrinsic", func { x, y, c -> return Sub64(x, y, c) }, a.z, a.x, a.c, a.y, a.cout) + test("Sub64 intrinsic symmetric", func { x, y, c -> return Sub64(x, y, c) }, a.z, a.y, a.c, a.x, a.cout) } } @@ -956,10 +956,10 @@ func TestMulDiv(t *testing.T) { testDiv("Div symmetric", Div, a.hi, a.lo+a.r, a.x, a.y, a.r) // The above code can't test intrinsic implementation, because the passed function is not called directly. // The following code uses a closure to test the intrinsic version in case the function is intrinsified. - testMul("Mul intrinsic", func { x, y | return Mul(x, y) }, a.x, a.y, a.hi, a.lo) - testMul("Mul intrinsic symmetric", func { x, y | return Mul(x, y) }, a.y, a.x, a.hi, a.lo) - testDiv("Div intrinsic", func { hi, lo, y | return Div(hi, lo, y) }, a.hi, a.lo+a.r, a.y, a.x, a.r) - testDiv("Div intrinsic symmetric", func { hi, lo, y | return Div(hi, lo, y) }, a.hi, a.lo+a.r, a.x, a.y, a.r) + testMul("Mul intrinsic", func { x, y -> return Mul(x, y) }, a.x, a.y, a.hi, a.lo) + testMul("Mul intrinsic symmetric", func { x, y -> return Mul(x, y) }, a.y, a.x, a.hi, a.lo) + testDiv("Div intrinsic", func { hi, lo, y -> return Div(hi, lo, y) }, a.hi, a.lo+a.r, a.y, a.x, a.r) + testDiv("Div intrinsic symmetric", func { hi, lo, y -> return Div(hi, lo, y) }, a.hi, a.lo+a.r, a.x, a.y, a.r) } } @@ -1018,10 +1018,10 @@ func TestMulDiv64(t *testing.T) { testDiv("Div64 symmetric", Div64, a.hi, a.lo+a.r, a.x, a.y, a.r) // The above code can't test intrinsic implementation, because the passed function is not called directly. // The following code uses a closure to test the intrinsic version in case the function is intrinsified. - testMul("Mul64 intrinsic", func { x, y | return Mul64(x, y) }, a.x, a.y, a.hi, a.lo) - testMul("Mul64 intrinsic symmetric", func { x, y | return Mul64(x, y) }, a.y, a.x, a.hi, a.lo) - testDiv("Div64 intrinsic", func { hi, lo, y | return Div64(hi, lo, y) }, a.hi, a.lo+a.r, a.y, a.x, a.r) - testDiv("Div64 intrinsic symmetric", func { hi, lo, y | return Div64(hi, lo, y) }, a.hi, a.lo+a.r, a.x, a.y, a.r) + testMul("Mul64 intrinsic", func { x, y -> return Mul64(x, y) }, a.x, a.y, a.hi, a.lo) + testMul("Mul64 intrinsic symmetric", func { x, y -> return Mul64(x, y) }, a.y, a.x, a.hi, a.lo) + testDiv("Div64 intrinsic", func { hi, lo, y -> return Div64(hi, lo, y) }, a.hi, a.lo+a.r, a.y, a.x, a.r) + testDiv("Div64 intrinsic symmetric", func { hi, lo, y -> return Div64(hi, lo, y) }, a.hi, a.lo+a.r, a.x, a.y, a.r) } } diff --git a/src/math/rand/default_test.go b/src/math/rand/default_test.go index 380c127ef181d..d7e9c57372cbc 100644 --- a/src/math/rand/default_test.go +++ b/src/math/rand/default_test.go @@ -35,7 +35,7 @@ func TestDefaultRace(t *testing.T) { for i := 0; i < 6; i++ { i := i - t.Run(strconv.Itoa(i), func { t | + t.Run(strconv.Itoa(i), func { t -> t.Parallel() exe, err := os.Executable() if err != nil { diff --git a/src/math/rand/example_test.go b/src/math/rand/example_test.go index cb61be8f0533f..62b9b92edf4e8 100644 --- a/src/math/rand/example_test.go +++ b/src/math/rand/example_test.go @@ -107,7 +107,7 @@ func ExamplePerm() { func ExampleShuffle() { words := strings.Fields("ink runs from the corners of my mouth") - rand.Shuffle(len(words), func { i, j | words[i], words[j] = words[j], words[i] }) + rand.Shuffle(len(words), func { i, j -> words[i], words[j] = words[j], words[i] }) fmt.Println(words) } @@ -115,7 +115,7 @@ func ExampleShuffle_slicesInUnison() { numbers := []byte("12345") letters := []byte("ABCDE") // Shuffle numbers, swapping corresponding entries in letters at the same time. - rand.Shuffle(len(numbers), func { i, j | + rand.Shuffle(len(numbers), func { i, j -> numbers[i], numbers[j] = numbers[j], numbers[i] letters[i], letters[j] = letters[j], letters[i] }) diff --git a/src/math/rand/rand_test.go b/src/math/rand/rand_test.go index 07c84f4f7a4b1..57707529d4eaf 100644 --- a/src/math/rand/rand_test.go +++ b/src/math/rand/rand_test.go @@ -453,7 +453,7 @@ func TestShuffleSmall(t *testing.T) { // Check that Shuffle allows n=0 and n=1, but that swap is never called for them. r := New(NewSource(1)) for n := 0; n <= 1; n++ { - r.Shuffle(n, func { i, j | t.Fatalf("swap called, n=%d i=%d j=%d", n, i, j) }) + r.Shuffle(n, func { i, j -> t.Fatalf("swap called, n=%d i=%d j=%d", n, i, j) }) } } @@ -488,7 +488,7 @@ func TestUniformFactorial(t *testing.T) { top = 3 } for n := 3; n <= top; n++ { - t.Run(fmt.Sprintf("n=%d", n), func { t | + t.Run(fmt.Sprintf("n=%d", n), func { t -> // Calculate n!. nfact := 1 for i := 2; i <= n; i++ { @@ -509,13 +509,13 @@ func TestUniformFactorial(t *testing.T) { for i := range p { p[i] = i } - r.Shuffle(n, func { i, j | p[i], p[j] = p[j], p[i] }) + r.Shuffle(n, func { i, j -> p[i], p[j] = p[j], p[i] }) return encodePerm(p) }}, } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> // Gather chi-squared values and check that they follow // the expected normal distribution given n!-1 degrees of freedom. // See https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test and @@ -565,7 +565,7 @@ func BenchmarkInt63Threadsafe(b *testing.B) { } func BenchmarkInt63ThreadsafeParallel(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { Int63() } }) } @@ -633,7 +633,7 @@ func BenchmarkPerm30ViaShuffle(b *testing.B) { for i := range p { p[i] = i } - r.Shuffle(30, func { i, j | p[i], p[j] = p[j], p[i] }) + r.Shuffle(30, func { i, j -> p[i], p[j] = p[j], p[i] }) } } @@ -642,7 +642,7 @@ func BenchmarkPerm30ViaShuffle(b *testing.B) { func BenchmarkShuffleOverhead(b *testing.B) { r := New(NewSource(1)) for n := b.N; n > 0; n-- { - r.Shuffle(52, func { i, j | if i < 0 || i >= 52 || j < 0 || j >= 52 { + r.Shuffle(52, func { i, j -> if i < 0 || i >= 52 || j < 0 || j >= 52 { b.Fatalf("bad swap(%d, %d)", i, j) } }) } diff --git a/src/math/rand/v2/example_test.go b/src/math/rand/v2/example_test.go index 10ca078621f1d..b8c1be3d55d04 100644 --- a/src/math/rand/v2/example_test.go +++ b/src/math/rand/v2/example_test.go @@ -116,7 +116,7 @@ func ExampleN() { func ExampleShuffle() { words := strings.Fields("ink runs from the corners of my mouth") - rand.Shuffle(len(words), func { i, j | words[i], words[j] = words[j], words[i] }) + rand.Shuffle(len(words), func { i, j -> words[i], words[j] = words[j], words[i] }) fmt.Println(words) } @@ -124,7 +124,7 @@ func ExampleShuffle_slicesInUnison() { numbers := []byte("12345") letters := []byte("ABCDE") // Shuffle numbers, swapping corresponding entries in letters at the same time. - rand.Shuffle(len(numbers), func { i, j | + rand.Shuffle(len(numbers), func { i, j -> numbers[i], numbers[j] = numbers[j], numbers[i] letters[i], letters[j] = letters[j], letters[i] }) diff --git a/src/math/rand/v2/rand.go b/src/math/rand/v2/rand.go index d0ea460713a9d..2ad18ea9b4f56 100644 --- a/src/math/rand/v2/rand.go +++ b/src/math/rand/v2/rand.go @@ -223,7 +223,7 @@ func (r *Rand) Perm(n int) []int { for i := range p { p[i] = i } - r.Shuffle(len(p), func { i, j | p[i], p[j] = p[j], p[i] }) + r.Shuffle(len(p), func { i, j -> p[i], p[j] = p[j], p[i] }) return p } diff --git a/src/math/rand/v2/rand_test.go b/src/math/rand/v2/rand_test.go index e1fc3d9075a9b..e222ad657110e 100644 --- a/src/math/rand/v2/rand_test.go +++ b/src/math/rand/v2/rand_test.go @@ -362,7 +362,7 @@ func TestShuffleSmall(t *testing.T) { // Check that Shuffle allows n=0 and n=1, but that swap is never called for them. r := testRand() for n := 0; n <= 1; n++ { - r.Shuffle(n, func { i, j | t.Fatalf("swap called, n=%d i=%d j=%d", n, i, j) }) + r.Shuffle(n, func { i, j -> t.Fatalf("swap called, n=%d i=%d j=%d", n, i, j) }) } } @@ -397,7 +397,7 @@ func TestUniformFactorial(t *testing.T) { top = 3 } for n := 3; n <= top; n++ { - t.Run(fmt.Sprintf("n=%d", n), func { t | + t.Run(fmt.Sprintf("n=%d", n), func { t -> // Calculate n!. nfact := 1 for i := 2; i <= n; i++ { @@ -417,13 +417,13 @@ func TestUniformFactorial(t *testing.T) { for i := range p { p[i] = i } - r.Shuffle(n, func { i, j | p[i], p[j] = p[j], p[i] }) + r.Shuffle(n, func { i, j -> p[i], p[j] = p[j], p[i] }) return encodePerm(p) }}, } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> // Gather chi-squared values and check that they follow // the expected normal distribution given n!-1 degrees of freedom. // See https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test and @@ -490,7 +490,7 @@ func BenchmarkGlobalInt64(b *testing.B) { } func BenchmarkGlobalInt64Parallel(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var t int64 for pb.Next() { t += Int64() @@ -508,7 +508,7 @@ func BenchmarkGlobalUint64(b *testing.B) { } func BenchmarkGlobalUint64Parallel(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var t uint64 for pb.Next() { t += Uint64() @@ -736,7 +736,7 @@ func BenchmarkPerm30ViaShuffle(b *testing.B) { for i := range p { p[i] = i } - r.Shuffle(30, func { i, j | p[i], p[j] = p[j], p[i] }) + r.Shuffle(30, func { i, j -> p[i], p[j] = p[j], p[i] }) t += p[0] } Sink = uint64(t) @@ -747,7 +747,7 @@ func BenchmarkPerm30ViaShuffle(b *testing.B) { func BenchmarkShuffleOverhead(b *testing.B) { r := testRand() for n := b.N; n > 0; n-- { - r.Shuffle(30, func { i, j | if i < 0 || i >= 30 || j < 0 || j >= 30 { + r.Shuffle(30, func { i, j -> if i < 0 || i >= 30 || j < 0 || j >= 30 { b.Fatalf("bad swap(%d, %d)", i, j) } }) } diff --git a/src/mime/example_test.go b/src/mime/example_test.go index 05c2ea5f74b1c..5a0103c77357d 100644 --- a/src/mime/example_test.go +++ b/src/mime/example_test.go @@ -31,7 +31,7 @@ func ExampleWordDecoder_Decode() { } fmt.Println(header) - dec.CharsetReader = func { charset, input | + dec.CharsetReader = func { charset, input -> switch charset { case "x-case": // Fake character set for example. @@ -70,7 +70,7 @@ func ExampleWordDecoder_DecodeHeader() { } fmt.Println(header) - dec.CharsetReader = func { charset, input | + dec.CharsetReader = func { charset, input -> switch charset { case "x-case": // Fake character set for example. diff --git a/src/mime/multipart/formdata_test.go b/src/mime/multipart/formdata_test.go index 36dbd770a1037..63489eb5dd5e9 100644 --- a/src/mime/multipart/formdata_test.go +++ b/src/mime/multipart/formdata_test.go @@ -290,7 +290,7 @@ func TestReadForm_MetadataTooLarge(t *testing.T) { } }, }} { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> var buf bytes.Buffer fw := NewWriter(&buf) test.f(fw) @@ -416,7 +416,7 @@ func TestReadFormLimits(t *testing.T) { if test.godebug != "" { name += fmt.Sprintf("/godebug=%v", test.godebug) } - t.Run(name, func { t | + t.Run(name, func { t -> if test.godebug != "" { t.Setenv("GODEBUG", test.godebug) } @@ -466,7 +466,7 @@ func TestReadFormEndlessHeaderLine(t *testing.T) { name: "continuation", prefix: "X-Header: foo\r\n ", }} { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> const eol = "\r\n" s := `--boundary` + eol s += `Content-Disposition: form-data; name="a"` + eol @@ -515,7 +515,7 @@ func BenchmarkReadForm(b *testing.B) { } }, }} { - b.Run(test.name, func { b | + b.Run(test.name, func { b -> for _, maxMemory := range []int64{ 0, 1 << 20, @@ -526,7 +526,7 @@ func BenchmarkReadForm(b *testing.B) { if err := fw.Close(); err != nil { b.Fatal(err) } - b.Run(fmt.Sprintf("maxMemory=%v", maxMemory), func { b | + b.Run(fmt.Sprintf("maxMemory=%v", maxMemory), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { fr := NewReader(bytes.NewReader(buf.Bytes()), fw.Boundary()) diff --git a/src/mime/multipart/multipart_test.go b/src/mime/multipart/multipart_test.go index 996505bce982f..a9d3437112627 100644 --- a/src/mime/multipart/multipart_test.go +++ b/src/mime/multipart/multipart_test.go @@ -429,7 +429,7 @@ func TestLineContinuation(t *testing.T) { func TestQuotedPrintableEncoding(t *testing.T) { for _, cte := range []string{"quoted-printable", "Quoted-PRINTABLE"} { - t.Run(cte, func { t | testQuotedPrintableEncoding(t, cte) }) + t.Run(cte, func { t -> testQuotedPrintableEncoding(t, cte) }) } } diff --git a/src/mime/quotedprintable/reader_test.go b/src/mime/quotedprintable/reader_test.go index 2430d717b955c..ddfa75f6aa2a7 100644 --- a/src/mime/quotedprintable/reader_test.go +++ b/src/mime/quotedprintable/reader_test.go @@ -119,7 +119,7 @@ func TestExhaustive(t *testing.T) { if testing.Short() { n = 4 } - everySequence("", "0A \r\n=", n, func { s | + everySequence("", "0A \r\n=", n, func { s -> if strings.HasSuffix(s, "=") || strings.Contains(s, "==") { return } diff --git a/src/mime/type_test.go b/src/mime/type_test.go index b014ef6f852b9..e58e56d05b5e4 100644 --- a/src/mime/type_test.go +++ b/src/mime/type_test.go @@ -161,7 +161,7 @@ func BenchmarkTypeByExtension(b *testing.B) { ".HTML", ".unused", } { - b.Run(ext, func { b | b.RunParallel(func { pb | for pb.Next() { + b.Run(ext, func { b -> b.RunParallel(func { pb -> for pb.Next() { TypeByExtension(ext) } }) }) } @@ -176,8 +176,8 @@ func BenchmarkExtensionsByType(b *testing.B) { "text/html; charset=utf-8", "application/octet-stream", } { - b.Run(typ, func { b | - b.RunParallel(func { pb | + b.Run(typ, func { b -> + b.RunParallel(func { pb -> for pb.Next() { if _, err := ExtensionsByType(typ); err != nil { b.Fatal(err) diff --git a/src/net/conn_test.go b/src/net/conn_test.go index 242c02cc3629d..652367c9d4eaf 100644 --- a/src/net/conn_test.go +++ b/src/net/conn_test.go @@ -20,7 +20,7 @@ const someTimeout = 1 * time.Hour func TestConnAndListener(t *testing.T) { for i, network := range []string{"tcp", "unix", "unixpacket"} { i, network := i, network - t.Run(network, func { t | + t.Run(network, func { t -> if !testableNetwork(network) { t.Skipf("skipping %s test", network) } diff --git a/src/net/dial_test.go b/src/net/dial_test.go index aa3fc7e39ee35..3854c176697ba 100644 --- a/src/net/dial_test.go +++ b/src/net/dial_test.go @@ -232,7 +232,7 @@ func TestDialParallel(t *testing.T) { for i, tt := range testCases { i, tt := i, tt - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> dialTCP := func(ctx context.Context, network string, laddr, raddr *TCPAddr) (*TCPConn, error) { n := "tcp6" if raddr.IP.To4() != nil { @@ -438,7 +438,7 @@ func TestDialParallelSpuriousConnection(t *testing.T) { dialing.Add(2) origTestHookDialTCP := testHookDialTCP defer func() { testHookDialTCP = origTestHookDialTCP }() - testHookDialTCP = func { ctx, net, laddr, raddr | + testHookDialTCP = func { ctx, net, laddr, raddr -> // Wait until Happy Eyeballs kicks in and both connections are dialing, // and inhibit cancellation. // This forces dialParallel to juggle two successful connections. @@ -723,7 +723,7 @@ func TestDialerKeepAlive(t *testing.T) { } var got time.Duration = -1 - testHookSetKeepAlive = func { cfg | got = cfg.Idle } + testHookSetKeepAlive = func { cfg -> got = cfg.Idle } for _, test := range tests { got = -1 @@ -894,7 +894,7 @@ func TestDialClosedPortFailFast(t *testing.T) { t.Skip("skipping windows only test") } for _, network := range []string{"tcp", "tcp4", "tcp6"} { - t.Run(network, func { t | + t.Run(network, func { t -> if !testableNetwork(network) { t.Skipf("skipping: can't listen on %s", network) } @@ -993,7 +993,7 @@ func TestDialerControl(t *testing.T) { t.Skipf("skipping: fake net does not support Dialer.Control") } - t.Run("StreamDial", func { t | + t.Run("StreamDial", func { t -> for _, network := range []string{"tcp", "tcp4", "tcp6", "unix", "unixpacket"} { if !testableNetwork(network) { continue @@ -1009,7 +1009,7 @@ func TestDialerControl(t *testing.T) { c.Close() } }) - t.Run("PacketDial", func { t | + t.Run("PacketDial", func { t -> for _, network := range []string{"udp", "udp4", "udp6", "unixgram"} { if !testableNetwork(network) { continue @@ -1037,9 +1037,9 @@ func TestDialerControlContext(t *testing.T) { case "js", "wasip1": t.Skipf("skipping: fake net does not support Dialer.ControlContext") } - t.Run("StreamDial", func { t | + t.Run("StreamDial", func { t -> for i, network := range []string{"tcp", "tcp4", "tcp6", "unix", "unixpacket"} { - t.Run(network, func { t | + t.Run(network, func { t -> if !testableNetwork(network) { t.Skipf("skipping: %s not available", network) } diff --git a/src/net/dial_unix_test.go b/src/net/dial_unix_test.go index 4251e04b863f6..924218a39b75a 100644 --- a/src/net/dial_unix_test.go +++ b/src/net/dial_unix_test.go @@ -15,7 +15,7 @@ import ( ) func init() { - isEADDRINUSE = func { err | return errors.Is(err, syscall.EADDRINUSE) } + isEADDRINUSE = func { err -> return errors.Is(err, syscall.EADDRINUSE) } } // Issue 16523 @@ -48,7 +48,7 @@ func TestDialContextCancelRace(t *testing.T) { ctx, cancelCtx := context.WithCancel(context.Background()) - connectFunc = func { fd, addr | + connectFunc = func { fd, addr -> err := oldConnectFunc(fd, addr) t.Logf("connect(%d, addr) = %v", fd, err) if err == nil { diff --git a/src/net/dnsclient.go b/src/net/dnsclient.go index 82ce1dc0b8515..033e9b115f17a 100644 --- a/src/net/dnsclient.go +++ b/src/net/dnsclient.go @@ -197,7 +197,7 @@ func (addrs byPriorityWeight) shuffleByWeight() { // sort reorders SRV records as specified in RFC 2782. func (addrs byPriorityWeight) sort() { - slices.SortFunc(addrs, func { a, b | + slices.SortFunc(addrs, func { a, b -> if r := cmp.Compare(a.Priority, b.Priority); r != 0 { return r } @@ -228,7 +228,7 @@ func (s byPref) sort() { j := randIntn(i + 1) s[i], s[j] = s[j], s[i] } - slices.SortFunc(s, func { a, b | return cmp.Compare(a.Pref, b.Pref) }) + slices.SortFunc(s, func { a, b -> return cmp.Compare(a.Pref, b.Pref) }) } // An NS represents a single DNS NS record. diff --git a/src/net/dnsclient_unix.go b/src/net/dnsclient_unix.go index 159fd07f8b3b0..4a665d06da0cc 100644 --- a/src/net/dnsclient_unix.go +++ b/src/net/dnsclient_unix.go @@ -654,15 +654,15 @@ func (r *Resolver) goLookupIPCNAMEOrder(ctx context.Context, network, name strin var queryFn func(fqdn string, qtype dnsmessage.Type) var responseFn func(fqdn string, qtype dnsmessage.Type) result if conf.singleRequest { - queryFn = func { fqdn, qtype | } - responseFn = func { fqdn, qtype | + queryFn = func { fqdn, qtype -> } + responseFn = func { fqdn, qtype -> dnsWaitGroup.Add(1) defer dnsWaitGroup.Done() p, server, err := r.tryOneName(ctx, conf, fqdn, qtype) return result{p, server, err} } } else { - queryFn = func { fqdn, qtype | + queryFn = func { fqdn, qtype -> dnsWaitGroup.Add(1) go func(qtype dnsmessage.Type) { p, server, err := r.tryOneName(ctx, conf, fqdn, qtype) @@ -670,7 +670,7 @@ func (r *Resolver) goLookupIPCNAMEOrder(ctx context.Context, network, name strin dnsWaitGroup.Done() }(qtype) } - responseFn = func { fqdn, qtype | return <-lane } + responseFn = func { fqdn, qtype -> return <-lane } } var lastErr error for _, fqdn := range conf.nameList(name) { diff --git a/src/net/dnsclient_unix_test.go b/src/net/dnsclient_unix_test.go index 15d8a40a1105c..3518972bca296 100644 --- a/src/net/dnsclient_unix_test.go +++ b/src/net/dnsclient_unix_test.go @@ -1643,7 +1643,7 @@ func TestNoSuchHost(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> lookups := 0 err := lookupWithFake(fakeDNSServer{ rh: func(n, s string, q dnsmessage.Message, d time.Time) (dnsmessage.Message, error) { @@ -2382,8 +2382,8 @@ func testGoLookupIPCNAMEOrderHostsAliases(t *testing.T, mode hostLookupOrder, lo // This isn't a great test as it just tests the dnsmessage package // against itself. func TestDNSPacketSize(t *testing.T) { - t.Run("enabled", func { t | testDNSPacketSize(t, false) }) - t.Run("disabled", func { t | testDNSPacketSize(t, true) }) + t.Run("enabled", func { t -> testDNSPacketSize(t, false) }) + t.Run("disabled", func { t -> testDNSPacketSize(t, true) }) } func testDNSPacketSize(t *testing.T, disable bool) { diff --git a/src/net/error_test.go b/src/net/error_test.go index 3ee7a53ccb3a3..09e2c90d4b9de 100644 --- a/src/net/error_test.go +++ b/src/net/error_test.go @@ -145,14 +145,14 @@ func TestDialError(t *testing.T) { origTestHookLookupIP := testHookLookupIP defer func() { testHookLookupIP = origTestHookLookupIP }() - testHookLookupIP = func { ctx, fn, network, host | return nil, &DNSError{Err: "dial error test", Name: "name", Server: "server", IsTimeout: true} } - sw.Set(socktest.FilterConnect, func { so | return nil, errOpNotSupported }) + testHookLookupIP = func { ctx, fn, network, host -> return nil, &DNSError{Err: "dial error test", Name: "name", Server: "server", IsTimeout: true} } + sw.Set(socktest.FilterConnect, func { so -> return nil, errOpNotSupported }) defer sw.Set(socktest.FilterConnect, nil) d := Dialer{Timeout: someTimeout} for i, tt := range dialErrorTests { i, tt := i, tt - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> c, err := d.Dial(tt.network, tt.address) if err == nil { t.Errorf("should fail; %s:%s->%s", c.LocalAddr().Network(), c.LocalAddr(), c.RemoteAddr()) @@ -237,7 +237,7 @@ func TestDialAddrError(t *testing.T) { if desc == "" { desc = tt.addr.String() } - t.Run(fmt.Sprintf("%s/%s", tt.network, desc), func { t | + t.Run(fmt.Sprintf("%s/%s", tt.network, desc), func { t -> var err error var c Conn var op string @@ -297,12 +297,12 @@ func TestListenError(t *testing.T) { origTestHookLookupIP := testHookLookupIP defer func() { testHookLookupIP = origTestHookLookupIP }() - testHookLookupIP = func { _, fn, network, host | return nil, &DNSError{Err: "listen error test", Name: "name", Server: "server", IsTimeout: true} } - sw.Set(socktest.FilterListen, func { so | return nil, errOpNotSupported }) + testHookLookupIP = func { _, fn, network, host -> return nil, &DNSError{Err: "listen error test", Name: "name", Server: "server", IsTimeout: true} } + sw.Set(socktest.FilterListen, func { so -> return nil, errOpNotSupported }) defer sw.Set(socktest.FilterListen, nil) for i, tt := range listenErrorTests { - t.Run(fmt.Sprintf("%s_%s", tt.network, tt.address), func { t | + t.Run(fmt.Sprintf("%s_%s", tt.network, tt.address), func { t -> ln, err := Listen(tt.network, tt.address) if err == nil { t.Errorf("#%d: should fail; %s:%s->", i, ln.Addr().Network(), ln.Addr()) @@ -353,10 +353,10 @@ func TestListenPacketError(t *testing.T) { origTestHookLookupIP := testHookLookupIP defer func() { testHookLookupIP = origTestHookLookupIP }() - testHookLookupIP = func { _, fn, network, host | return nil, &DNSError{Err: "listen error test", Name: "name", Server: "server", IsTimeout: true} } + testHookLookupIP = func { _, fn, network, host -> return nil, &DNSError{Err: "listen error test", Name: "name", Server: "server", IsTimeout: true} } for i, tt := range listenPacketErrorTests { - t.Run(fmt.Sprintf("%s_%s", tt.network, tt.address), func { t | + t.Run(fmt.Sprintf("%s_%s", tt.network, tt.address), func { t -> c, err := ListenPacket(tt.network, tt.address) if err == nil { t.Errorf("#%d: should fail; %s:%s->", i, c.LocalAddr().Network(), c.LocalAddr()) @@ -553,7 +553,7 @@ third: } func TestCloseError(t *testing.T) { - t.Run("tcp", func { t | + t.Run("tcp", func { t -> ln := newLocalListener(t, "tcp") defer ln.Close() c, err := Dial(ln.Addr().Network(), ln.Addr().String()) @@ -586,7 +586,7 @@ func TestCloseError(t *testing.T) { } }) - t.Run("udp", func { t | + t.Run("udp", func { t -> if !testableNetwork("udp") { t.Skipf("skipping: udp not available") } diff --git a/src/net/file_unix_test.go b/src/net/file_unix_test.go index 7604c15e2b70d..d54b1e63bf27b 100644 --- a/src/net/file_unix_test.go +++ b/src/net/file_unix_test.go @@ -52,7 +52,7 @@ func TestFileFdBlocks(t *testing.T) { if err != nil { t.Fatal(err) } - err = rawconn.Control(func { fd | + err = rawconn.Control(func { fd -> nonblock, err := unix.IsNonblock(int(fd)) if err != nil { t.Fatal(err) @@ -75,7 +75,7 @@ func TestFileFdBlocks(t *testing.T) { if err != nil { t.Fatal(err) } - err = rawconn.Control(func { fd | + err = rawconn.Control(func { fd -> nonblock, err := unix.IsNonblock(int(fd)) if err != nil { t.Fatal(err) diff --git a/src/net/http/alpn_test.go b/src/net/http/alpn_test.go index ec992355b06ff..3d03a2d665538 100644 --- a/src/net/http/alpn_test.go +++ b/src/net/http/alpn_test.go @@ -20,7 +20,7 @@ import ( func TestNextProtoUpgrade(t *testing.T) { setParallel(t) defer afterTest(t) - ts := httptest.NewUnstartedServer(HandlerFunc(func { w, r | + ts := httptest.NewUnstartedServer(HandlerFunc(func { w, r -> fmt.Fprintf(w, "path=%s,proto=", r.URL.Path) if r.TLS != nil { w.Write([]byte(r.TLS.NegotiatedProtocol)) diff --git a/src/net/http/cgi/cgi_main.go b/src/net/http/cgi/cgi_main.go index c1f287faca257..6a3d6453f5d35 100644 --- a/src/net/http/cgi/cgi_main.go +++ b/src/net/http/cgi/cgi_main.go @@ -111,7 +111,7 @@ func childCGIProcess() { fmt.Printf("\nHello") os.Exit(0) } - Serve(http.HandlerFunc(func { rw, req | + Serve(http.HandlerFunc(func { rw, req -> if req.FormValue("nil-request-body") == "1" { fmt.Fprintf(rw, "nil-request-body=%v\n", req.Body == nil) return diff --git a/src/net/http/cgi/child_test.go b/src/net/http/cgi/child_test.go index 0646838346696..b99071f03adb9 100644 --- a/src/net/http/cgi/child_test.go +++ b/src/net/http/cgi/child_test.go @@ -181,7 +181,7 @@ func TestResponse(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> var buf bytes.Buffer resp := response{ req: httptest.NewRequest("GET", "/", nil), diff --git a/src/net/http/cgi/host_test.go b/src/net/http/cgi/host_test.go index 1927809be55a8..590839e57ba3d 100644 --- a/src/net/http/cgi/host_test.go +++ b/src/net/http/cgi/host_test.go @@ -257,7 +257,7 @@ func TestDropProxyHeader(t *testing.T) { "Proxy: should_be_stripped\n"+ "Host: example.com\n\n", expectedMap, - func { reqInfo | + func { reqInfo -> if v, ok := reqInfo["env-HTTP_PROXY"]; ok { t.Errorf("HTTP_PROXY = %q; should be absent", v) } @@ -345,7 +345,7 @@ func TestRedirect(t *testing.T) { func TestInternalRedirect(t *testing.T) { testenv.MustHaveExec(t) - baseHandler := http.HandlerFunc(func { rw, req | + baseHandler := http.HandlerFunc(func { rw, req -> fmt.Fprintf(rw, "basepath=%s\n", req.URL.Path) fmt.Fprintf(rw, "remoteaddr=%s\n", req.RemoteAddr) }) diff --git a/src/net/http/cgi/integration_test.go b/src/net/http/cgi/integration_test.go index 90b1d7d4c4a0e..dc9e0a79ecf00 100644 --- a/src/net/http/cgi/integration_test.go +++ b/src/net/http/cgi/integration_test.go @@ -176,7 +176,7 @@ func TestChildContentType(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> expectedMap := map[string]string{"_body": tt.body} req := fmt.Sprintf("GET /test.go?exact-body=%s HTTP/1.0\nHost: example.com\n\n", url.QueryEscape(tt.body)) replay := runCgiTest(t, h, req, expectedMap) diff --git a/src/net/http/client_test.go b/src/net/http/client_test.go index a13e9e23dab63..43980a169dcb9 100644 --- a/src/net/http/client_test.go +++ b/src/net/http/client_test.go @@ -31,7 +31,7 @@ import ( "time" ) -var robotsTxtHandler = HandlerFunc(func { w, r | +var robotsTxtHandler = HandlerFunc(func { w, r -> w.Header().Set("Last-Modified", "sometime") fmt.Fprintf(w, "User-agent: go\nDisallow: /something/") }) @@ -189,7 +189,7 @@ func TestPostFormRequestFormat(t *testing.T) { func TestClientRedirects(t *testing.T) { run(t, testClientRedirects) } func testClientRedirects(t *testing.T, mode testMode) { var ts *httptest.Server - ts = newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts = newClientServerTest(t, mode, HandlerFunc(func { w, r -> n, _ := strconv.Atoi(r.FormValue("n")) // Test Referer header. (7 is arbitrary position to test at) if n == 7 { @@ -233,7 +233,7 @@ func testClientRedirects(t *testing.T, mode testMode) { var checkErr error var lastVia []*Request var lastReq *Request - c.CheckRedirect = func { req, via | + c.CheckRedirect = func { req, via -> lastReq = req lastVia = via return checkErr @@ -285,11 +285,11 @@ func testClientRedirects(t *testing.T, mode testMode) { // Tests that Client redirects' contexts are derived from the original request's context. func TestClientRedirectsContext(t *testing.T) { run(t, testClientRedirectsContext) } func testClientRedirectsContext(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | Redirect(w, r, "/", StatusTemporaryRedirect) })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> Redirect(w, r, "/", StatusTemporaryRedirect) })).ts ctx, cancel := context.WithCancel(context.Background()) c := ts.Client() - c.CheckRedirect = func { req, via | + c.CheckRedirect = func { req, via -> cancel() select { case <-req.Context().Done(): @@ -353,7 +353,7 @@ func TestPostRedirects(t *testing.T) { `POST /?code=404 "c404"`, } want := strings.Join(wantSegments, "\n") - run(t, func { t, mode | testRedirectsByMethod(t, mode, "POST", postRedirectTests, want) }) + run(t, func { t, mode -> testRedirectsByMethod(t, mode, "POST", postRedirectTests, want) }) } func TestDeleteRedirects(t *testing.T) { @@ -390,7 +390,7 @@ func TestDeleteRedirects(t *testing.T) { `DELETE /?code=404 "c404"`, } want := strings.Join(wantSegments, "\n") - run(t, func { t, mode | testRedirectsByMethod(t, mode, "DELETE", deleteRedirectTests, want) }) + run(t, func { t, mode -> testRedirectsByMethod(t, mode, "DELETE", deleteRedirectTests, want) }) } func testRedirectsByMethod(t *testing.T, mode testMode, method string, table []redirectTest, want string) { @@ -399,7 +399,7 @@ func testRedirectsByMethod(t *testing.T, mode testMode, method string, table []r bytes.Buffer } var ts *httptest.Server - ts = newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts = newClientServerTest(t, mode, HandlerFunc(func { w, r -> log.Lock() slurp, _ := io.ReadAll(r.Body) fmt.Fprintf(&log.Buffer, "%s %s %q", r.Method, r.RequestURI, slurp) @@ -473,7 +473,7 @@ func TestClientRedirectUseResponse(t *testing.T) { run(t, testClientRedirectUseR func testClientRedirectUseResponse(t *testing.T, mode testMode) { const body = "Hello, world." var ts *httptest.Server - ts = newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts = newClientServerTest(t, mode, HandlerFunc(func { w, r -> if strings.Contains(r.URL.Path, "/other") { io.WriteString(w, "wrong body") } else { @@ -484,7 +484,7 @@ func testClientRedirectUseResponse(t *testing.T, mode testMode) { })).ts c := ts.Client() - c.CheckRedirect = func { req, via | + c.CheckRedirect = func { req, via -> if req.Response == nil { t.Error("expected non-nil Request.Response") } @@ -512,9 +512,9 @@ func testClientRedirectUseResponse(t *testing.T, mode testMode) { func TestClientRedirectNoLocation(t *testing.T) { run(t, testClientRedirectNoLocation) } func testClientRedirectNoLocation(t *testing.T, mode testMode) { for _, code := range []int{301, 308} { - t.Run(fmt.Sprint(code), func { t | + t.Run(fmt.Sprint(code), func { t -> setParallel(t) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Foo", "Bar") w.WriteHeader(code) })) @@ -537,7 +537,7 @@ func testClientRedirectNoLocation(t *testing.T, mode testMode) { func TestClientRedirect308NoGetBody(t *testing.T) { run(t, testClientRedirect308NoGetBody) } func testClientRedirect308NoGetBody(t *testing.T, mode testMode) { const fakeURL = "https://localhost:1234/" // won't be hit - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Location", fakeURL) w.WriteHeader(308) })).ts @@ -566,7 +566,7 @@ var expectedCookies = []*Cookie{ {Name: "Second", Value: "Hit"}, } -var echoCookiesRedirectHandler = HandlerFunc(func { w, r | +var echoCookiesRedirectHandler = HandlerFunc(func { w, r -> for _, cookie := range r.Cookies() { SetCookie(w, cookie) } @@ -668,7 +668,7 @@ func matchReturnedCookies(t *testing.T, expected, given []*Cookie) { func TestJarCalls(t *testing.T) { run(t, testJarCalls, []testMode{http1Mode}) } func testJarCalls(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> pathSuffix := r.RequestURI[1:] if r.RequestURI == "/nosetcookie" { return // don't set cookies for this path @@ -681,7 +681,7 @@ func testJarCalls(t *testing.T, mode testMode) { jar := new(RecordingJar) c := ts.Client() c.Jar = jar - c.Transport.(*Transport).Dial = func { _, _ | return net.Dial("tcp", ts.Listener.Addr().String()) } + c.Transport.(*Transport).Dial = func { _, _ -> return net.Dial("tcp", ts.Listener.Addr().String()) } _, err := c.Get("http://firsthost.fake/") if err != nil { t.Fatal(err) @@ -727,7 +727,7 @@ func (j *RecordingJar) logf(format string, args ...any) { func TestStreamingGet(t *testing.T) { run(t, testStreamingGet) } func testStreamingGet(t *testing.T, mode testMode) { say := make(chan string) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.(Flusher).Flush() for str := range say { w.Write([]byte(str)) @@ -776,7 +776,7 @@ func (c *writeCountingConn) Write(p []byte) (int, error) { // don't send a TCP packet per line of the http request + body. func TestClientWrites(t *testing.T) { run(t, testClientWrites, []testMode{http1Mode}) } func testClientWrites(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> })).ts writes := 0 dialer := func(netz string, addr string) (net.Conn, error) { @@ -811,7 +811,7 @@ func TestClientInsecureTransport(t *testing.T) { run(t, testClientInsecureTransport, []testMode{https1Mode, http2Mode}) } func testClientInsecureTransport(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.Write([]byte("Hello")) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Write([]byte("Hello")) })) ts := cst.ts errLog := new(strings.Builder) ts.Config.ErrorLog = log.New(errLog, "", 0) @@ -857,7 +857,7 @@ func TestClientWithCorrectTLSServerName(t *testing.T) { } func testClientWithCorrectTLSServerName(t *testing.T, mode testMode) { const serverName = "example.com" - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.TLS.ServerName != serverName { t.Errorf("expected client to set ServerName %q, got: %q", serverName, r.TLS.ServerName) } @@ -874,7 +874,7 @@ func TestClientWithIncorrectTLSServerName(t *testing.T) { run(t, testClientWithIncorrectTLSServerName, []testMode{https1Mode, http2Mode}) } func testClientWithIncorrectTLSServerName(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> })) ts := cst.ts errLog := new(strings.Builder) ts.Config.ErrorLog = log.New(errLog, "", 0) @@ -908,12 +908,12 @@ func TestTransportUsesTLSConfigServerName(t *testing.T) { run(t, testTransportUsesTLSConfigServerName, []testMode{https1Mode, http2Mode}) } func testTransportUsesTLSConfigServerName(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.Write([]byte("Hello")) })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Write([]byte("Hello")) })).ts c := ts.Client() tr := c.Transport.(*Transport) tr.TLSClientConfig.ServerName = "example.com" // one of httptest's Server cert names - tr.Dial = func { netw, addr | return net.Dial(netw, ts.Listener.Addr().String()) } + tr.Dial = func { netw, addr -> return net.Dial(netw, ts.Listener.Addr().String()) } res, err := c.Get("https://some-other-host.tld/") if err != nil { t.Fatal(err) @@ -925,13 +925,13 @@ func TestResponseSetsTLSConnectionState(t *testing.T) { run(t, testResponseSetsTLSConnectionState, []testMode{https1Mode}) } func testResponseSetsTLSConnectionState(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.Write([]byte("Hello")) })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Write([]byte("Hello")) })).ts c := ts.Client() tr := c.Transport.(*Transport) tr.TLSClientConfig.CipherSuites = []uint16{tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256} tr.TLSClientConfig.MaxVersion = tls.VersionTLS12 // to get to pick the cipher suite - tr.Dial = func { netw, addr | return net.Dial(netw, ts.Listener.Addr().String()) } + tr.Dial = func { netw, addr -> return net.Dial(netw, ts.Listener.Addr().String()) } res, err := c.Get("https://example.com/") if err != nil { t.Fatal(err) @@ -952,7 +952,7 @@ func TestHTTPSClientDetectsHTTPServer(t *testing.T) { run(t, testHTTPSClientDetectsHTTPServer, []testMode{http1Mode}) } func testHTTPSClientDetectsHTTPServer(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> })).ts ts.Config.ErrorLog = quietLog _, err := Get(strings.Replace(ts.URL, "http", "https", 1)) @@ -964,7 +964,7 @@ func testHTTPSClientDetectsHTTPServer(t *testing.T, mode testMode) { // Verify Response.ContentLength is populated. https://golang.org/issue/4126 func TestClientHeadContentLength(t *testing.T) { run(t, testClientHeadContentLength) } func testClientHeadContentLength(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | if v := r.FormValue("cl"); v != "" { + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if v := r.FormValue("cl"); v != "" { w.Header().Set("Content-Length", v) } })) tests := []struct { @@ -997,7 +997,7 @@ func testClientHeadContentLength(t *testing.T, mode testMode) { func TestEmptyPasswordAuth(t *testing.T) { run(t, testEmptyPasswordAuth) } func testEmptyPasswordAuth(t *testing.T, mode testMode) { gopher := "gopher" - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> auth := r.Header.Get("Authorization") if strings.HasPrefix(auth, "Basic ") { encoded := auth[6:] @@ -1132,7 +1132,7 @@ func TestStripPasswordFromError(t *testing.T) { }, } for _, tC := range testCases { - t.Run(tC.desc, func { t | + t.Run(tC.desc, func { t -> _, err := client.Get(tC.in) if err.Error() != tC.out { t.Errorf("Unexpected output for %q: expected %q, actual %q", @@ -1149,7 +1149,7 @@ func testClientTimeout(t *testing.T, mode testMode) { nonce string // a unique per-request string sawSlowNonce bool // true if the handler saw /slow?nonce= ) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> _ = r.ParseForm() if r.URL.Path == "/" { Redirect(w, r, "/slow?nonce="+r.Form.Get("nonce"), StatusFound) @@ -1246,7 +1246,7 @@ func testClientTimeout(t *testing.T, mode testMode) { func TestClientTimeout_Headers(t *testing.T) { run(t, testClientTimeout_Headers) } func testClientTimeout_Headers(t *testing.T, mode testMode) { donec := make(chan bool, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | <-donec }), optQuietLog) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> <-donec }), optQuietLog) // Note that we use a channel send here and not a close. // The race detector doesn't know that we're waiting for a timeout // and thinks that the waitgroup inside httptest.Server is added to concurrently @@ -1290,7 +1290,7 @@ func testClientTimeoutCancel(t *testing.T, mode testMode) { testDone := make(chan struct{}) ctx, cancel := context.WithCancel(context.Background()) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.(Flusher).Flush() <-testDone })) @@ -1313,7 +1313,7 @@ func testClientTimeoutCancel(t *testing.T, mode testMode) { // Issue 49366: if Client.Timeout is set but not hit, no error should be returned. func TestClientTimeoutDoesNotExpire(t *testing.T) { run(t, testClientTimeoutDoesNotExpire) } func testClientTimeoutDoesNotExpire(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.Write([]byte("body")) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Write([]byte("body")) })) cst.c.Timeout = 1 * time.Hour req, _ := NewRequest("GET", cst.ts.URL, nil) @@ -1332,7 +1332,7 @@ func testClientTimeoutDoesNotExpire(t *testing.T, mode testMode) { func TestClientRedirectEatsBody_h1(t *testing.T) { run(t, testClientRedirectEatsBody) } func testClientRedirectEatsBody(t *testing.T, mode testMode) { saw := make(chan string, 2) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> saw <- r.RemoteAddr if r.URL.Path == "/" { Redirect(w, r, "/foo", StatusFound) // which includes a body @@ -1455,7 +1455,7 @@ func testClientCopyHeadersOnRedirect(t *testing.T, mode testMode) { xfoo = "foo-val" ) var ts2URL string - ts1 := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts1 := newClientServerTest(t, mode, HandlerFunc(func { w, r -> want := Header{ "User-Agent": []string{ua}, "X-Foo": []string{xfoo}, @@ -1473,11 +1473,11 @@ func testClientCopyHeadersOnRedirect(t *testing.T, mode testMode) { w.Header().Set("Result", "ok") } })).ts - ts2 := newClientServerTest(t, mode, HandlerFunc(func { w, r | Redirect(w, r, ts1.URL, StatusFound) })).ts + ts2 := newClientServerTest(t, mode, HandlerFunc(func { w, r -> Redirect(w, r, ts1.URL, StatusFound) })).ts ts2URL = ts2.URL c := ts1.Client() - c.CheckRedirect = func { r, via | + c.CheckRedirect = func { r, via -> want := Header{ "User-Agent": []string{ua}, "X-Foo": []string{xfoo}, @@ -1513,7 +1513,7 @@ func testClientCopyHeadersOnRedirect(t *testing.T, mode testMode) { func TestClientCopyHostOnRedirect(t *testing.T) { run(t, testClientCopyHostOnRedirect) } func testClientCopyHostOnRedirect(t *testing.T, mode testMode) { // Virtual hostname: should not receive any request. - virtual := newClientServerTest(t, mode, HandlerFunc(func { w, r | + virtual := newClientServerTest(t, mode, HandlerFunc(func { w, r -> t.Errorf("Virtual host received request %v", r.URL) w.WriteHeader(403) io.WriteString(w, "should not see this response") @@ -1527,7 +1527,7 @@ func testClientCopyHostOnRedirect(t *testing.T, mode testMode) { const wantBody = "response body" var tsURL string var tsHost string - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> switch r.URL.Path { case "/": // Relative redirect. @@ -1592,7 +1592,7 @@ func testClientAltersCookiesOnRedirect(t *testing.T, mode testMode) { return m } - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> var want map[string][]string got := cookieMap(r.Cookies()) @@ -1778,7 +1778,7 @@ func testClientRedirectTypes(t *testing.T, mode testMode) { handlerc := make(chan HandlerFunc, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> h := <-handlerc h(rw, req) })).ts @@ -1796,7 +1796,7 @@ func testClientRedirectTypes(t *testing.T, mode testMode) { continue } - c.CheckRedirect = func { req, via | + c.CheckRedirect = func { req, via -> if got, want := req.Method, tt.wantMethod; got != want { return fmt.Errorf("#%d: got next method %q; want %q", i, got, want) } @@ -1839,7 +1839,7 @@ func (b issue18239Body) Close() error { // if Request.GetBody is not defined. func TestTransportBodyReadError(t *testing.T) { run(t, testTransportBodyReadError) } func testTransportBodyReadError(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.URL.Path == "/ping" { return } @@ -1920,7 +1920,7 @@ func (t testRoundTripper) RoundTrip(req *Request) (*Response, error) { func TestClientPropagatesTimeoutToContext(t *testing.T) { c := &Client{ Timeout: 5 * time.Second, - Transport: testRoundTripper(func { req | + Transport: testRoundTripper(func { req -> ctx := req.Context() deadline, ok := ctx.Deadline() if !ok { @@ -1938,12 +1938,12 @@ func TestClientPropagatesTimeoutToContext(t *testing.T) { // docs about request cancellation vs timing out. func TestClientDoCanceledVsTimeout(t *testing.T) { run(t, testClientDoCanceledVsTimeout) } func testClientDoCanceledVsTimeout(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.Write([]byte("Hello, World!")) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Write([]byte("Hello, World!")) })) cases := []string{"timeout", "canceled"} for _, name := range cases { - t.Run(name, func { t | + t.Run(name, func { t -> var ctx context.Context var cancel func() if name == "timeout" { @@ -2019,7 +2019,7 @@ func TestClientPopulatesNilResponseBody(t *testing.T) { // Issue 40382: Client calls Close multiple times on Request.Body. func TestClientCallsCloseOnlyOnce(t *testing.T) { run(t, testClientCallsCloseOnlyOnce) } func testClientCallsCloseOnlyOnce(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.WriteHeader(StatusNoContent) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.WriteHeader(StatusNoContent) })) // Issue occurred non-deterministically: needed to occur after a successful // write (into TCP buffer) but before end of body. @@ -2072,7 +2072,7 @@ func (b *issue40382Body) Close() error { func TestProbeZeroLengthBody(t *testing.T) { run(t, testProbeZeroLengthBody) } func testProbeZeroLengthBody(t *testing.T, mode testMode) { reqc := make(chan struct{}) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> close(reqc) if _, err := io.Copy(w, r.Body); err != nil { t.Errorf("error copying request body: %v", err) diff --git a/src/net/http/clientserver_test.go b/src/net/http/clientserver_test.go index a9ea7a3809f12..963052dfcf599 100644 --- a/src/net/http/clientserver_test.go +++ b/src/net/http/clientserver_test.go @@ -79,7 +79,7 @@ func run[T TBRun[T]](t T, f func(t T, mode testMode), opts ...any) { setParallel(t) } for _, mode := range modes { - t.Run(string(mode), func { t | + t.Run(string(mode), func { t -> t.Helper() if t, ok := any(t).(*testing.T); ok && parallel { setParallel(t) @@ -221,7 +221,7 @@ func testNewClientServerTest(t *testing.T, mode testMode) { proto string hasTLS bool } - h := HandlerFunc(func { w, r | + h := HandlerFunc(func { w, r -> got.Lock() defer got.Unlock() got.proto = r.Proto @@ -256,7 +256,7 @@ func TestChunkedResponseHeaders(t *testing.T) { run(t, testChunkedResponseHeader func testChunkedResponseHeaders(t *testing.T, mode testMode) { log.SetOutput(io.Discard) // is noisy otherwise defer log.SetOutput(os.Stderr) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Length", "intentional gibberish") // we check that this is deleted w.(Flusher).Flush() fmt.Fprintf(w, "I am a chunked response.") @@ -513,7 +513,7 @@ func TestH12_HandlerWritesTooLittle(t *testing.T) { func TestHandlerWritesTooMuch(t *testing.T) { run(t, testHandlerWritesTooMuch) } func testHandlerWritesTooMuch(t *testing.T, mode testMode) { wantBody := []byte("123") - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> rc := NewResponseController(w) w.Header().Set("Content-Length", fmt.Sprintf("%v", len(wantBody))) rc.Flush() @@ -576,7 +576,7 @@ func TestH12_AutoGzip_Disabled(t *testing.T) { // output. func Test304Responses(t *testing.T) { run(t, test304Responses) } func test304Responses(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.WriteHeader(StatusNotModified) _, err := w.Write([]byte("illegal body")) if err != ErrBodyNotAllowed { @@ -644,7 +644,7 @@ func TestCancelRequestMidBody(t *testing.T) { run(t, testCancelRequestMidBody) } func testCancelRequestMidBody(t *testing.T, mode testMode) { unblock := make(chan bool) didFlush := make(chan bool, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> io.WriteString(w, "Hello") w.(Flusher).Flush() didFlush <- true @@ -688,7 +688,7 @@ func testCancelRequestMidBody(t *testing.T, mode testMode) { // Tests that clients can send trailers to a server and that the server can read them. func TestTrailersClientToServer(t *testing.T) { run(t, testTrailersClientToServer) } func testTrailersClientToServer(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> var decl []string for k := range r.Trailer { decl = append(decl, k) @@ -738,15 +738,15 @@ func testTrailersClientToServer(t *testing.T, mode testMode) { // Tests that servers send trailers to a client and that the client can read them. func TestTrailersServerToClient(t *testing.T) { - run(t, func { t, mode | testTrailersServerToClient(t, mode, false) }) + run(t, func { t, mode -> testTrailersServerToClient(t, mode, false) }) } func TestTrailersServerToClientFlush(t *testing.T) { - run(t, func { t, mode | testTrailersServerToClient(t, mode, true) }) + run(t, func { t, mode -> testTrailersServerToClient(t, mode, true) }) } func testTrailersServerToClient(t *testing.T, mode testMode, flush bool) { const body = "Some body" - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Trailer", "Server-Trailer-A, Server-Trailer-B") w.Header().Add("Trailer", "Server-Trailer-C") @@ -816,7 +816,7 @@ func testTrailersServerToClient(t *testing.T, mode testMode, flush bool) { func TestResponseBodyReadAfterClose(t *testing.T) { run(t, testResponseBodyReadAfterClose) } func testResponseBodyReadAfterClose(t *testing.T, mode testMode) { const body = "Some body" - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | io.WriteString(w, body) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> io.WriteString(w, body) })) res, err := cst.c.Get(cst.ts.URL) if err != nil { t.Fatal(err) @@ -832,7 +832,7 @@ func TestConcurrentReadWriteReqBody(t *testing.T) { run(t, testConcurrentReadWri func testConcurrentReadWriteReqBody(t *testing.T, mode testMode) { const reqBody = "some request body" const resBody = "some response body" - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> var wg sync.WaitGroup wg.Add(2) didRead := make(chan bool, 1) @@ -881,7 +881,7 @@ func testConcurrentReadWriteReqBody(t *testing.T, mode testMode) { func TestConnectRequest(t *testing.T) { run(t, testConnectRequest) } func testConnectRequest(t *testing.T, mode testMode) { gotc := make(chan *Request, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | gotc <- r })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> gotc <- r })) u, err := url.Parse(cst.ts.URL) if err != nil { @@ -933,7 +933,7 @@ func testConnectRequest(t *testing.T, mode testMode) { func TestTransportUserAgent(t *testing.T) { run(t, testTransportUserAgent) } func testTransportUserAgent(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | fmt.Fprintf(w, "%q", r.Header["User-Agent"]) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> fmt.Fprintf(w, "%q", r.Header["User-Agent"]) })) either := func(a, b string) string { if mode == http2Mode { @@ -989,12 +989,12 @@ func testTransportUserAgent(t *testing.T, mode testMode) { func TestStarRequestMethod(t *testing.T) { for _, method := range []string{"FOO", "OPTIONS"} { - t.Run(method, func { t | run(t, func { t, mode | testStarRequest(t, method, mode) }) }) + t.Run(method, func { t -> run(t, func { t, mode -> testStarRequest(t, method, mode) }) }) } } func testStarRequest(t *testing.T, method string, mode testMode) { gotc := make(chan *Request, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("foo", "bar") gotc <- r w.(Flusher).Flush() @@ -1060,7 +1060,7 @@ func TestTransportDiscardsUnneededConns(t *testing.T) { run(t, testTransportDiscardsUnneededConns, []testMode{http2Mode}) } func testTransportDiscardsUnneededConns(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | fmt.Fprintf(w, "Hello, %v", r.RemoteAddr) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> fmt.Fprintf(w, "Hello, %v", r.RemoteAddr) })) defer cst.close() var numOpen, numClose int32 // atomic @@ -1143,13 +1143,13 @@ func testTransportDiscardsUnneededConns(t *testing.T, mode testMode) { // tests that Transport doesn't retain a pointer to the provided request. func TestTransportGCRequest(t *testing.T) { - run(t, func { t, mode | - t.Run("Body", func { t | testTransportGCRequest(t, mode, true) }) - t.Run("NoBody", func { t | testTransportGCRequest(t, mode, false) }) + run(t, func { t, mode -> + t.Run("Body", func { t -> testTransportGCRequest(t, mode, true) }) + t.Run("NoBody", func { t -> testTransportGCRequest(t, mode, false) }) }) } func testTransportGCRequest(t *testing.T, mode testMode, body bool) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> io.ReadAll(r.Body) if body { io.WriteString(w, "Hello.") @@ -1184,7 +1184,7 @@ func testTransportGCRequest(t *testing.T, mode testMode, body bool) { func TestTransportRejectsInvalidHeaders(t *testing.T) { run(t, testTransportRejectsInvalidHeaders) } func testTransportRejectsInvalidHeaders(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | fmt.Fprintf(w, "Handler saw headers: %q", r.Header) }), optQuietLog) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> fmt.Fprintf(w, "Handler saw headers: %q", r.Header) }), optQuietLog) cst.tr.DisableKeepAlives = true tests := []struct { @@ -1203,7 +1203,7 @@ func testTransportRejectsInvalidHeaders(t *testing.T, mode testMode) { } for _, tt := range tests { dialedc := make(chan bool, 1) - cst.tr.Dial = func { netw, addr | + cst.tr.Dial = func { netw, addr -> dialedc <- true return net.Dial(netw, addr) } @@ -1231,13 +1231,13 @@ func testTransportRejectsInvalidHeaders(t *testing.T, mode testMode) { } func TestInterruptWithPanic(t *testing.T) { - run(t, func { t, mode | - t.Run("boom", func { t | testInterruptWithPanic(t, mode, "boom") }) - t.Run("nil", func { t | + run(t, func { t, mode -> + t.Run("boom", func { t -> testInterruptWithPanic(t, mode, "boom") }) + t.Run("nil", func { t -> t.Setenv("GODEBUG", "panicnil=1") testInterruptWithPanic(t, mode, nil) }) - t.Run("ErrAbortHandler", func { t | testInterruptWithPanic(t, mode, ErrAbortHandler) }) + t.Run("ErrAbortHandler", func { t -> testInterruptWithPanic(t, mode, ErrAbortHandler) }) }, testNotParallel) } func testInterruptWithPanic(t *testing.T, mode testMode, panicValue any) { @@ -1248,7 +1248,7 @@ func testInterruptWithPanic(t *testing.T, mode testMode, panicValue any) { var errorLog lockedBytesBuffer gotHeaders := make(chan bool, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> io.WriteString(w, msg) w.(Flusher).Flush() @@ -1257,7 +1257,7 @@ func testInterruptWithPanic(t *testing.T, mode testMode, panicValue any) { case <-testDone: } panic(panicValue) - }), func { ts | ts.Config.ErrorLog = log.New(&errorLog, "", 0) }) + }), func { ts -> ts.Config.ErrorLog = log.New(&errorLog, "", 0) }) res, err := cst.c.Get(cst.ts.URL) if err != nil { t.Fatal(err) @@ -1278,7 +1278,7 @@ func testInterruptWithPanic(t *testing.T, mode testMode, panicValue any) { } wantStackLogged := panicValue != nil && panicValue != ErrAbortHandler - waitCondition(t, 10*time.Millisecond, func { d | + waitCondition(t, 10*time.Millisecond, func { d -> gotLog := logOutput() if !wantStackLogged { if gotLog == "" { @@ -1344,7 +1344,7 @@ func TestH12_AutoGzipWithDumpResponse(t *testing.T) { // Issue 14607 func TestCloseIdleConnections(t *testing.T) { run(t, testCloseIdleConnections) } func testCloseIdleConnections(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.Header().Set("X-Addr", r.RemoteAddr) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("X-Addr", r.RemoteAddr) })) get := func { res, err := cst.c.Get(cst.ts.URL) if err != nil { @@ -1384,7 +1384,7 @@ func (r testErrorReader) Read(p []byte) (n int, err error) { func TestNoSniffExpectRequestBody(t *testing.T) { run(t, testNoSniffExpectRequestBody) } func testNoSniffExpectRequestBody(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.WriteHeader(StatusUnauthorized) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.WriteHeader(StatusUnauthorized) })) // Set ExpectContinueTimeout non-zero so RoundTrip won't try to write it. cst.tr.ExpectContinueTimeout = 10 * time.Second @@ -1407,7 +1407,7 @@ func testNoSniffExpectRequestBody(t *testing.T, mode testMode) { func TestServerUndeclaredTrailers(t *testing.T) { run(t, testServerUndeclaredTrailers) } func testServerUndeclaredTrailers(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Foo", "Bar") w.Header().Set("Trailer:Foo", "Baz") w.(Flusher).Flush() @@ -1437,7 +1437,7 @@ func TestBadResponseAfterReadingBody(t *testing.T) { run(t, testBadResponseAfterReadingBody, []testMode{http1Mode}) } func testBadResponseAfterReadingBody(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> _, err := io.Copy(io.Discard, r.Body) if err != nil { t.Fatal(err) @@ -1464,7 +1464,7 @@ func testBadResponseAfterReadingBody(t *testing.T, mode testMode) { func TestWriteHeader0(t *testing.T) { run(t, testWriteHeader0) } func testWriteHeader0(t *testing.T, mode testMode) { gotpanic := make(chan bool, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> defer close(gotpanic) defer func() { if e := recover(); e != nil { @@ -1498,14 +1498,14 @@ func testWriteHeader0(t *testing.T, mode testMode) { // Issue 23010: don't be super strict checking WriteHeader's code if // it's not even valid to call WriteHeader then anyway. func TestWriteHeaderNoCodeCheck(t *testing.T) { - run(t, func { t, mode | testWriteHeaderAfterWrite(t, mode, false) }) + run(t, func { t, mode -> testWriteHeaderAfterWrite(t, mode, false) }) } func TestWriteHeaderNoCodeCheck_h1hijack(t *testing.T) { testWriteHeaderAfterWrite(t, http1Mode, true) } func testWriteHeaderAfterWrite(t *testing.T, mode testMode, hijack bool) { var errorLog lockedBytesBuffer - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if hijack { conn, _, _ := w.(Hijacker).Hijack() defer conn.Close() @@ -1518,7 +1518,7 @@ func testWriteHeaderAfterWrite(t *testing.T, mode testMode, hijack bool) { w.(Flusher).Flush() w.WriteHeader(0) // verify this doesn't panic if there's already output; Issue 23010 io.WriteString(w, "bar") - }), func { ts | ts.Config.ErrorLog = log.New(&errorLog, "", 0) }) + }), func { ts -> ts.Config.ErrorLog = log.New(&errorLog, "", 0) }) res, err := cst.c.Get(cst.ts.URL) if err != nil { t.Fatal(err) @@ -1552,7 +1552,7 @@ func TestBidiStreamReverseProxy(t *testing.T) { run(t, testBidiStreamReverseProxy, []testMode{http2Mode}) } func testBidiStreamReverseProxy(t *testing.T, mode testMode) { - backend := newClientServerTest(t, mode, HandlerFunc(func { w, r | if _, err := io.Copy(w, r.Body); err != nil { + backend := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if _, err := io.Copy(w, r.Body); err != nil { log.Printf("bidi backend copy: %v", err) } })) @@ -1562,7 +1562,7 @@ func testBidiStreamReverseProxy(t *testing.T, mode testMode) { } rp := httputil.NewSingleHostReverseProxy(backURL) rp.Transport = backend.tr - proxy := newClientServerTest(t, mode, HandlerFunc(func { w, r | rp.ServeHTTP(w, r) })) + proxy := newClientServerTest(t, mode, HandlerFunc(func { w, r -> rp.ServeHTTP(w, r) })) bodyRes := make(chan any, 1) // error or hash.Hash pr, pw := io.Pipe() @@ -1632,7 +1632,7 @@ func TestH12_WebSocketUpgrade(t *testing.T) { func TestIdentityTransferEncoding(t *testing.T) { run(t, testIdentityTransferEncoding) } func testIdentityTransferEncoding(t *testing.T, mode testMode) { const body = "body" - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> gotBody, _ := io.ReadAll(r.Body) if got, want := string(gotBody), body; got != want { t.Errorf("got request body = %q; want %q", got, want) @@ -1661,7 +1661,7 @@ func TestEarlyHintsRequest(t *testing.T) { run(t, testEarlyHintsRequest) } func testEarlyHintsRequest(t *testing.T, mode testMode) { var wg sync.WaitGroup wg.Add(1) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> h := w.Header() h.Add("Content-Length", "123") // must be ignored diff --git a/src/net/http/cookiejar/example_test.go b/src/net/http/cookiejar/example_test.go index 2c4db27877ca1..6027c77ac32b4 100644 --- a/src/net/http/cookiejar/example_test.go +++ b/src/net/http/cookiejar/example_test.go @@ -15,7 +15,7 @@ import ( func ExampleNew() { // Start a server to give us cookies. - ts := httptest.NewServer(http.HandlerFunc(func { w, r | + ts := httptest.NewServer(http.HandlerFunc(func { w, r -> if cookie, err := r.Cookie("Flavor"); err != nil { http.SetCookie(w, &http.Cookie{Name: "Flavor", Value: "Chocolate Chip"}) } else { diff --git a/src/net/http/cookiejar/jar.go b/src/net/http/cookiejar/jar.go index 884cc5817c821..b028e5712d0da 100644 --- a/src/net/http/cookiejar/jar.go +++ b/src/net/http/cookiejar/jar.go @@ -211,7 +211,7 @@ func (j *Jar) cookies(u *url.URL, now time.Time) (cookies []*http.Cookie) { // sort according to RFC 6265 section 5.4 point 2: by longest // path and then by earliest creation time. - slices.SortFunc(selected, func { a, b | + slices.SortFunc(selected, func { a, b -> if r := cmp.Compare(b.Path, a.Path); r != 0 { return r } diff --git a/src/net/http/example_test.go b/src/net/http/example_test.go index f7487c88a185f..7003a9af304b3 100644 --- a/src/net/http/example_test.go +++ b/src/net/http/example_test.go @@ -15,7 +15,7 @@ import ( ) func ExampleHijacker() { - http.HandleFunc("/hijack", func { w, r | + http.HandleFunc("/hijack", func { w, r -> hj, ok := w.(http.Hijacker) if !ok { http.Error(w, "webserver doesn't support hijacking", http.StatusInternalServerError) @@ -82,7 +82,7 @@ func (apiHandler) ServeHTTP(http.ResponseWriter, *http.Request) {} func ExampleServeMux_Handle() { mux := http.NewServeMux() mux.Handle("/api/", apiHandler{}) - mux.HandleFunc("/", func { w, req | + mux.HandleFunc("/", func { w, req -> // The "/" pattern matches everything, so we need to check // that we're at the root here. if req.URL.Path != "/" { @@ -97,7 +97,7 @@ func ExampleServeMux_Handle() { // after the HTTP response, instead of before. func ExampleResponseWriter_trailers() { mux := http.NewServeMux() - mux.HandleFunc("/sendstrailers", func { w, req | + mux.HandleFunc("/sendstrailers", func { w, req -> // Before any call to WriteHeader or Write, declare // the trailers you will set during the HTTP // response. These three headers are actually sent in @@ -141,7 +141,7 @@ func ExampleServer_Shutdown() { } func ExampleListenAndServeTLS() { - http.HandleFunc("/", func { w, req | io.WriteString(w, "Hello, TLS!\n") }) + http.HandleFunc("/", func { w, req -> io.WriteString(w, "Hello, TLS!\n") }) // One can use generate_cert.go in crypto/tls to generate cert.pem and key.pem. log.Printf("About to listen on 8443. Go to https://127.0.0.1:8443/") @@ -175,7 +175,7 @@ func ExampleHandleFunc() { } func newPeopleHandler() http.Handler { - return http.HandlerFunc(func { w, r | fmt.Fprintln(w, "This is the people handler.") }) + return http.HandlerFunc(func { w, r -> fmt.Fprintln(w, "This is the people handler.") }) } func ExampleNotFoundHandler() { diff --git a/src/net/http/export_test.go b/src/net/http/export_test.go index d53f8c7460b67..68d13cc2464ac 100644 --- a/src/net/http/export_test.go +++ b/src/net/http/export_test.go @@ -44,7 +44,7 @@ func init() { // and never assigned to. testHookMu = new(sync.Mutex) - testHookClientDoResult = func { res, err | + testHookClientDoResult = func { res, err -> if err != nil { if _, ok := err.(*url.Error); !ok { panic(fmt.Sprintf("unexpected Client.Do error of type %T; want *url.Error", err)) diff --git a/src/net/http/fcgi/fcgi_test.go b/src/net/http/fcgi/fcgi_test.go index 140add61a0a70..f07b5c662a6e9 100644 --- a/src/net/http/fcgi/fcgi_test.go +++ b/src/net/http/fcgi/fcgi_test.go @@ -243,7 +243,7 @@ func TestChildServeCleansUp(t *testing.T) { rc := nopWriteCloser{bytes.NewReader(input)} done := make(chan struct{}) c := newChild(rc, http.HandlerFunc(func { w, - r | + r -> // block on reading body of request _, err := io.Copy(io.Discard, r.Body) if err != tt.err { @@ -331,7 +331,7 @@ func TestChildServeReadsEnvVars(t *testing.T) { rc := nopWriteCloser{bytes.NewReader(input)} done := make(chan struct{}) c := newChild(rc, http.HandlerFunc(func { w, - r | + r -> env := ProcessEnv(r) if _, ok := env[tt.envVar]; ok && tt.expectedFilteredOut { t.Errorf("Expected environment variable %s to not be set, but set to %s", @@ -373,14 +373,14 @@ func TestResponseWriterSniffsContentType(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> input := make([]byte, len(streamFullRequestStdin)) copy(input, streamFullRequestStdin) rc := nopWriteCloser{bytes.NewReader(input)} done := make(chan struct{}) var resp *response c := newChild(rc, http.HandlerFunc(func { w, - r | + r -> io.WriteString(w, tt.body) resp = w.(*response) close(done) @@ -433,7 +433,7 @@ func TestSlowRequest(t *testing.T) { handlerDone := make(chan bool) c := newChild(rc, http.HandlerFunc(func { w, - r | + r -> w.WriteHeader(200) close(handlerDone) })) diff --git a/src/net/http/fs.go b/src/net/http/fs.go index f41229e593bc0..7a3c3566caaa0 100644 --- a/src/net/http/fs.go +++ b/src/net/http/fs.go @@ -152,7 +152,7 @@ func dirList(w ResponseWriter, r *Request, f File) { Error(w, "Error reading directory", StatusInternalServerError) return } - sort.Slice(dirs, func { i, j | return dirs.name(i) < dirs.name(j) }) + sort.Slice(dirs, func { i, j -> return dirs.name(i) < dirs.name(j) }) w.Header().Set("Content-Type", "text/html; charset=utf-8") fmt.Fprintf(w, "\n") @@ -884,7 +884,7 @@ func (f ioFS) Open(name string) (File, error) { } file, err := f.fsys.Open(name) if err != nil { - return nil, mapOpenError(err, name, '/', func { path | return fs.Stat(f.fsys, path) }) + return nil, mapOpenError(err, name, '/', func { path -> return fs.Stat(f.fsys, path) }) } return ioFile{file}, nil } diff --git a/src/net/http/fs_test.go b/src/net/http/fs_test.go index a3d28fafc7e89..d5508549c5b7e 100644 --- a/src/net/http/fs_test.go +++ b/src/net/http/fs_test.go @@ -74,7 +74,7 @@ var ServeFileRangeTests = []struct { func TestServeFile(t *testing.T) { run(t, testServeFile) } func testServeFile(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | ServeFile(w, r, "testdata/file") })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ServeFile(w, r, "testdata/file") })).ts c := ts.Client() var err error @@ -499,7 +499,7 @@ func TestEmptyDirOpenCWD(t *testing.T) { func TestServeFileContentType(t *testing.T) { run(t, testServeFileContentType) } func testServeFileContentType(t *testing.T, mode testMode) { const ctype = "icecream/chocolate" - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> switch r.FormValue("override") { case "1": w.Header().Set("Content-Type", ctype) @@ -526,7 +526,7 @@ func testServeFileContentType(t *testing.T, mode testMode) { func TestServeFileMimeType(t *testing.T) { run(t, testServeFileMimeType) } func testServeFileMimeType(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | ServeFile(w, r, "testdata/style.css") })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ServeFile(w, r, "testdata/style.css") })).ts resp, err := ts.Client().Get(ts.URL) if err != nil { t.Fatal(err) @@ -540,7 +540,7 @@ func testServeFileMimeType(t *testing.T, mode testMode) { func TestServeFileFromCWD(t *testing.T) { run(t, testServeFileFromCWD) } func testServeFileFromCWD(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | ServeFile(w, r, "fs_test.go") })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ServeFile(w, r, "fs_test.go") })).ts r, err := ts.Client().Get(ts.URL) if err != nil { t.Fatal(err) @@ -555,7 +555,7 @@ func testServeFileFromCWD(t *testing.T, mode testMode) { func TestServeDirWithoutTrailingSlash(t *testing.T) { run(t, testServeDirWithoutTrailingSlash) } func testServeDirWithoutTrailingSlash(t *testing.T, mode testMode) { e := "/testdata/" - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | ServeFile(w, r, ".") })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ServeFile(w, r, ".") })).ts r, err := ts.Client().Get(ts.URL + "/testdata") if err != nil { t.Fatal(err) @@ -570,7 +570,7 @@ func testServeDirWithoutTrailingSlash(t *testing.T, mode testMode) { // specified. func TestServeFileWithContentEncoding(t *testing.T) { run(t, testServeFileWithContentEncoding) } func testServeFileWithContentEncoding(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Encoding", "foo") ServeFile(w, r, "testdata/file") @@ -597,7 +597,7 @@ func testServeFileWithContentEncoding(t *testing.T, mode testMode) { // file has not been modified, as per RFC 7232 section 4.1. func TestServeFileNotModified(t *testing.T) { run(t, testServeFileNotModified) } func testServeFileNotModified(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Type", "application/json") w.Header().Set("Content-Encoding", "foo") w.Header().Set("Etag", `"123"`) @@ -657,7 +657,7 @@ func testServeIndexHtml(t *testing.T, mode testMode) { h = FileServer(FS(os.DirFS("."))) name = "DirFS" } - t.Run(name, func { t | + t.Run(name, func { t -> const want = "index.html says hello\n" ts := newClientServerTest(t, mode, h).ts @@ -897,7 +897,7 @@ func testServeContent(t *testing.T, mode testMode) { etag string } servec := make(chan serveParam, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> p := <-servec if p.etag != "" { w.Header().Set("ETag", p.etag) @@ -1216,9 +1216,9 @@ func (issue12991File) Stat() (fs.FileInfo, error) { return nil, fs.ErrPermission func (issue12991File) Close() error { return nil } func TestFileServerErrorMessages(t *testing.T) { - run(t, func { t, mode | - t.Run("keepheaders=0", func { t | testFileServerErrorMessages(t, mode, false) }) - t.Run("keepheaders=1", func { t | testFileServerErrorMessages(t, mode, true) }) + run(t, func { t, mode -> + t.Run("keepheaders=0", func { t -> testFileServerErrorMessages(t, mode, false) }) + t.Run("keepheaders=1", func { t -> testFileServerErrorMessages(t, mode, true) }) }, testNotParallel) } func testFileServerErrorMessages(t *testing.T, mode testMode, keepHeaders bool) { @@ -1366,9 +1366,9 @@ func TestLinuxSendfileChild(*testing.T) { // Issues 18984, 49552: tests that requests for paths beyond files return not-found errors func TestFileServerNotDirError(t *testing.T) { - run(t, func { t, mode | - t.Run("Dir", func { t | testFileServerNotDirError(t, mode, func { path | return Dir(path) }) }) - t.Run("FS", func { t | testFileServerNotDirError(t, mode, func { path | return FS(os.DirFS(path)) }) }) + run(t, func { t, mode -> + t.Run("Dir", func { t -> testFileServerNotDirError(t, mode, func { path -> return Dir(path) }) }) + t.Run("FS", func { t -> testFileServerNotDirError(t, mode, func { path -> return FS(os.DirFS(path)) }) }) }) } @@ -1385,7 +1385,7 @@ func testFileServerNotDirError(t *testing.T, mode testMode, newfs func(string) F } test := func(name string, fsys FileSystem) { - t.Run(name, func { t | + t.Run(name, func { t -> _, err = fsys.Open("/index.html/not-a-file") if err == nil { t.Fatal("err == nil; want != nil") @@ -1502,7 +1502,7 @@ func testServeFileRejectsInvalidSuffixLengths(t *testing.T, mode testMode) { for _, tt := range tests { tt := tt - t.Run(tt.r, func { t | + t.Run(tt.r, func { t -> req, err := NewRequest("GET", cst.URL+"/index.html", nil) if err != nil { t.Fatal(err) @@ -1605,7 +1605,7 @@ func TestServeFileFS(t *testing.T) { fsys := fstest.MapFS{ filename: {Data: contents}, } - ts := newClientServerTest(t, http1Mode, HandlerFunc(func { w, r | ServeFileFS(w, r, fsys, filename) })).ts + ts := newClientServerTest(t, http1Mode, HandlerFunc(func { w, r -> ServeFileFS(w, r, fsys, filename) })).ts defer ts.Close() res, err := ts.Client().Get(ts.URL + "/" + filename) @@ -1641,7 +1641,7 @@ func TestServeFileZippingResponseWriter(t *testing.T) { fsys := fstest.MapFS{ filename: {Data: contents}, } - ts := newClientServerTest(t, http1Mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, http1Mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Encoding", "gzip") gzw := gzip.NewWriter(w) defer gzw.Close() @@ -1696,21 +1696,21 @@ func testFileServerDirWithRootFile(t *testing.T, mode testMode) { res.Body.Close() } - t.Run("FileServer", func { t | testDirFile(t, FileServer(Dir("testdata/index.html"))) }) + t.Run("FileServer", func { t -> testDirFile(t, FileServer(Dir("testdata/index.html"))) }) - t.Run("FileServerFS", func { t | testDirFile(t, FileServerFS(os.DirFS("testdata/index.html"))) }) + t.Run("FileServerFS", func { t -> testDirFile(t, FileServerFS(os.DirFS("testdata/index.html"))) }) } func TestServeContentHeadersWithError(t *testing.T) { - t.Run("keepheaders=0", func { t | testServeContentHeadersWithError(t, false) }) - t.Run("keepheaders=1", func { t | testServeContentHeadersWithError(t, true) }) + t.Run("keepheaders=0", func { t -> testServeContentHeadersWithError(t, false) }) + t.Run("keepheaders=1", func { t -> testServeContentHeadersWithError(t, true) }) } func testServeContentHeadersWithError(t *testing.T, keepHeaders bool) { if keepHeaders { t.Setenv("GODEBUG", "httpservecontentkeepheaders=1") } contents := []byte("content") - ts := newClientServerTest(t, http1Mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, http1Mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Type", "application/octet-stream") w.Header().Set("Content-Length", strconv.Itoa(len(contents))) w.Header().Set("Content-Encoding", "gzip") diff --git a/src/net/http/h2_bundle.go b/src/net/http/h2_bundle.go index 6813a8f9ce8bd..ca2c6769ae038 100644 --- a/src/net/http/h2_bundle.go +++ b/src/net/http/h2_bundle.go @@ -1845,7 +1845,7 @@ func http2NewFramer(w io.Writer, r io.Reader) *http2Framer { debugReadLoggerf: log.Printf, debugWriteLoggerf: log.Printf, } - fr.getReadBuf = func { size | + fr.getReadBuf = func { size -> if cap(fr.readBuf) >= int(size) { return fr.readBuf[:size] } @@ -2946,7 +2946,7 @@ func (fr *http2Framer) readMetaFrame(hf *http2HeadersFrame) (http2Frame, error) hdec := fr.ReadMetaHeaders hdec.SetEmitEnabled(true) hdec.SetMaxStringLength(fr.maxHeaderStringLen()) - hdec.SetEmitFunc(func { hf | + hdec.SetEmitFunc(func { hf -> if http2VerboseLogs && fr.logReads { fr.debugReadLoggerf("http2: decoded hpack field %+v", hf) } @@ -2983,7 +2983,7 @@ func (fr *http2Framer) readMetaFrame(hf *http2HeadersFrame) (http2Frame, error) mh.Fields = append(mh.Fields, hf) }) // Lose reference to MetaHeadersFrame: - defer hdec.SetEmitFunc(func { hf | }) + defer hdec.SetEmitFunc(func { hf -> }) var hc http2headersOrContinuation = hf for { @@ -3061,7 +3061,7 @@ func http2summarizeFrame(f http2Frame) string { switch f := f.(type) { case *http2SettingsFrame: n := 0 - f.ForeachSetting(func { s | + f.ForeachSetting(func { s -> n++ if n == 1 { buf.WriteString(", settings:") @@ -6646,7 +6646,7 @@ func (w *http2responseWriter) SetReadDeadline(deadline time.Time) error { st.onReadTimeout() return nil } - w.rws.conn.sendServeMsg(func { sc | + w.rws.conn.sendServeMsg(func { sc -> if st.readDeadline != nil { if !st.readDeadline.Stop() { // Deadline already exceeded, or stream has been closed. @@ -6672,7 +6672,7 @@ func (w *http2responseWriter) SetWriteDeadline(deadline time.Time) error { st.onWriteTimeout() return nil } - w.rws.conn.sendServeMsg(func { sc | + w.rws.conn.sendServeMsg(func { sc -> if st.writeDeadline != nil { if !st.writeDeadline.Stop() { // Deadline already exceeded, or stream has been closed. @@ -9242,7 +9242,7 @@ func (cc *http2ClientConn) encodeHeaders(req *Request, addGzipHeader bool, trail // separate pass before encoding the headers to prevent // modifying the hpack state. hlSize := uint64(0) - enumerateHeaders(func { name, value | + enumerateHeaders(func { name, value -> hf := hpack.HeaderField{Name: name, Value: value} hlSize += uint64(hf.Size()) }) @@ -9255,7 +9255,7 @@ func (cc *http2ClientConn) encodeHeaders(req *Request, addGzipHeader bool, trail traceHeaders := http2traceHasWroteHeaderField(trace) // Header list size is ok. Write the headers. - enumerateHeaders(func { name, value | + enumerateHeaders(func { name, value -> name, ascii := http2lowerHeader(name) if !ascii { // Skip writing invalid headers. Per RFC 7540, Section 8.1.2, header @@ -9648,7 +9648,7 @@ func (rl *http2clientConnReadLoop) handleResponse(cs *http2clientStream, f *http t = make(Header) res.Trailer = t } - http2foreachHeaderElement(hf.Value, func { v | t[http2canonicalHeader(v)] = nil }) + http2foreachHeaderElement(hf.Value, func { v -> t[http2canonicalHeader(v)] = nil }) } else { vv := header[key] if vv == nil && len(strs) > 0 { @@ -10061,7 +10061,7 @@ func (rl *http2clientConnReadLoop) processSettingsNoWrite(f *http2SettingsFrame) } var seenMaxConcurrentStreams bool - err := f.ForeachSetting(func { s | + err := f.ForeachSetting(func { s -> switch s.ID { case http2SettingMaxFrameSize: cc.maxFrameSize = s.Val @@ -11470,7 +11470,7 @@ func (ws *http2priorityWriteScheduler) Push(wr http2FrameWriteRequest) { } func (ws *http2priorityWriteScheduler) Pop() (wr http2FrameWriteRequest, ok bool) { - ws.root.walkReadyInOrder(false, &ws.tmp, func { n, openParent | + ws.root.walkReadyInOrder(false, &ws.tmp, func { n, openParent -> limit := int32(math.MaxInt32) if openParent { limit = ws.writeThrottleLimit diff --git a/src/net/http/header.go b/src/net/http/header.go index acbb6f45cfa47..44621a126d481 100644 --- a/src/net/http/header.go +++ b/src/net/http/header.go @@ -176,7 +176,7 @@ func (h Header) sortedKeyValues(exclude map[string]bool) (kvs []keyValues, hs *h } } hs.kvs = kvs - slices.SortFunc(hs.kvs, func { a, b | return strings.Compare(a.key, b.key) }) + slices.SortFunc(hs.kvs, func { a, b -> return strings.Compare(a.key, b.key) }) return kvs, hs } diff --git a/src/net/http/header_test.go b/src/net/http/header_test.go index 41b23e14587e9..25a9473835cad 100644 --- a/src/net/http/header_test.go +++ b/src/net/http/header_test.go @@ -257,7 +257,7 @@ func TestCloneOrMakeHeader(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> got := cloneOrMakeHeader(tt.in) if got == nil { t.Fatal("unexpected nil Header") diff --git a/src/net/http/http_test.go b/src/net/http/http_test.go index 96cf8732917f6..1a40500b440f7 100644 --- a/src/net/http/http_test.go +++ b/src/net/http/http_test.go @@ -38,7 +38,7 @@ func TestForeachHeaderElement(t *testing.T) { } for _, tt := range tests { var got []string - foreachHeaderElement(tt.in, func { v | got = append(got, v) }) + foreachHeaderElement(tt.in, func { v -> got = append(got, v) }) if !reflect.DeepEqual(got, tt.want) { t.Errorf("foreachHeaderElement(%q) = %q; want %q", tt.in, got, tt.want) } @@ -154,7 +154,7 @@ func TestNoUnicodeStrings(t *testing.T) { } re := regexp.MustCompile(`(strings|bytes).([A-Za-z]+)`) - if err := fs.WalkDir(os.DirFS("."), ".", func { path, d, err | + if err := fs.WalkDir(os.DirFS("."), ".", func { path, d, err -> if err != nil { t.Fatal(err) } diff --git a/src/net/http/httptest/example_test.go b/src/net/http/httptest/example_test.go index cf694fa2340b1..5410d62a3bd60 100644 --- a/src/net/http/httptest/example_test.go +++ b/src/net/http/httptest/example_test.go @@ -35,7 +35,7 @@ func ExampleResponseRecorder() { } func ExampleServer() { - ts := httptest.NewServer(http.HandlerFunc(func { w, r | fmt.Fprintln(w, "Hello, client") })) + ts := httptest.NewServer(http.HandlerFunc(func { w, r -> fmt.Fprintln(w, "Hello, client") })) defer ts.Close() res, err := http.Get(ts.URL) @@ -53,7 +53,7 @@ func ExampleServer() { } func ExampleServer_hTTP2() { - ts := httptest.NewUnstartedServer(http.HandlerFunc(func { w, r | fmt.Fprintf(w, "Hello, %s", r.Proto) })) + ts := httptest.NewUnstartedServer(http.HandlerFunc(func { w, r -> fmt.Fprintf(w, "Hello, %s", r.Proto) })) ts.EnableHTTP2 = true ts.StartTLS() defer ts.Close() @@ -73,7 +73,7 @@ func ExampleServer_hTTP2() { } func ExampleNewTLSServer() { - ts := httptest.NewTLSServer(http.HandlerFunc(func { w, r | fmt.Fprintln(w, "Hello, client") })) + ts := httptest.NewTLSServer(http.HandlerFunc(func { w, r -> fmt.Fprintln(w, "Hello, client") })) defer ts.Close() client := ts.Client() diff --git a/src/net/http/httptest/httptest_test.go b/src/net/http/httptest/httptest_test.go index 2ee99c13ce090..5d0e799b48ea7 100644 --- a/src/net/http/httptest/httptest_test.go +++ b/src/net/http/httptest/httptest_test.go @@ -173,7 +173,7 @@ func TestNewRequestWithContext(t *testing.T) { }, }, } { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> got := NewRequestWithContext(context.Background(), tt.method, tt.uri, tt.body) slurp, err := io.ReadAll(got.Body) if err != nil { diff --git a/src/net/http/httptest/recorder_test.go b/src/net/http/httptest/recorder_test.go index acbd1ead69a50..2c7e8fd0d2b74 100644 --- a/src/net/http/httptest/recorder_test.go +++ b/src/net/http/httptest/recorder_test.go @@ -295,7 +295,7 @@ func TestRecorder(t *testing.T) { }, } { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> r, _ := http.NewRequest("GET", "http://foo.com/", nil) h := http.HandlerFunc(tt.h) rec := NewRecorder() @@ -353,7 +353,7 @@ func TestRecorderPanicsOnNonXXXStatusCode(t *testing.T) { } for _, badCode := range badCodes { badCode := badCode - t.Run(fmt.Sprintf("Code=%d", badCode), func { t | + t.Run(fmt.Sprintf("Code=%d", badCode), func { t -> defer func() { if r := recover(); r == nil { t.Fatal("Expected a panic") diff --git a/src/net/http/httptest/server.go b/src/net/http/httptest/server.go index 730c7e8472378..416f38f9632b2 100644 --- a/src/net/http/httptest/server.go +++ b/src/net/http/httptest/server.go @@ -316,7 +316,7 @@ func (s *Server) goServe() { // connections are idle. func (s *Server) wrap() { oldHook := s.Config.ConnState - s.Config.ConnState = func { c, cs | + s.Config.ConnState = func { c, cs -> s.mu.Lock() defer s.mu.Unlock() diff --git a/src/net/http/httptest/server_test.go b/src/net/http/httptest/server_test.go index 00986943914a5..17ec776da7b82 100644 --- a/src/net/http/httptest/server_test.go +++ b/src/net/http/httptest/server_test.go @@ -35,26 +35,26 @@ var newServers = map[string]newServerFunc{ func TestServer(t *testing.T) { for _, name := range []string{"NewServer", "NewServerManual"} { - t.Run(name, func { t | + t.Run(name, func { t -> newServer := newServers[name] - t.Run("Server", func { t | testServer(t, newServer) }) - t.Run("GetAfterClose", func { t | testGetAfterClose(t, newServer) }) - t.Run("ServerCloseBlocking", func { t | testServerCloseBlocking(t, newServer) }) - t.Run("ServerCloseClientConnections", func { t | testServerCloseClientConnections(t, newServer) }) - t.Run("ServerClientTransportType", func { t | testServerClientTransportType(t, newServer) }) + t.Run("Server", func { t -> testServer(t, newServer) }) + t.Run("GetAfterClose", func { t -> testGetAfterClose(t, newServer) }) + t.Run("ServerCloseBlocking", func { t -> testServerCloseBlocking(t, newServer) }) + t.Run("ServerCloseClientConnections", func { t -> testServerCloseClientConnections(t, newServer) }) + t.Run("ServerClientTransportType", func { t -> testServerClientTransportType(t, newServer) }) }) } for _, name := range []string{"NewTLSServer", "NewTLSServerManual"} { - t.Run(name, func { t | + t.Run(name, func { t -> newServer := newServers[name] - t.Run("ServerClient", func { t | testServerClient(t, newServer) }) - t.Run("TLSServerClientTransportType", func { t | testTLSServerClientTransportType(t, newServer) }) + t.Run("ServerClient", func { t -> testServerClient(t, newServer) }) + t.Run("TLSServerClientTransportType", func { t -> testTLSServerClientTransportType(t, newServer) }) }) } } func testServer(t *testing.T, newServer newServerFunc) { - ts := newServer(http.HandlerFunc(func { w, r | w.Write([]byte("hello")) })) + ts := newServer(http.HandlerFunc(func { w, r -> w.Write([]byte("hello")) })) defer ts.Close() res, err := http.Get(ts.URL) if err != nil { @@ -72,7 +72,7 @@ func testServer(t *testing.T, newServer newServerFunc) { // Issue 12781 func testGetAfterClose(t *testing.T, newServer newServerFunc) { - ts := newServer(http.HandlerFunc(func { w, r | w.Write([]byte("hello")) })) + ts := newServer(http.HandlerFunc(func { w, r -> w.Write([]byte("hello")) })) res, err := http.Get(ts.URL) if err != nil { @@ -97,7 +97,7 @@ func testGetAfterClose(t *testing.T, newServer newServerFunc) { } func testServerCloseBlocking(t *testing.T, newServer newServerFunc) { - ts := newServer(http.HandlerFunc(func { w, r | w.Write([]byte("hello")) })) + ts := newServer(http.HandlerFunc(func { w, r -> w.Write([]byte("hello")) })) dial := func { c, err := net.Dial("tcp", ts.Listener.Addr().String()) if err != nil { @@ -125,7 +125,7 @@ func testServerCloseBlocking(t *testing.T, newServer newServerFunc) { // Issue 14290 func testServerCloseClientConnections(t *testing.T, newServer newServerFunc) { var s *Server - s = newServer(http.HandlerFunc(func { w, r | s.CloseClientConnections() })) + s = newServer(http.HandlerFunc(func { w, r -> s.CloseClientConnections() })) defer s.Close() res, err := http.Get(s.URL) if err == nil { @@ -137,7 +137,7 @@ func testServerCloseClientConnections(t *testing.T, newServer newServerFunc) { // Tests that the Server.Client method works and returns an http.Client that can hit // NewTLSServer without cert warnings. func testServerClient(t *testing.T, newTLSServer newServerFunc) { - ts := newTLSServer(http.HandlerFunc(func { w, r | w.Write([]byte("hello")) })) + ts := newTLSServer(http.HandlerFunc(func { w, r -> w.Write([]byte("hello")) })) defer ts.Close() client := ts.Client() res, err := client.Get(ts.URL) @@ -157,7 +157,7 @@ func testServerClient(t *testing.T, newTLSServer newServerFunc) { // Tests that the Server.Client.Transport interface is implemented // by a *http.Transport. func testServerClientTransportType(t *testing.T, newServer newServerFunc) { - ts := newServer(http.HandlerFunc(func { w, r | })) + ts := newServer(http.HandlerFunc(func { w, r -> })) defer ts.Close() client := ts.Client() if _, ok := client.Transport.(*http.Transport); !ok { @@ -168,7 +168,7 @@ func testServerClientTransportType(t *testing.T, newServer newServerFunc) { // Tests that the TLS Server.Client.Transport interface is implemented // by a *http.Transport. func testTLSServerClientTransportType(t *testing.T, newTLSServer newServerFunc) { - ts := newTLSServer(http.HandlerFunc(func { w, r | })) + ts := newTLSServer(http.HandlerFunc(func { w, r -> })) defer ts.Close() client := ts.Client() if _, ok := client.Transport.(*http.Transport); !ok { @@ -197,7 +197,7 @@ func TestServerZeroValueClose(t *testing.T) { // concurrently with closing the server. func TestCloseHijackedConnection(t *testing.T) { hijacked := make(chan net.Conn) - ts := NewServer(http.HandlerFunc(func { w, r | + ts := NewServer(http.HandlerFunc(func { w, r -> defer close(hijacked) hj, ok := w.(http.Hijacker) if !ok { @@ -256,8 +256,8 @@ func TestTLSServerWithHTTP2(t *testing.T) { } for _, tt := range modes { - t.Run(tt.name, func { t | - cst := NewUnstartedServer(http.HandlerFunc(func { w, r | w.Header().Set("X-Proto", r.Proto) })) + t.Run(tt.name, func { t -> + cst := NewUnstartedServer(http.HandlerFunc(func { w, r -> w.Header().Set("X-Proto", r.Proto) })) switch tt.name { case "http2": diff --git a/src/net/http/httptrace/trace.go b/src/net/http/httptrace/trace.go index 82c81ef0e08d3..ce5771aeda166 100644 --- a/src/net/http/httptrace/trace.go +++ b/src/net/http/httptrace/trace.go @@ -45,10 +45,10 @@ func WithClientTrace(ctx context.Context, trace *ClientTrace) context.Context { ConnectDone: trace.ConnectDone, } if trace.DNSStart != nil { - nt.DNSStart = func { name | trace.DNSStart(DNSStartInfo{Host: name}) } + nt.DNSStart = func { name -> trace.DNSStart(DNSStartInfo{Host: name}) } } if trace.DNSDone != nil { - nt.DNSDone = func { netIPs, coalesced, err | + nt.DNSDone = func { netIPs, coalesced, err -> addrs := make([]net.IPAddr, len(netIPs)) for i, ip := range netIPs { addrs[i] = ip.(net.IPAddr) @@ -197,7 +197,7 @@ func (t *ClientTrace) compose(old *ClientTrace) { tfCopy := reflect.ValueOf(tf.Interface()) // We need to call both tf and of in some order. - newFunc := reflect.MakeFunc(hookType, func { args | + newFunc := reflect.MakeFunc(hookType, func { args -> tfCopy.Call(args) return of.Call(args) }) diff --git a/src/net/http/httputil/example_test.go b/src/net/http/httputil/example_test.go index db98d8bd7cb2e..c05f37895477b 100644 --- a/src/net/http/httputil/example_test.go +++ b/src/net/http/httputil/example_test.go @@ -16,7 +16,7 @@ import ( ) func ExampleDumpRequest() { - ts := httptest.NewServer(http.HandlerFunc(func { w, r | + ts := httptest.NewServer(http.HandlerFunc(func { w, r -> dump, err := httputil.DumpRequest(r, true) if err != nil { http.Error(w, fmt.Sprint(err), http.StatusInternalServerError) @@ -70,7 +70,7 @@ func ExampleDumpRequestOut() { func ExampleDumpResponse() { const body = "Go is a general-purpose language designed with systems programming in mind." - ts := httptest.NewServer(http.HandlerFunc(func { w, r | + ts := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Header().Set("Date", "Wed, 19 Jul 1972 19:00:00 GMT") fmt.Fprintln(w, body) })) @@ -94,7 +94,7 @@ func ExampleDumpResponse() { } func ExampleReverseProxy() { - backendServer := httptest.NewServer(http.HandlerFunc(func { w, r | fmt.Fprintln(w, "this call was relayed by the reverse proxy") })) + backendServer := httptest.NewServer(http.HandlerFunc(func { w, r -> fmt.Fprintln(w, "this call was relayed by the reverse proxy") })) defer backendServer.Close() rpURL, err := url.Parse(backendServer.URL) diff --git a/src/net/http/httputil/reverseproxy_test.go b/src/net/http/httputil/reverseproxy_test.go index 711e86d512462..3dcfd7409d195 100644 --- a/src/net/http/httputil/reverseproxy_test.go +++ b/src/net/http/httputil/reverseproxy_test.go @@ -40,7 +40,7 @@ func init() { func TestReverseProxy(t *testing.T) { const backendResponse = "I am the backend" const backendStatus = 404 - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> if r.Method == "GET" && r.FormValue("mode") == "hangup" { c, _, _ := w.(http.Hijacker).Hijack() c.Close() @@ -163,7 +163,7 @@ func TestReverseProxyStripHeadersPresentInConnection(t *testing.T) { // in the Request's Connection header. const someConnHeader = "X-Some-Conn-Header" - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> if c := r.Header.Get("Connection"); c != "" { t.Errorf("handler got header %q = %q; want empty", "Connection", c) } @@ -185,7 +185,7 @@ func TestReverseProxyStripHeadersPresentInConnection(t *testing.T) { t.Fatal(err) } proxyHandler := NewSingleHostReverseProxy(backendURL) - frontend := httptest.NewServer(http.HandlerFunc(func { w, r | + frontend := httptest.NewServer(http.HandlerFunc(func { w, r -> proxyHandler.ServeHTTP(w, r) if c := r.Header.Get(someConnHeader); c != "should be deleted" { t.Errorf("handler modified header %q = %q; want %q", someConnHeader, c, "should be deleted") @@ -247,7 +247,7 @@ func TestReverseProxyStripEmptyConnection(t *testing.T) { // in the Request's Connection header. const someConnHeader = "X-Some-Conn-Header" - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> if c := r.Header.Values("Connection"); len(c) != 0 { t.Errorf("handler got header %q = %v; want empty", "Connection", c) } @@ -265,7 +265,7 @@ func TestReverseProxyStripEmptyConnection(t *testing.T) { t.Fatal(err) } proxyHandler := NewSingleHostReverseProxy(backendURL) - frontend := httptest.NewServer(http.HandlerFunc(func { w, r | + frontend := httptest.NewServer(http.HandlerFunc(func { w, r -> proxyHandler.ServeHTTP(w, r) if c := r.Header.Get(someConnHeader); c != "should be deleted" { t.Errorf("handler modified header %q = %q; want %q", someConnHeader, c, "should be deleted") @@ -301,7 +301,7 @@ func TestXForwardedFor(t *testing.T) { const prevForwardedFor = "client ip" const backendResponse = "I am the backend" const backendStatus = 404 - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> if r.Header.Get("X-Forwarded-For") == "" { t.Errorf("didn't get X-Forwarded-For header") } @@ -339,7 +339,7 @@ func TestXForwardedFor(t *testing.T) { // Issue 38079: don't append to X-Forwarded-For if it's present but nil func TestXForwardedFor_Omit(t *testing.T) { - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> if v := r.Header.Get("X-Forwarded-For"); v != "" { t.Errorf("got X-Forwarded-For header: %q", v) } @@ -355,7 +355,7 @@ func TestXForwardedFor_Omit(t *testing.T) { defer frontend.Close() oldDirector := proxyHandler.Director - proxyHandler.Director = func { r | + proxyHandler.Director = func { r -> r.Header["X-Forwarded-For"] = nil oldDirector(r) } @@ -377,7 +377,7 @@ func TestReverseProxyRewriteStripsForwarded(t *testing.T) { "X-Forwarded-Host", "X-Forwarded-Proto", } - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> for _, h := range headers { if v := r.Header.Get(h); v != "" { t.Errorf("got %v header: %q", h, v) @@ -422,7 +422,7 @@ var proxyQueryTests = []struct { } func TestReverseProxyQuery(t *testing.T) { - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Header().Set("X-Got-Query", r.URL.RawQuery) w.Write([]byte("hi")) })) @@ -450,7 +450,7 @@ func TestReverseProxyQuery(t *testing.T) { func TestReverseProxyFlushInterval(t *testing.T) { const expected = "hi" - backend := httptest.NewServer(http.HandlerFunc(func { w, r | w.Write([]byte(expected)) })) + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Write([]byte(expected)) })) defer backend.Close() backendURL, err := url.Parse(backend.URL) @@ -495,7 +495,7 @@ func (w *wrappedRW) Unwrap() http.ResponseWriter { func TestReverseProxyResponseControllerFlushInterval(t *testing.T) { const expected = "hi" - backend := httptest.NewServer(http.HandlerFunc(func { w, r | w.Write([]byte(expected)) })) + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Write([]byte(expected)) })) defer backend.Close() backendURL, err := url.Parse(backend.URL) @@ -506,7 +506,7 @@ func TestReverseProxyResponseControllerFlushInterval(t *testing.T) { mf := &mockFlusher{} proxyHandler := NewSingleHostReverseProxy(backendURL) proxyHandler.FlushInterval = -1 // flush immediately - proxyWithMiddleware := http.HandlerFunc(func { w, r | + proxyWithMiddleware := http.HandlerFunc(func { w, r -> mf.ResponseWriter = w w = &wrappedRW{mf} proxyHandler.ServeHTTP(w, r) @@ -533,7 +533,7 @@ func TestReverseProxyResponseControllerFlushInterval(t *testing.T) { func TestReverseProxyFlushIntervalHeaders(t *testing.T) { const expected = "hi" stopCh := make(chan struct{}) - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Header().Add("MyHeader", expected) w.WriteHeader(200) w.(http.Flusher).Flush() @@ -575,7 +575,7 @@ func TestReverseProxyCancellation(t *testing.T) { const backendResponse = "I am the backend" reqInFlight := make(chan struct{}) - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> close(reqInFlight) // cause the client to cancel its request select { @@ -637,10 +637,10 @@ func req(t *testing.T, v string) *http.Request { // Issue 12344 func TestNilBody(t *testing.T) { - backend := httptest.NewServer(http.HandlerFunc(func { w, r | w.Write([]byte("hi")) })) + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Write([]byte("hi")) })) defer backend.Close() - frontend := httptest.NewServer(http.HandlerFunc(func { w, _ | + frontend := httptest.NewServer(http.HandlerFunc(func { w, _ -> backURL, _ := url.Parse(backend.URL) rp := NewSingleHostReverseProxy(backURL) r := req(t, "GET / HTTP/1.0\r\n\r\n") @@ -666,7 +666,7 @@ func TestNilBody(t *testing.T) { // Issue 15524 func TestUserAgentHeader(t *testing.T) { var gotUA string - backend := httptest.NewServer(http.HandlerFunc(func { w, r | gotUA = r.Header.Get("User-Agent") })) + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> gotUA = r.Header.Get("User-Agent") })) defer backend.Close() backendURL, err := url.Parse(backend.URL) if err != nil { @@ -675,7 +675,7 @@ func TestUserAgentHeader(t *testing.T) { proxyHandler := new(ReverseProxy) proxyHandler.ErrorLog = log.New(io.Discard, "", 0) // quiet for tests - proxyHandler.Director = func { req | req.URL = backendURL } + proxyHandler.Director = func { req -> req.URL = backendURL } frontend := httptest.NewServer(proxyHandler) defer frontend.Close() frontendClient := frontend.Client() @@ -705,7 +705,7 @@ func (bp bufferPool) Put(v []byte) { bp.put(v) } func TestReverseProxyGetPutBuffer(t *testing.T) { const msg = "hi" - backend := httptest.NewServer(http.HandlerFunc(func { w, r | io.WriteString(w, msg) })) + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> io.WriteString(w, msg) })) defer backend.Close() backendURL, err := url.Parse(backend.URL) @@ -762,7 +762,7 @@ func TestReverseProxy_Post(t *testing.T) { const backendResponse = "I am the backend" const backendStatus = 200 var requestBody = bytes.Repeat([]byte("a"), 1<<20) - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> slurp, err := io.ReadAll(r.Body) if err != nil { t.Errorf("Backend body read = %v", err) @@ -809,7 +809,7 @@ func TestReverseProxy_NilBody(t *testing.T) { backendURL, _ := url.Parse("http://fake.tld/") proxyHandler := NewSingleHostReverseProxy(backendURL) proxyHandler.ErrorLog = log.New(io.Discard, "", 0) // quiet for tests - proxyHandler.Transport = RoundTripperFunc(func { req | + proxyHandler.Transport = RoundTripperFunc(func { req -> if req.Body != nil { t.Error("Body != nil; want a nil Body") } @@ -833,7 +833,7 @@ func TestReverseProxy_AllocatedHeader(t *testing.T) { proxyHandler := new(ReverseProxy) proxyHandler.ErrorLog = log.New(io.Discard, "", 0) // quiet for tests proxyHandler.Director = func {} // noop - proxyHandler.Transport = RoundTripperFunc(func { req | + proxyHandler.Transport = RoundTripperFunc(func { req -> if req.Header == nil { t.Error("Header == nil; want a non-nil Header") } @@ -851,13 +851,13 @@ func TestReverseProxy_AllocatedHeader(t *testing.T) { // Issue 14237. Test ModifyResponse and that an error from it // causes the proxy to return StatusBadGateway, or StatusOK otherwise. func TestReverseProxyModifyResponse(t *testing.T) { - backendServer := httptest.NewServer(http.HandlerFunc(func { w, r | w.Header().Add("X-Hit-Mod", fmt.Sprintf("%v", r.URL.Path == "/mod")) })) + backendServer := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Header().Add("X-Hit-Mod", fmt.Sprintf("%v", r.URL.Path == "/mod")) })) defer backendServer.Close() rpURL, _ := url.Parse(backendServer.URL) rproxy := NewSingleHostReverseProxy(rpURL) rproxy.ErrorLog = log.New(io.Discard, "", 0) // quiet for tests - rproxy.ModifyResponse = func { resp | + rproxy.ModifyResponse = func { resp -> if resp.Header.Get("X-Hit-Mod") != "true" { return fmt.Errorf("tried to by-pass proxy") } @@ -943,7 +943,7 @@ func TestReverseProxyErrorHandler(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> target := &url.URL{ Scheme: "http", Host: "dummy.tld", @@ -976,7 +976,7 @@ func TestReverseProxyErrorHandler(t *testing.T) { // Issue 16659: log errors from short read func TestReverseProxy_CopyBuffer(t *testing.T) { - backendServer := httptest.NewServer(http.HandlerFunc(func { w, r | + backendServer := httptest.NewServer(http.HandlerFunc(func { w, r -> out := "this call was relayed by the reverse proxy" // Coerce a wrong content length to induce io.UnexpectedEOF w.Header().Set("Content-Length", fmt.Sprintf("%d", len(out)*2)) @@ -993,7 +993,7 @@ func TestReverseProxy_CopyBuffer(t *testing.T) { rproxy := NewSingleHostReverseProxy(rpURL) rproxy.ErrorLog = log.New(&proxyLog, "", log.Lshortfile) donec := make(chan bool, 1) - frontendProxy := httptest.NewServer(http.HandlerFunc(func { w, r | + frontendProxy := httptest.NewServer(http.HandlerFunc(func { w, r -> defer func() { donec <- true }() rproxy.ServeHTTP(w, r) })) @@ -1047,7 +1047,7 @@ func BenchmarkServeHTTP(b *testing.B) { } func TestServeHTTPDeepCopy(t *testing.T) { - backend := httptest.NewServer(http.HandlerFunc(func { w, r | w.Write([]byte("Hello Gopher!")) })) + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Write([]byte("Hello Gopher!")) })) defer backend.Close() backendURL, err := url.Parse(backend.URL) if err != nil { @@ -1060,7 +1060,7 @@ func TestServeHTTPDeepCopy(t *testing.T) { resultChan := make(chan result, 1) proxyHandler := NewSingleHostReverseProxy(backendURL) - frontend := httptest.NewServer(http.HandlerFunc(func { w, r | + frontend := httptest.NewServer(http.HandlerFunc(func { w, r -> before := r.URL.String() proxyHandler.ServeHTTP(w, r) after := r.URL.String() @@ -1093,7 +1093,7 @@ func TestClonesRequestHeaders(t *testing.T) { Director: func(req *http.Request) { req.Header.Set("From-Director", "1") }, - Transport: roundTripperFunc(func { req | + Transport: roundTripperFunc(func { req -> if v := req.Header.Get("From-Director"); v != "1" { t.Errorf("From-Directory value = %q; want 1", v) } @@ -1166,7 +1166,7 @@ func (cc *checkCloser) Read(b []byte) (int, error) { func TestReverseProxy_PanicBodyError(t *testing.T) { log.SetOutput(io.Discard) defer log.SetOutput(os.Stderr) - backendServer := httptest.NewServer(http.HandlerFunc(func { w, r | + backendServer := httptest.NewServer(http.HandlerFunc(func { w, r -> out := "this call was relayed by the reverse proxy" // Coerce a wrong content length to induce io.ErrUnexpectedEOF w.Header().Set("Content-Length", fmt.Sprintf("%d", len(out)*2)) @@ -1198,7 +1198,7 @@ func TestReverseProxy_PanicBodyError(t *testing.T) { // Issue #46866: panic without closing incoming request body causes a panic func TestReverseProxy_PanicClosesIncomingBody(t *testing.T) { - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> out := "this call was relayed by the reverse proxy" // Coerce a wrong content length to induce io.ErrUnexpectedEOF w.Header().Set("Content-Length", fmt.Sprintf("%d", len(out)*2)) @@ -1306,7 +1306,7 @@ func TestSelectFlushInterval(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> got := tt.p.flushInterval(tt.res) if got != tt.want { t.Errorf("flushLatency = %v; want %v", got, tt.want) @@ -1316,7 +1316,7 @@ func TestSelectFlushInterval(t *testing.T) { } func TestReverseProxyWebSocket(t *testing.T) { - backendServer := httptest.NewServer(http.HandlerFunc(func { w, r | + backendServer := httptest.NewServer(http.HandlerFunc(func { w, r -> if upgradeType(r.Header) != "websocket" { t.Error("unexpected backend request") http.Error(w, "unexpected request", 400) @@ -1341,12 +1341,12 @@ func TestReverseProxyWebSocket(t *testing.T) { backURL, _ := url.Parse(backendServer.URL) rproxy := NewSingleHostReverseProxy(backURL) rproxy.ErrorLog = log.New(io.Discard, "", 0) // quiet for tests - rproxy.ModifyResponse = func { res | + rproxy.ModifyResponse = func { res -> res.Header.Add("X-Modified", "true") return nil } - handler := http.HandlerFunc(func { rw, req | + handler := http.HandlerFunc(func { rw, req -> rw.Header().Set("X-Header", "X-Value") rproxy.ServeHTTP(rw, req) if got, want := rw.Header().Get("X-Modified"), "true"; got != want { @@ -1409,7 +1409,7 @@ func TestReverseProxyWebSocketCancellation(t *testing.T) { } terminalMsg := "final message" - cst := httptest.NewServer(http.HandlerFunc(func { w, r | + cst := httptest.NewServer(http.HandlerFunc(func { w, r -> if g, ws := upgradeType(r.Header), "websocket"; g != ws { t.Errorf("Unexpected upgrade type %q, want %q", g, ws) http.Error(w, "Unexpected request", 400) @@ -1458,12 +1458,12 @@ func TestReverseProxyWebSocketCancellation(t *testing.T) { backendURL, _ := url.Parse(cst.URL) rproxy := NewSingleHostReverseProxy(backendURL) rproxy.ErrorLog = log.New(io.Discard, "", 0) // quiet for tests - rproxy.ModifyResponse = func { res | + rproxy.ModifyResponse = func { res -> res.Header.Add("X-Modified", "true") return nil } - handler := http.HandlerFunc(func { rw, req | + handler := http.HandlerFunc(func { rw, req -> rw.Header().Set("X-Header", "X-Value") ctx, cancel := context.WithCancel(req.Context()) go func() { @@ -1533,7 +1533,7 @@ func TestReverseProxyWebSocketCancellation(t *testing.T) { } func TestUnannouncedTrailer(t *testing.T) { - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.WriteHeader(http.StatusOK) w.(http.Flusher).Flush() w.Header().Set(http.TrailerPrefix+"X-Unannounced-Trailer", "unannounced_trailer_value") @@ -1563,7 +1563,7 @@ func TestUnannouncedTrailer(t *testing.T) { } func TestSetURL(t *testing.T) { - backend := httptest.NewServer(http.HandlerFunc(func { w, r | w.Write([]byte(r.Host)) })) + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Write([]byte(r.Host)) })) defer backend.Close() backendURL, err := url.Parse(backend.URL) if err != nil { @@ -1646,7 +1646,7 @@ func TestJoinURLPath(t *testing.T) { func TestReverseProxyRewriteReplacesOut(t *testing.T) { const content = "response_content" - backend := httptest.NewServer(http.HandlerFunc(func { w, r | w.Write([]byte(content)) })) + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Write([]byte(content)) })) defer backend.Close() proxyHandler := &ReverseProxy{ Rewrite: func(r *ProxyRequest) { @@ -1672,7 +1672,7 @@ func Test1xxHeadersNotModifiedAfterRoundTrip(t *testing.T) { // and proxy them. httptrace handlers can execute after RoundTrip returns, in particular // after experiencing connection errors. When this happens, we shouldn't modify the // ResponseWriter headers after ReverseProxy.ServeHTTP returns. - backend := httptest.NewServer(http.HandlerFunc(func { w, r | for i := 0; i < 5; i++ { + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> for i := 0; i < 5; i++ { w.WriteHeader(103) } })) defer backend.Close() @@ -1707,7 +1707,7 @@ func Test1xxHeadersNotModifiedAfterRoundTrip(t *testing.T) { } func Test1xxResponses(t *testing.T) { - backend := httptest.NewServer(http.HandlerFunc(func { w, r | + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> h := w.Header() h.Add("Link", "; rel=preload; as=style") h.Add("Link", "; rel=preload; as=script") @@ -1792,19 +1792,19 @@ const ( ) func TestReverseProxyQueryParameterSmugglingDirectorDoesNotParseForm(t *testing.T) { - testReverseProxyQueryParameterSmuggling(t, testWantsRawQuery, func { u | + testReverseProxyQueryParameterSmuggling(t, testWantsRawQuery, func { u -> proxyHandler := NewSingleHostReverseProxy(u) oldDirector := proxyHandler.Director - proxyHandler.Director = func { r | oldDirector(r) } + proxyHandler.Director = func { r -> oldDirector(r) } return proxyHandler }) } func TestReverseProxyQueryParameterSmugglingDirectorParsesForm(t *testing.T) { - testReverseProxyQueryParameterSmuggling(t, testWantsCleanQuery, func { u | + testReverseProxyQueryParameterSmuggling(t, testWantsCleanQuery, func { u -> proxyHandler := NewSingleHostReverseProxy(u) oldDirector := proxyHandler.Director - proxyHandler.Director = func { r | + proxyHandler.Director = func { r -> // Parsing the form causes ReverseProxy to remove unparsable // query parameters before forwarding. r.FormValue("a") @@ -1815,7 +1815,7 @@ func TestReverseProxyQueryParameterSmugglingDirectorParsesForm(t *testing.T) { } func TestReverseProxyQueryParameterSmugglingRewrite(t *testing.T) { - testReverseProxyQueryParameterSmuggling(t, testWantsCleanQuery, func { u | return &ReverseProxy{ + testReverseProxyQueryParameterSmuggling(t, testWantsCleanQuery, func { u -> return &ReverseProxy{ Rewrite: func(r *ProxyRequest) { r.SetURL(u) }, @@ -1823,7 +1823,7 @@ func TestReverseProxyQueryParameterSmugglingRewrite(t *testing.T) { } func TestReverseProxyQueryParameterSmugglingRewritePreservesRawQuery(t *testing.T) { - testReverseProxyQueryParameterSmuggling(t, testWantsRawQuery, func { u | + testReverseProxyQueryParameterSmuggling(t, testWantsRawQuery, func { u -> return &ReverseProxy{ Rewrite: func(r *ProxyRequest) { r.SetURL(u) @@ -1835,7 +1835,7 @@ func TestReverseProxyQueryParameterSmugglingRewritePreservesRawQuery(t *testing. func testReverseProxyQueryParameterSmuggling(t *testing.T, wantCleanQuery bool, newProxy func(*url.URL) *ReverseProxy) { const content = "response_content" - backend := httptest.NewServer(http.HandlerFunc(func { w, r | w.Write([]byte(r.URL.RawQuery)) })) + backend := httptest.NewServer(http.HandlerFunc(func { w, r -> w.Write([]byte(r.URL.RawQuery)) })) defer backend.Close() backendURL, err := url.Parse(backend.URL) if err != nil { diff --git a/src/net/http/internal/ascii/print_test.go b/src/net/http/internal/ascii/print_test.go index 0249b8e93297c..2c8f7d49ebddd 100644 --- a/src/net/http/internal/ascii/print_test.go +++ b/src/net/http/internal/ascii/print_test.go @@ -36,7 +36,7 @@ func TestEqualFold(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> if got := EqualFold(tt.a, tt.b); got != tt.want { t.Errorf("AsciiEqualFold(%q,%q): got %v want %v", tt.a, tt.b, got, tt.want) } @@ -86,7 +86,7 @@ func TestIsPrint(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> if got := IsPrint(tt.in); got != tt.want { t.Errorf("IsASCIIPrint(%q): got %v want %v", tt.in, got, tt.want) } diff --git a/src/net/http/mapping_test.go b/src/net/http/mapping_test.go index 00bc539207fa8..6827192da5afd 100644 --- a/src/net/http/mapping_test.go +++ b/src/net/http/mapping_test.go @@ -51,11 +51,11 @@ func TestMappingEachPair(t *testing.T) { } var got []entry[int, string] - m.eachPair(func { k, v | + m.eachPair(func { k, v -> got = append(got, entry[int, string]{k, v}) return true }) - slices.SortFunc(got, func { e1, e2 | return cmp.Compare(e1.key, e2.key) }) + slices.SortFunc(got, func { e1, e2 -> return cmp.Compare(e1.key, e2.key) }) if !slices.Equal(got, want) { t.Errorf("got %v, want %v", got, want) } @@ -102,9 +102,9 @@ func BenchmarkFindChild(b *testing.B) { } for _, n := range []int{2, 4, 8, 16, 32} { list := children[:n] - b.Run(fmt.Sprintf("n=%d", n), func { b | + b.Run(fmt.Sprintf("n=%d", n), func { b -> - b.Run("rep=linear", func { b | + b.Run("rep=linear", func { b -> var entries []entry[string, any] for _, c := range list { entries = append(entries, entry[string, any]{c, nil}) @@ -114,7 +114,7 @@ func BenchmarkFindChild(b *testing.B) { findChildLinear(key, entries) } }) - b.Run("rep=map", func { b | + b.Run("rep=map", func { b -> m := map[string]any{} for _, c := range list { m[c] = nil @@ -126,7 +126,7 @@ func BenchmarkFindChild(b *testing.B) { } _ = x }) - b.Run(fmt.Sprintf("rep=hybrid%d", maxSlice), func { b | + b.Run(fmt.Sprintf("rep=hybrid%d", maxSlice), func { b -> var h mapping[string, any] for _, c := range list { h.add(c, nil) diff --git a/src/net/http/pprof/pprof.go b/src/net/http/pprof/pprof.go index 93e68295a47b8..8d79a52bde280 100644 --- a/src/net/http/pprof/pprof.go +++ b/src/net/http/pprof/pprof.go @@ -412,7 +412,7 @@ func Index(w http.ResponseWriter, r *http.Request) { }) } - sort.Slice(profiles, func { i, j | return profiles[i].Name < profiles[j].Name }) + sort.Slice(profiles, func { i, j -> return profiles[i].Name < profiles[j].Name }) if err := indexTmplExecute(w, profiles); err != nil { log.Print(err) diff --git a/src/net/http/pprof/pprof_test.go b/src/net/http/pprof/pprof_test.go index 77df4fc6c648e..81c938708396c 100644 --- a/src/net/http/pprof/pprof_test.go +++ b/src/net/http/pprof/pprof_test.go @@ -56,7 +56,7 @@ func TestHandlers(t *testing.T) { {"/debug/pprof/", Index, http.StatusOK, "text/html; charset=utf-8", "", []byte("Types of profiles available:")}, } for _, tc := range testCases { - t.Run(tc.path, func { t | + t.Run(tc.path, func { t -> req := httptest.NewRequest("GET", "http://example.com"+tc.path, nil) w := httptest.NewRecorder() tc.handler(w, req) diff --git a/src/net/http/request_test.go b/src/net/http/request_test.go index 67b1e6c4a9053..de11df84cf3e8 100644 --- a/src/net/http/request_test.go +++ b/src/net/http/request_test.go @@ -119,7 +119,7 @@ func TestParseFormUnknownContentType(t *testing.T) { {"unknown", "", Header{"Content-Type": {"application/unknown"}}}, } { t.Run(test.name, - func { t | + func { t -> req := &Request{ Method: "POST", Header: test.contentType, @@ -296,7 +296,7 @@ func TestMaxInt64ForMultipartFormMaxMemoryOverflow(t *testing.T) { } func testMaxInt64ForMultipartFormMaxMemoryOverflow(t *testing.T, mode testMode) { payloadSize := 1 << 10 - cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> // The combination of: // MaxInt64 + payloadSize + (internal spare of 10MiB) // triggers the overflow. See issue https://golang.org/issue/40430/ @@ -334,7 +334,7 @@ func testMaxInt64ForMultipartFormMaxMemoryOverflow(t *testing.T, mode testMode) func TestRequestRedirect(t *testing.T) { run(t, testRequestRedirect) } func testRequestRedirect(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> switch r.URL.Path { case "/": w.Header().Set("Location", "/foo/") @@ -1084,7 +1084,7 @@ func TestRequestClonePathValue(t *testing.T) { // Issue 34878: verify we don't panic when including basic auth (Go 1.13 regression) func TestNoPanicOnRoundTripWithBasicAuth(t *testing.T) { run(t, testNoPanicWithBasicAuth) } func testNoPanicWithBasicAuth(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> })) u, err := url.Parse(cst.ts.URL) if err != nil { @@ -1305,7 +1305,7 @@ func TestRequestCookiesByName(t *testing.T) { } for _, tt := range tests { - t.Run(tt.filter, func { t | + t.Run(tt.filter, func { t -> req, err := NewRequest("GET", "http://example.com/", nil) if err != nil { t.Fatal(err) @@ -1462,11 +1462,11 @@ func benchmarkFileAndServer(b *testing.B, n int64) { b.Fatalf("Failed to copy %d bytes: %v", n, err) } - run(b, func { b, mode | runFileAndServerBenchmarks(b, mode, f, n) }, []testMode{http1Mode, https1Mode, http2Mode}) + run(b, func { b, mode -> runFileAndServerBenchmarks(b, mode, f, n) }, []testMode{http1Mode, https1Mode, http2Mode}) } func runFileAndServerBenchmarks(b *testing.B, mode testMode, f *os.File, n int64) { - handler := HandlerFunc(func { rw, req | + handler := HandlerFunc(func { rw, req -> defer req.Body.Close() nc, err := io.Copy(io.Discard, req.Body) if err != nil { @@ -1567,7 +1567,7 @@ func TestPathValueAndPattern(t *testing.T) { }, } { mux := NewServeMux() - mux.HandleFunc(test.pattern, func { w, r | + mux.HandleFunc(test.pattern, func { w, r -> for name, want := range test.want { got := r.PathValue(name) if got != want { @@ -1590,7 +1590,7 @@ func TestPathValueAndPattern(t *testing.T) { func TestSetPathValue(t *testing.T) { mux := NewServeMux() - mux.HandleFunc("/a/{b}/c/{d...}", func { _, r | + mux.HandleFunc("/a/{b}/c/{d...}", func { _, r -> kvs := map[string]string{ "b": "X", "d": "Y", @@ -1616,7 +1616,7 @@ func TestSetPathValue(t *testing.T) { func TestStatus(t *testing.T) { // The main purpose of this test is to check 405 responses and the Allow header. - h := http.HandlerFunc(func { w, r | }) + h := http.HandlerFunc(func { w, r -> }) mux := NewServeMux() mux.Handle("GET /g", h) mux.Handle("POST /p", h) diff --git a/src/net/http/response_test.go b/src/net/http/response_test.go index a101230440525..257a95abb5379 100644 --- a/src/net/http/response_test.go +++ b/src/net/http/response_test.go @@ -724,7 +724,7 @@ func TestReadResponseCloseInMiddle(t *testing.T) { rest, err := io.ReadAll(bufr) checkErr(err, "ReadAll on remainder") if e, g := "Next Request Here", string(rest); e != g { - g = regexp.MustCompile(`(xx+)`).ReplaceAllStringFunc(g, func { match | return fmt.Sprintf("x(repeated x%d)", len(match)) }) + g = regexp.MustCompile(`(xx+)`).ReplaceAllStringFunc(g, func { match -> return fmt.Sprintf("x(repeated x%d)", len(match)) }) fatalf("remainder = %q, expected %q", g, e) } } diff --git a/src/net/http/responsecontroller_test.go b/src/net/http/responsecontroller_test.go index 202e8dde6775f..e253d20f1dd07 100644 --- a/src/net/http/responsecontroller_test.go +++ b/src/net/http/responsecontroller_test.go @@ -18,7 +18,7 @@ import ( func TestResponseControllerFlush(t *testing.T) { run(t, testResponseControllerFlush) } func testResponseControllerFlush(t *testing.T, mode testMode) { continuec := make(chan struct{}) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ctl := NewResponseController(w) w.Write([]byte("one")) if err := ctl.Flush(); err != nil { @@ -52,7 +52,7 @@ func TestResponseControllerHijack(t *testing.T) { run(t, testResponseControllerH func testResponseControllerHijack(t *testing.T, mode testMode) { const header = "X-Header" const value = "set" - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ctl := NewResponseController(w) c, _, err := ctl.Hijack() if mode == http2Mode { @@ -81,7 +81,7 @@ func TestResponseControllerSetPastWriteDeadline(t *testing.T) { run(t, testResponseControllerSetPastWriteDeadline) } func testResponseControllerSetPastWriteDeadline(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ctl := NewResponseController(w) w.Write([]byte("one")) if err := ctl.Flush(); err != nil { @@ -125,7 +125,7 @@ func TestResponseControllerSetFutureWriteDeadline(t *testing.T) { func testResponseControllerSetFutureWriteDeadline(t *testing.T, mode testMode) { errc := make(chan error, 1) startwritec := make(chan struct{}) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ctl := NewResponseController(w) w.WriteHeader(200) if err := ctl.Flush(); err != nil { @@ -161,7 +161,7 @@ func TestResponseControllerSetPastReadDeadline(t *testing.T) { func testResponseControllerSetPastReadDeadline(t *testing.T, mode testMode) { readc := make(chan struct{}) donec := make(chan struct{}) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> defer close(donec) ctl := NewResponseController(w) b := make([]byte, 3) @@ -224,7 +224,7 @@ func TestResponseControllerSetFutureReadDeadline(t *testing.T) { } func testResponseControllerSetFutureReadDeadline(t *testing.T, mode testMode) { respBody := "response body" - cst := newClientServerTest(t, mode, HandlerFunc(func { w, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, req -> ctl := NewResponseController(w) if err := ctl.SetReadDeadline(time.Now().Add(1 * time.Millisecond)); err != nil { t.Errorf("ctl.SetReadDeadline() = %v, want nil", err) @@ -258,7 +258,7 @@ func (w wrapWriter) Unwrap() ResponseWriter { func TestWrappedResponseController(t *testing.T) { run(t, testWrappedResponseController) } func testWrappedResponseController(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w = wrapWriter{w} ctl := NewResponseController(w) if err := ctl.Flush(); err != nil { @@ -283,7 +283,7 @@ func TestResponseControllerEnableFullDuplex(t *testing.T) { run(t, testResponseControllerEnableFullDuplex) } func testResponseControllerEnableFullDuplex(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, req -> ctl := NewResponseController(w) if err := ctl.EnableFullDuplex(); err != nil { // TODO: Drop test for HTTP/2 when x/net is updated to support @@ -328,7 +328,7 @@ func testResponseControllerEnableFullDuplex(t *testing.T, mode testMode) { } func TestIssue58237(t *testing.T) { - cst := newClientServerTest(t, http2Mode, HandlerFunc(func { w, req | + cst := newClientServerTest(t, http2Mode, HandlerFunc(func { w, req -> ctl := NewResponseController(w) if err := ctl.SetReadDeadline(time.Now().Add(1 * time.Millisecond)); err != nil { t.Errorf("ctl.SetReadDeadline() = %v, want nil", err) diff --git a/src/net/http/roundtrip_js.go b/src/net/http/roundtrip_js.go index 82e1abae0322d..c4c9c8bb20065 100644 --- a/src/net/http/roundtrip_js.go +++ b/src/net/http/roundtrip_js.go @@ -132,7 +132,7 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { errCh = make(chan error, 1) success, failure js.Func ) - success = js.FuncOf(func { this, args | + success = js.FuncOf(func { this, args -> success.Release() failure.Release() @@ -207,7 +207,7 @@ func (t *Transport) RoundTrip(req *Request) (*Response, error) { return nil }) - failure = js.FuncOf(func { this, args | + failure = js.FuncOf(func { this, args -> success.Release() failure.Release() @@ -264,7 +264,7 @@ func (r *streamReader) Read(p []byte) (n int, err error) { bCh = make(chan []byte, 1) errCh = make(chan error, 1) ) - success := js.FuncOf(func { this, args | + success := js.FuncOf(func { this, args -> result := args[0] if result.Get("done").Bool() { errCh <- io.EOF @@ -276,7 +276,7 @@ func (r *streamReader) Read(p []byte) (n int, err error) { return nil }) defer success.Release() - failure := js.FuncOf(func { this, args | + failure := js.FuncOf(func { this, args -> // Assumes it's a TypeError. See // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError // for more information on this type. See @@ -330,7 +330,7 @@ func (r *arrayReader) Read(p []byte) (n int, err error) { bCh = make(chan []byte, 1) errCh = make(chan error, 1) ) - success := js.FuncOf(func { this, args | + success := js.FuncOf(func { this, args -> // Wrap the input ArrayBuffer with a Uint8Array uint8arrayWrapper := uint8Array.New(args[0]) value := make([]byte, uint8arrayWrapper.Get("byteLength").Int()) @@ -339,7 +339,7 @@ func (r *arrayReader) Read(p []byte) (n int, err error) { return nil }) defer success.Release() - failure := js.FuncOf(func { this, args | + failure := js.FuncOf(func { this, args -> // Assumes it's a TypeError. See // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/TypeError // for more information on this type. diff --git a/src/net/http/routing_index_test.go b/src/net/http/routing_index_test.go index 6550b99e52042..62d0e58be0579 100644 --- a/src/net/http/routing_index_test.go +++ b/src/net/http/routing_index_test.go @@ -40,7 +40,7 @@ func trueConflicts(pat *pattern, pats []*pattern) []string { func indexConflicts(pat *pattern, idx *routingIndex) []string { var s []string - idx.possiblyConflictingPatterns(pat, func { p | + idx.possiblyConflictingPatterns(pat, func { p -> if pat.conflictsWith(p) { s = append(s, p.String()) } @@ -117,7 +117,7 @@ func genChoice(choices []string) generator { // with those of g2. func genConcat2(g1, g2 generator) generator { return func(collect func(string)) { - g1(func { s1 | g2(func { s2 | collect(s1 + s2) }) }) + g1(func { s1 -> g2(func { s2 -> collect(s1 + s2) }) }) } } diff --git a/src/net/http/routing_tree.go b/src/net/http/routing_tree.go index 254fe6fc14b81..ca944fc1d5c4a 100644 --- a/src/net/http/routing_tree.go +++ b/src/net/http/routing_tree.go @@ -230,7 +230,7 @@ func (n *routingNode) matchingMethodsPath(path string, set map[string]bool) { if n == nil { return } - n.children.eachPair(func { method, c | + n.children.eachPair(func { method, c -> if p, _ := c.matchPath(path, nil); p != nil { set[method] = true } diff --git a/src/net/http/routing_tree_test.go b/src/net/http/routing_tree_test.go index 0cd47c2b5c4cd..881575a5e99bf 100644 --- a/src/net/http/routing_tree_test.go +++ b/src/net/http/routing_tree_test.go @@ -259,7 +259,7 @@ func TestMatchingMethods(t *testing.T) { "", }, } { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> ms := map[string]bool{} test.tree.matchingMethods(test.host, test.path, ms) got := strings.Join(slices.Sorted(maps.Keys(ms)), ",") @@ -281,7 +281,7 @@ func (n *routingNode) print(w io.Writer, level int) { } var keys []string - n.children.eachPair(func { k, _ | + n.children.eachPair(func { k, _ -> keys = append(keys, k) return true }) diff --git a/src/net/http/serve_test.go b/src/net/http/serve_test.go index e4d61a42aa2fe..613819dbb07ca 100644 --- a/src/net/http/serve_test.go +++ b/src/net/http/serve_test.go @@ -498,7 +498,7 @@ func testServeWithSlashRedirectKeepsQueryString(t *testing.T, mode testMode) { mux.HandleFunc("/testOne", writeBackQuery) mux.HandleFunc("/testTwo/", writeBackQuery) mux.HandleFunc("/testThree", writeBackQuery) - mux.HandleFunc("/testThree/", func { w, r | fmt.Fprintf(w, "%s:bar", r.URL.RawQuery) }) + mux.HandleFunc("/testThree/", func { w, r -> fmt.Fprintf(w, "%s:bar", r.URL.RawQuery) }) ts := newClientServerTest(t, mode, mux).ts @@ -600,7 +600,7 @@ func TestServeWithSlashRedirectForHostPatterns(t *testing.T) { // See issue #65624. func TestMuxNoSlashRedirectWithTrailingSlash(t *testing.T) { mux := NewServeMux() - mux.HandleFunc("/{x}/", func { w, r | fmt.Fprintln(w, "ok") }) + mux.HandleFunc("/{x}/", func { w, r -> fmt.Fprintln(w, "ok") }) w := httptest.NewRecorder() req, _ := NewRequest("GET", "/", nil) mux.ServeHTTP(w, req) @@ -614,7 +614,7 @@ func TestMuxNoSlashRedirectWithTrailingSlash(t *testing.T) { // See issue #67657. func TestMuxNoSlash405WithTrailingSlash(t *testing.T) { mux := NewServeMux() - mux.HandleFunc("GET /{x}/", func { w, r | fmt.Fprintln(w, "ok") }) + mux.HandleFunc("GET /{x}/", func { w, r -> fmt.Fprintln(w, "ok") }) w := httptest.NewRecorder() req, _ := NewRequest("GET", "/", nil) mux.ServeHTTP(w, req) @@ -627,7 +627,7 @@ func TestShouldRedirectConcurrency(t *testing.T) { run(t, testShouldRedirectConc func testShouldRedirectConcurrency(t *testing.T, mode testMode) { mux := NewServeMux() newClientServerTest(t, mode, mux) - mux.HandleFunc("/", func { w, r | }) + mux.HandleFunc("/", func { w, r -> }) } func BenchmarkServeMux(b *testing.B) { benchmarkServeMux(b, true) } @@ -682,12 +682,12 @@ func testServerTimeouts(t *testing.T, mode testMode) { 100 * time.Millisecond, 500 * time.Millisecond, 1 * time.Second, - }, func { t, timeout | return testServerTimeoutsWithTimeout(t, timeout, mode) }) + }, func { t, timeout -> return testServerTimeoutsWithTimeout(t, timeout, mode) }) } func testServerTimeoutsWithTimeout(t *testing.T, timeout time.Duration, mode testMode) error { var reqNum atomic.Int32 - cst := newClientServerTest(t, mode, HandlerFunc(func { res, req | fmt.Fprintf(res, "req=%d", reqNum.Add(1)) }), func { ts | + cst := newClientServerTest(t, mode, HandlerFunc(func { res, req -> fmt.Fprintf(res, "req=%d", reqNum.Add(1)) }), func { ts -> ts.Config.ReadTimeout = timeout ts.Config.WriteTimeout = timeout }) @@ -761,13 +761,13 @@ func TestServerReadTimeout(t *testing.T) { run(t, testServerReadTimeout) } func testServerReadTimeout(t *testing.T, mode testMode) { respBody := "response body" for timeout := 5 * time.Millisecond; ; timeout *= 2 { - cst := newClientServerTest(t, mode, HandlerFunc(func { res, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { res, req -> _, err := io.Copy(io.Discard, req.Body) if !errors.Is(err, os.ErrDeadlineExceeded) { t.Errorf("server timed out reading request body: got err %v; want os.ErrDeadlineExceeded", err) } res.Write([]byte(respBody)) - }), func { ts | + }), func { ts -> ts.Config.ReadHeaderTimeout = -1 // don't time out while reading headers ts.Config.ReadTimeout = timeout t.Logf("Server.Config.ReadTimeout = %v", timeout) @@ -803,7 +803,7 @@ func testServerNoReadTimeout(t *testing.T, mode testMode) { reqBody := "Hello, Gophers!" resBody := "Hi, Gophers!" for _, timeout := range []time.Duration{0, -1} { - cst := newClientServerTest(t, mode, HandlerFunc(func { res, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { res, req -> ctl := NewResponseController(res) ctl.EnableFullDuplex() res.WriteHeader(StatusOK) @@ -818,7 +818,7 @@ func testServerNoReadTimeout(t *testing.T, mode testMode) { t.Errorf("server read request body: %v; got %q, want %q", err, got, reqBody) } res.Write([]byte(resBody)) - }), func { ts | + }), func { ts -> ts.Config.ReadTimeout = timeout t.Logf("Server.Config.ReadTimeout = %d", timeout) }) @@ -846,11 +846,11 @@ func TestServerWriteTimeout(t *testing.T) { run(t, testServerWriteTimeout) } func testServerWriteTimeout(t *testing.T, mode testMode) { for timeout := 5 * time.Millisecond; ; timeout *= 2 { errc := make(chan error, 2) - cst := newClientServerTest(t, mode, HandlerFunc(func { res, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { res, req -> errc <- nil _, err := io.Copy(res, neverEnding('a')) errc <- err - }), func { ts | + }), func { ts -> ts.Config.WriteTimeout = timeout t.Logf("Server.Config.WriteTimeout = %v", timeout) }) @@ -910,10 +910,10 @@ func testServerWriteTimeout(t *testing.T, mode testMode) { func TestServerNoWriteTimeout(t *testing.T) { run(t, testServerNoWriteTimeout) } func testServerNoWriteTimeout(t *testing.T, mode testMode) { for _, timeout := range []time.Duration{0, -1} { - cst := newClientServerTest(t, mode, HandlerFunc(func { res, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { res, req -> _, err := io.Copy(res, neverEnding('a')) t.Logf("server write response: %v", err) - }), func { ts | + }), func { ts -> ts.Config.WriteTimeout = timeout t.Logf("Server.Config.WriteTimeout = %d", timeout) }) @@ -942,8 +942,8 @@ func testWriteDeadlineExtendedOnNewRequest(t *testing.T, mode testMode) { if testing.Short() { t.Skip("skipping in short mode") } - ts := newClientServerTest(t, mode, HandlerFunc(func { res, req | }), - func { ts | ts.Config.WriteTimeout = 250 * time.Millisecond }, + ts := newClientServerTest(t, mode, HandlerFunc(func { res, req -> }), + func { ts -> ts.Config.WriteTimeout = 250 * time.Millisecond }, ).ts c := ts.Client() @@ -986,14 +986,14 @@ func TestWriteDeadlineEnforcedPerStream(t *testing.T) { t.Skip("skipping in short mode") } setParallel(t) - run(t, func { t, mode | - tryTimeouts(t, func { timeout | return testWriteDeadlineEnforcedPerStream(t, mode, timeout) }) + run(t, func { t, mode -> + tryTimeouts(t, func { timeout -> return testWriteDeadlineEnforcedPerStream(t, mode, timeout) }) }) } func testWriteDeadlineEnforcedPerStream(t *testing.T, mode testMode, timeout time.Duration) error { firstRequest := make(chan bool, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { res, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { res, req -> select { case firstRequest <- true: // first request succeeds @@ -1001,7 +1001,7 @@ func testWriteDeadlineEnforcedPerStream(t *testing.T, mode testMode, timeout tim // second request times out time.Sleep(timeout) } - }), func { ts | ts.Config.WriteTimeout = timeout / 2 }) + }), func { ts -> ts.Config.WriteTimeout = timeout / 2 }) defer cst.close() ts := cst.ts @@ -1042,14 +1042,14 @@ func TestNoWriteDeadline(t *testing.T) { } setParallel(t) defer afterTest(t) - run(t, func { t, mode | - tryTimeouts(t, func { timeout | return testNoWriteDeadline(t, mode, timeout) }) + run(t, func { t, mode -> + tryTimeouts(t, func { timeout -> return testNoWriteDeadline(t, mode, timeout) }) }) } func testNoWriteDeadline(t *testing.T, mode testMode, timeout time.Duration) error { firstRequest := make(chan bool, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { res, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { res, req -> select { case firstRequest <- true: // first request succeeds @@ -1087,7 +1087,7 @@ func testOnlyWriteTimeout(t *testing.T, mode testMode) { conn net.Conn ) var afterTimeoutErrc = make(chan error, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, req | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, req -> buf := make([]byte, 512<<10) _, err := w.Write(buf) if err != nil { @@ -1103,7 +1103,7 @@ func testOnlyWriteTimeout(t *testing.T, mode testMode) { conn.SetWriteDeadline(time.Now().Add(-30 * time.Second)) _, err = w.Write(buf) afterTimeoutErrc <- err - }), func { ts | ts.Listener = trackLastConnListener{ts.Listener, &mu, &conn} }).ts + }), func { ts -> ts.Listener = trackLastConnListener{ts.Listener, &mu, &conn} }).ts c := ts.Client() @@ -1150,7 +1150,7 @@ func testIdentityResponse(t *testing.T, mode testMode) { t.Skip("https://go.dev/issue/56019") } - handler := HandlerFunc(func { rw, req | + handler := HandlerFunc(func { rw, req -> rw.Header().Set("Content-Length", "3") rw.Header().Set("Transfer-Encoding", req.FormValue("te")) switch { @@ -1282,12 +1282,12 @@ func testTCPConnectionStaysOpen(t *testing.T, req string, handler Handler) { // TestServeHTTP10Close verifies that HTTP/1.0 requests won't be kept alive. func TestServeHTTP10Close(t *testing.T) { - testTCPConnectionCloses(t, "GET / HTTP/1.0\r\n\r\n", HandlerFunc(func { w, r | ServeFile(w, r, "testdata/file") })) + testTCPConnectionCloses(t, "GET / HTTP/1.0\r\n\r\n", HandlerFunc(func { w, r -> ServeFile(w, r, "testdata/file") })) } // TestClientCanClose verifies that clients can also force a connection to close. func TestClientCanClose(t *testing.T) { - testTCPConnectionCloses(t, "GET / HTTP/1.1\r\nHost: foo\r\nConnection: close\r\n\r\n", HandlerFunc(func { w, r | + testTCPConnectionCloses(t, "GET / HTTP/1.1\r\nHost: foo\r\nConnection: close\r\n\r\n", HandlerFunc(func { w, r -> // Nothing. })) } @@ -1295,15 +1295,15 @@ func TestClientCanClose(t *testing.T) { // TestHandlersCanSetConnectionClose verifies that handlers can force a connection to close, // even for HTTP/1.1 requests. func TestHandlersCanSetConnectionClose11(t *testing.T) { - testTCPConnectionCloses(t, "GET / HTTP/1.1\r\nHost: foo\r\n\r\n\r\n", HandlerFunc(func { w, r | w.Header().Set("Connection", "close") })) + testTCPConnectionCloses(t, "GET / HTTP/1.1\r\nHost: foo\r\n\r\n\r\n", HandlerFunc(func { w, r -> w.Header().Set("Connection", "close") })) } func TestHandlersCanSetConnectionClose10(t *testing.T) { - testTCPConnectionCloses(t, "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n", HandlerFunc(func { w, r | w.Header().Set("Connection", "close") })) + testTCPConnectionCloses(t, "GET / HTTP/1.0\r\nConnection: keep-alive\r\n\r\n", HandlerFunc(func { w, r -> w.Header().Set("Connection", "close") })) } func TestHTTP2UpgradeClosesConnection(t *testing.T) { - testTCPConnectionCloses(t, "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n", HandlerFunc(func { w, r | + testTCPConnectionCloses(t, "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n", HandlerFunc(func { w, r -> // Nothing. (if not hijacked, the server should close the connection // afterwards) })) @@ -1330,7 +1330,7 @@ func TestHTTP10KeepAlive304Response(t *testing.T) { // Issue 15703 func TestKeepAliveFinalChunkWithEOF(t *testing.T) { run(t, testKeepAliveFinalChunkWithEOF) } func testKeepAliveFinalChunkWithEOF(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.(Flusher).Flush() // force chunked encoding w.Write([]byte("{\"Addr\": \"" + r.RemoteAddr + "\"}")) })) @@ -1358,7 +1358,7 @@ func testKeepAliveFinalChunkWithEOF(t *testing.T, mode testMode) { func TestSetsRemoteAddr(t *testing.T) { run(t, testSetsRemoteAddr) } func testSetsRemoteAddr(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | fmt.Fprintf(w, "%s", r.RemoteAddr) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> fmt.Fprintf(w, "%s", r.RemoteAddr) })) res, err := cst.c.Get(cst.ts.URL) if err != nil { @@ -1407,7 +1407,7 @@ func TestServerAllowsBlockingRemoteAddr(t *testing.T) { } func testServerAllowsBlockingRemoteAddr(t *testing.T, mode testMode) { conns := make(chan net.Conn) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | fmt.Fprintf(w, "RA:%s", r.RemoteAddr) }), func { ts | ts.Listener = &blockingRemoteAddrListener{ + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> fmt.Fprintf(w, "RA:%s", r.RemoteAddr) }), func { ts -> ts.Listener = &blockingRemoteAddrListener{ Listener: ts.Listener, conns: conns, } }).ts @@ -1470,7 +1470,7 @@ func testServerAllowsBlockingRemoteAddr(t *testing.T, mode testMode) { // counting of GET requests also happens on HEAD requests. func TestHeadResponses(t *testing.T) { run(t, testHeadResponses) } func testHeadResponses(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> _, err := w.Write([]byte("")) if err != nil { t.Errorf("ResponseWriter.Write: %v", err) @@ -1509,8 +1509,8 @@ func TestTLSHandshakeTimeout(t *testing.T) { } func testTLSHandshakeTimeout(t *testing.T, mode testMode) { errLog := new(strings.Builder) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | }), - func { ts | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> }), + func { ts -> ts.Config.ReadTimeout = 250 * time.Millisecond ts.Config.ErrorLog = log.New(errLog, "", 0) }, @@ -1536,14 +1536,14 @@ func testTLSHandshakeTimeout(t *testing.T, mode testMode) { func TestTLSServer(t *testing.T) { run(t, testTLSServer, []testMode{https1Mode, http2Mode}) } func testTLSServer(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.TLS != nil { w.Header().Set("X-TLS-Set", "true") if r.TLS.HandshakeComplete { w.Header().Set("X-TLS-HandshakeComplete", "true") } } - }), func { ts | ts.Config.ErrorLog = log.New(io.Discard, "", 0) }).ts + }), func { ts -> ts.Config.ErrorLog = log.New(io.Discard, "", 0) }).ts // Connect an idle TCP connection to this server before we run // our real tests. This idle connection used to block forever @@ -1599,8 +1599,8 @@ func TestServeTLS(t *testing.T) { addr := ln.Addr().String() serving := make(chan bool, 1) - SetTestHookServerServe(func { s, ln | serving <- true }) - handler := HandlerFunc(func { w, r | }) + SetTestHookServerServe(func { s, ln -> serving <- true }) + handler := HandlerFunc(func { w, r -> }) s := &Server{ Addr: addr, TLSConfig: tlsConf, @@ -1635,7 +1635,7 @@ func TestTLSServerRejectHTTPRequests(t *testing.T) { run(t, testTLSServerRejectHTTPRequests, []testMode{https1Mode, http2Mode}) } func testTLSServerRejectHTTPRequests(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | t.Error("unexpected HTTPS request") }), func { ts | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> t.Error("unexpected HTTPS request") }), func { ts -> var errBuf bytes.Buffer ts.Config.ErrorLog = log.New(&errBuf, "", 0) }).ts @@ -1760,7 +1760,7 @@ Try: ln.Close() t.Logf("Got %v", addr) lnc := make(chan net.Listener, 1) - SetTestHookServerServe(func { s, ln | lnc <- ln }) + SetTestHookServerServe(func { s, ln -> lnc <- ln }) s = &Server{ Addr: addr, TLSConfig: tlsConf, @@ -1848,7 +1848,7 @@ var serverExpectTests = []serverExpectTest{ // correctly. func TestServerExpect(t *testing.T) { run(t, testServerExpect, []testMode{http1Mode}) } func testServerExpect(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> // Note using r.FormValue("readbody") because for POST // requests that would read from r.Body, which we only // conditionally want to do. @@ -1965,7 +1965,7 @@ func TestServerUnreadRequestBodyLittle(t *testing.T) { } ls := &oneConnListener{conn} - go Serve(ls, HandlerFunc(func { rw, req | + go Serve(ls, HandlerFunc(func { rw, req -> defer close(done) if bufLen := readBufLen(); bufLen < len(body)/2 { t.Errorf("on request, read buffer length is %d; expected about 100 KB", bufLen) @@ -2001,7 +2001,7 @@ func TestServerUnreadRequestBodyLarge(t *testing.T) { conn.closec = make(chan bool, 1) ls := &oneConnListener{conn} - go Serve(ls, HandlerFunc(func { rw, req | + go Serve(ls, HandlerFunc(func { rw, req -> if conn.readBuf.Len() < len(body)/2 { t.Errorf("on request, read buffer length is %d; expected about 1MB", conn.readBuf.Len()) } @@ -2165,7 +2165,7 @@ func testHandlerBodyClose(t *testing.T, i int, tt handlerBodyCloseTest) { ls := &oneConnListener{conn} var numReqs int var size0, size1 int - go Serve(ls, HandlerFunc(func { rw, req | + go Serve(ls, HandlerFunc(func { rw, req -> numReqs++ if numReqs == 1 { size0 = readBufLen() @@ -2216,7 +2216,7 @@ func TestRequestBodyReadErrorClosesConnection(t *testing.T) { conn.closec = make(chan bool, 1) ls := &oneConnListener{conn} var numReqs int - go Serve(ls, HandlerFunc(func { _, req | + go Serve(ls, HandlerFunc(func { _, req -> numReqs++ if strings.Contains(req.URL.Path, "secret") { t.Error("Request for /secret encountered, should not have happened.") @@ -2251,7 +2251,7 @@ func TestInvalidTrailerClosesConnection(t *testing.T) { conn.closec = make(chan bool, 1) ln := &oneConnListener{conn} var numReqs int - go Serve(ln, HandlerFunc(func { _, req | + go Serve(ln, HandlerFunc(func { _, req -> numReqs++ if strings.Contains(req.URL.Path, "secret") { t.Errorf("Handler %s, Request for /secret encountered, should not have happened.", handler.name) @@ -2379,7 +2379,7 @@ func TestRequestBodyTimeoutClosesConnection(t *testing.T) { var numReqs int s := Server{ - Handler: HandlerFunc(func { _, req | + Handler: HandlerFunc(func { _, req -> numReqs++ if strings.Contains(req.URL.Path, "secret") { t.Error("Request for /secret encountered, should not have happened.") @@ -2413,7 +2413,7 @@ func TestTimeoutHandler(t *testing.T) { run(t, testTimeoutHandler) } func testTimeoutHandler(t *testing.T, mode testMode) { sendHi := make(chan bool, 1) writeErrors := make(chan error, 1) - sayHi := HandlerFunc(func { w, r | + sayHi := HandlerFunc(func { w, r -> <-sendHi _, werr := w.Write([]byte("hi")) writeErrors <- werr @@ -2468,7 +2468,7 @@ func testTimeoutHandler(t *testing.T, mode testMode) { // See issues 8209 and 8414. func TestTimeoutHandlerRace(t *testing.T) { run(t, testTimeoutHandlerRace) } func testTimeoutHandlerRace(t *testing.T, mode testMode) { - delayHi := HandlerFunc(func { w, r | + delayHi := HandlerFunc(func { w, r -> ms, _ := strconv.Atoi(r.URL.Path[1:]) if ms == 0 { ms = 1 @@ -2510,7 +2510,7 @@ func testTimeoutHandlerRace(t *testing.T, mode testMode) { // Both issues involved panics in the implementation of TimeoutHandler. func TestTimeoutHandlerRaceHeader(t *testing.T) { run(t, testTimeoutHandlerRaceHeader) } func testTimeoutHandlerRaceHeader(t *testing.T, mode testMode) { - delay204 := HandlerFunc(func { w, r | w.WriteHeader(204) }) + delay204 := HandlerFunc(func { w, r -> w.WriteHeader(204) }) ts := newClientServerTest(t, mode, TimeoutHandler(delay204, time.Nanosecond, "")).ts @@ -2547,7 +2547,7 @@ func TestTimeoutHandlerRaceHeaderTimeout(t *testing.T) { run(t, testTimeoutHandl func testTimeoutHandlerRaceHeaderTimeout(t *testing.T, mode testMode) { sendHi := make(chan bool, 1) writeErrors := make(chan error, 1) - sayHi := HandlerFunc(func { w, r | + sayHi := HandlerFunc(func { w, r -> w.Header().Set("Content-Type", "text/plain") <-sendHi _, werr := w.Write([]byte("hi")) @@ -2631,7 +2631,7 @@ func testTimeoutHandlerStartTimerWhenServing(t *testing.T, mode testMode) { func TestTimeoutHandlerContextCanceled(t *testing.T) { run(t, testTimeoutHandlerContextCanceled) } func testTimeoutHandlerContextCanceled(t *testing.T, mode testMode) { writeErrors := make(chan error, 1) - sayHi := HandlerFunc(func { w, r | + sayHi := HandlerFunc(func { w, r -> w.Header().Set("Content-Type", "text/plain") var err error // The request context has already been canceled, but @@ -2694,7 +2694,7 @@ func TestTimeoutHandlerPanicRecovery(t *testing.T) { wrapper := func(h Handler) Handler { return TimeoutHandler(h, time.Second, "") } - run(t, func { t, mode | testHandlerPanic(t, false, mode, wrapper, "intentional death for testing") }, testNotParallel) + run(t, func { t, mode -> testHandlerPanic(t, false, mode, wrapper, "intentional death for testing") }, testNotParallel) } func TestRedirectBadPath(t *testing.T) { @@ -2815,7 +2815,7 @@ func TestRedirectContentTypeAndBody(t *testing.T) { func TestZeroLengthPostAndResponse(t *testing.T) { run(t, testZeroLengthPostAndResponse) } func testZeroLengthPostAndResponse(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { rw, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { rw, r -> all, err := io.ReadAll(r.Body) if err != nil { t.Fatalf("handler ReadAll: %v", err) @@ -2852,16 +2852,16 @@ func testZeroLengthPostAndResponse(t *testing.T, mode testMode) { } func TestHandlerPanicNil(t *testing.T) { - run(t, func { t, mode | testHandlerPanic(t, false, mode, nil, nil) }, testNotParallel) + run(t, func { t, mode -> testHandlerPanic(t, false, mode, nil, nil) }, testNotParallel) } func TestHandlerPanic(t *testing.T) { - run(t, func { t, mode | testHandlerPanic(t, false, mode, nil, "intentional death for testing") }, testNotParallel) + run(t, func { t, mode -> testHandlerPanic(t, false, mode, nil, "intentional death for testing") }, testNotParallel) } func TestHandlerPanicWithHijack(t *testing.T) { // Only testing HTTP/1, and our http2 server doesn't support hijacking. - run(t, func { t, mode | testHandlerPanic(t, true, mode, nil, "intentional death for testing") }, []testMode{http1Mode}) + run(t, func { t, mode -> testHandlerPanic(t, true, mode, nil, "intentional death for testing") }, []testMode{http1Mode}) } func testHandlerPanic(t *testing.T, withHijack bool, mode testMode, wrapper func(Handler) Handler, panicValue any) { @@ -2876,7 +2876,7 @@ func testHandlerPanic(t *testing.T, withHijack bool, mode testMode, wrapper func pr, pw := io.Pipe() defer pw.Close() - var handler Handler = HandlerFunc(func { w, r | + var handler Handler = HandlerFunc(func { w, r -> if withHijack { rwc, _, err := w.(Hijacker).Hijack() if err != nil { @@ -2889,7 +2889,7 @@ func testHandlerPanic(t *testing.T, withHijack bool, mode testMode, wrapper func if wrapper != nil { handler = wrapper(handler) } - cst := newClientServerTest(t, mode, handler, func { ts | ts.Config.ErrorLog = log.New(pw, "", 0) }) + cst := newClientServerTest(t, mode, handler, func { ts -> ts.Config.ErrorLog = log.New(pw, "", 0) }) // Do a blocking read on the log output pipe. done := make(chan bool, 1) @@ -2929,7 +2929,7 @@ func TestServerWriteHijackZeroBytes(t *testing.T) { } func testServerWriteHijackZeroBytes(t *testing.T, mode testMode) { done := make(chan struct{}) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> defer close(done) w.(Flusher).Flush() conn, _, err := w.(Hijacker).Hijack() @@ -2942,7 +2942,7 @@ func testServerWriteHijackZeroBytes(t *testing.T, mode testMode) { if err != ErrHijacked { t.Errorf("Write error = %v; want ErrHijacked", err) } - }), func { ts | ts.Config.ErrorLog = log.New(terrorWriter{t}, "Unexpected write: ", 0) }).ts + }), func { ts -> ts.Config.ErrorLog = log.New(terrorWriter{t}, "Unexpected write: ", 0) }).ts c := ts.Client() res, err := c.Get(ts.URL) @@ -2954,15 +2954,15 @@ func testServerWriteHijackZeroBytes(t *testing.T, mode testMode) { } func TestServerNoDate(t *testing.T) { - run(t, func { t, mode | testServerNoHeader(t, mode, "Date") }) + run(t, func { t, mode -> testServerNoHeader(t, mode, "Date") }) } func TestServerContentType(t *testing.T) { - run(t, func { t, mode | testServerNoHeader(t, mode, "Content-Type") }) + run(t, func { t, mode -> testServerNoHeader(t, mode, "Content-Type") }) } func testServerNoHeader(t *testing.T, mode testMode, header string) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header()[header] = nil io.WriteString(w, "foo") // non-empty })) @@ -2978,7 +2978,7 @@ func testServerNoHeader(t *testing.T, mode testMode, header string) { func TestStripPrefix(t *testing.T) { run(t, testStripPrefix) } func testStripPrefix(t *testing.T, mode testMode) { - h := HandlerFunc(func { w, r | + h := HandlerFunc(func { w, r -> w.Header().Set("X-Path", r.URL.Path) w.Header().Set("X-RawPath", r.URL.RawPath) }) @@ -2997,7 +2997,7 @@ func testStripPrefix(t *testing.T, mode testMode) { {"/bar", "", ""}, // No prefix match. } for _, tc := range cases { - t.Run(tc.reqPath, func { t | + t.Run(tc.reqPath, func { t -> res, err := c.Get(ts.URL + tc.reqPath) if err != nil { t.Fatal(err) @@ -3034,7 +3034,7 @@ func TestStripPrefixNotModifyRequest(t *testing.T) { func TestRequestLimit(t *testing.T) { run(t, testRequestLimit) } func testRequestLimit(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | t.Fatalf("didn't expect to get request in Handler") }), optQuietLog) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> t.Fatalf("didn't expect to get request in Handler") }), optQuietLog) req, _ := NewRequest("GET", cst.ts.URL, nil) var bytesPerHeader = len("header12345: val12345\r\n") for i := 0; i < ((DefaultMaxHeaderBytes+4096)/bytesPerHeader)+1; i++ { @@ -3110,7 +3110,7 @@ func (r *bodyLimitReader) Close() error { func TestRequestBodyLimit(t *testing.T) { run(t, testRequestBodyLimit) } func testRequestBodyLimit(t *testing.T, mode testMode) { const limit = 1 << 20 - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> r.Body = MaxBytesReader(w, r.Body, limit) n, err := io.Copy(io.Discard, r.Body) if err == nil { @@ -3164,7 +3164,7 @@ func testClientWriteShutdown(t *testing.T, mode testMode) { if runtime.GOOS == "plan9" { t.Skip("skipping test; see https://golang.org/issue/17906") } - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> })).ts conn, err := net.Dial("tcp", ts.Listener.Addr().String()) if err != nil { t.Fatalf("Dial: %v", err) @@ -3191,7 +3191,7 @@ func TestServerBufferedChunking(t *testing.T) { conn.readBuf.Write([]byte("GET / HTTP/1.1\r\nHost: foo\r\n\r\n")) conn.closec = make(chan bool, 1) ls := &oneConnListener{conn} - go Serve(ls, HandlerFunc(func { rw, req | + go Serve(ls, HandlerFunc(func { rw, req -> rw.(Flusher).Flush() // force the Header to be sent, in chunking mode, not counting the length rw.Write([]byte{'x'}) rw.Write([]byte{'y'}) @@ -3222,7 +3222,7 @@ func testServerGracefulClose(t *testing.T, mode testMode) { 500 * time.Millisecond, time.Second, 5 * time.Second, - }, func { t, timeout | + }, func { t, timeout -> SetRSTAvoidanceDelay(t, timeout) t.Logf("set RST avoidance delay to %v", timeout) @@ -3232,7 +3232,7 @@ func testServerGracefulClose(t *testing.T, mode testMode) { req = append(req, 'x') } - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | Error(w, "bye", StatusUnauthorized) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> Error(w, "bye", StatusUnauthorized) })) // We need to close cst explicitly here so that in-flight server // requests don't race with the call to SetRSTAvoidanceDelay for a retry. defer cst.close() @@ -3276,7 +3276,7 @@ func testServerGracefulClose(t *testing.T, mode testMode) { func TestCaseSensitiveMethod(t *testing.T) { run(t, testCaseSensitiveMethod) } func testCaseSensitiveMethod(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | if r.Method != "get" { + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.Method != "get" { t.Errorf(`Got method %q; want "get"`, r.Method) } })) defer cst.close() @@ -3298,7 +3298,7 @@ func TestContentLengthZero(t *testing.T) { run(t, testContentLengthZero, []testMode{http1Mode}) } func testContentLengthZero(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req | })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> })).ts for _, version := range []string{"HTTP/1.0", "HTTP/1.1"} { conn, err := net.Dial("tcp", ts.Listener.Addr().String()) @@ -3330,7 +3330,7 @@ func TestCloseNotifier(t *testing.T) { func testCloseNotifier(t *testing.T, mode testMode) { gotReq := make(chan bool, 1) sawClose := make(chan bool, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> gotReq <- true cc := rw.(CloseNotifier).CloseNotify() <-cc @@ -3372,7 +3372,7 @@ func TestCloseNotifierPipelined(t *testing.T) { func testCloseNotifierPipelined(t *testing.T, mode testMode) { gotReq := make(chan bool, 2) sawClose := make(chan bool, 2) - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> gotReq <- true cc := rw.(CloseNotifier).CloseNotify() select { @@ -3427,7 +3427,7 @@ func TestCloseNotifierChanLeak(t *testing.T) { closec: make(chan bool, 1), } ln := &oneConnListener{conn: conn} - handler := HandlerFunc(func { rw, r | + handler := HandlerFunc(func { rw, r -> // Ignore the return value and never read from // it, testing that we don't leak goroutines // on the sending side: @@ -3454,7 +3454,7 @@ func testHijackAfterCloseNotifier(t *testing.T, mode testMode) { script <- "closenotify" script <- "hijack" close(script) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> plan := <-script switch plan { default: @@ -3500,7 +3500,7 @@ func testHijackBeforeRequestBodyRead(t *testing.T, mode testMode) { var requestBody = bytes.Repeat([]byte("a"), 1<<20) bodyOkay := make(chan bool, 1) gotCloseNotify := make(chan bool, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> defer close(bodyOkay) // caller will read false if nothing else reqBody := r.Body @@ -3545,7 +3545,7 @@ func TestOptions(t *testing.T) { run(t, testOptions, []testMode{http1Mode}) } func testOptions(t *testing.T, mode testMode) { uric := make(chan string, 2) // only expect 1, but leave space for 2 mux := NewServeMux() - mux.HandleFunc("/", func { w, r | uric <- r.RequestURI }) + mux.HandleFunc("/", func { w, r -> uric <- r.RequestURI }) ts := newClientServerTest(t, mode, mux).ts conn, err := net.Dial("tcp", ts.Listener.Addr().String()) @@ -3595,7 +3595,7 @@ func TestOptionsHandler(t *testing.T) { run(t, testOptionsHandler, []testMode{ht func testOptionsHandler(t *testing.T, mode testMode) { rc := make(chan *Request, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | rc <- r }), func { ts | ts.Config.DisableGeneralOptionsHandler = true }).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> rc <- r }), func { ts -> ts.Config.DisableGeneralOptionsHandler = true }).ts conn, err := net.Dial("tcp", ts.Listener.Addr().String()) if err != nil { @@ -3839,7 +3839,7 @@ func TestWriteAfterHijack(t *testing.T) { Writer: &buf, closec: make(chan bool, 1), } - handler := HandlerFunc(func { rw, r | + handler := HandlerFunc(func { rw, r -> conn, bufrw, err := rw.(Hijacker).Hijack() if err != nil { t.Error(err) @@ -3870,7 +3870,7 @@ func TestDoubleHijack(t *testing.T) { Writer: &buf, closec: make(chan bool, 1), } - handler := HandlerFunc(func { rw, r | + handler := HandlerFunc(func { rw, r -> conn, _, err := rw.(Hijacker).Hijack() if err != nil { t.Error(err) @@ -3950,7 +3950,7 @@ func TestServerReaderFromOrder(t *testing.T) { run(t, testServerReaderFromOrder) func testServerReaderFromOrder(t *testing.T, mode testMode) { pr, pw := io.Pipe() const size = 3 << 20 - cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> rw.Header().Set("Content-Type", "text/plain") // prevent sniffing path done := make(chan bool) go func() { @@ -3992,7 +3992,7 @@ func testServerReaderFromOrder(t *testing.T, mode testMode) { // Issue 6157, Issue 6685 func TestCodesPreventingContentTypeAndBody(t *testing.T) { for _, code := range []int{StatusNotModified, StatusNoContent} { - ht := newHandlerTest(HandlerFunc(func { w, r | + ht := newHandlerTest(HandlerFunc(func { w, r -> if r.URL.Path == "/header" { w.Header().Set("Content-Length", "123") } @@ -4023,7 +4023,7 @@ func TestCodesPreventingContentTypeAndBody(t *testing.T) { } func TestContentTypeOkayOn204(t *testing.T) { - ht := newHandlerTest(HandlerFunc(func { w, r | + ht := newHandlerTest(HandlerFunc(func { w, r -> w.Header().Set("Content-Length", "123") // suppressed w.Header().Set("Content-Type", "foo/bar") w.WriteHeader(204) @@ -4060,14 +4060,14 @@ func testTransportAndServerSharedBodyRace(t *testing.T, mode testMode) { 500 * time.Millisecond, time.Second, 5 * time.Second, - }, func { t, timeout | + }, func { t, timeout -> SetRSTAvoidanceDelay(t, timeout) t.Logf("set RST avoidance delay to %v", timeout) const bodySize = 1 << 20 var wg sync.WaitGroup - backend := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + backend := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> // Work around https://go.dev/issue/38370: clientServerTest uses // an httptest.Server under the hood, and in HTTP/2 mode it does not always // “[block] until all outstanding requests on this server have completed”, @@ -4091,7 +4091,7 @@ func testTransportAndServerSharedBodyRace(t *testing.T, mode testMode) { }() var proxy *clientServerTest - proxy = newClientServerTest(t, mode, HandlerFunc(func { rw, req | + proxy = newClientServerTest(t, mode, HandlerFunc(func { rw, req -> req2, _ := NewRequest("POST", backend.ts.URL, req.Body) req2.ContentLength = bodySize cancel := make(chan struct{}) @@ -4147,7 +4147,7 @@ func testRequestBodyCloseDoesntBlock(t *testing.T, mode testMode) { readErrCh := make(chan error, 1) errCh := make(chan error, 2) - server := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + server := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> go func(body io.Reader) { _, err := body.Read(make([]byte, 100)) readErrCh <- err @@ -4186,7 +4186,7 @@ func testRequestBodyCloseDoesntBlock(t *testing.T, mode testMode) { // test that ResponseWriter implements io.StringWriter. func TestResponseWriterWriteString(t *testing.T) { okc := make(chan bool, 1) - ht := newHandlerTest(HandlerFunc(func { w, r | + ht := newHandlerTest(HandlerFunc(func { w, r -> _, ok := w.(io.StringWriter) okc <- ok })) @@ -4266,9 +4266,9 @@ func testServerConnState(t *testing.T, mode testMode) { // next call to wantLog. } - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | handler[r.URL.Path](w, r) }), func { ts | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> handler[r.URL.Path](w, r) }), func { ts -> ts.Config.ErrorLog = log.New(io.Discard, "", 0) - ts.Config.ConnState = func { c, state | + ts.Config.ConnState = func { c, state -> if c == nil { t.Errorf("nil conn seen in state %s", state) return @@ -4379,7 +4379,7 @@ func TestServerKeepAlivesEnabledResultClose(t *testing.T) { run(t, testServerKeepAlivesEnabledResultClose, []testMode{http1Mode}) } func testServerKeepAlivesEnabledResultClose(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | }), func { ts | ts.Config.SetKeepAlivesEnabled(false) }).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> }), func { ts -> ts.Config.SetKeepAlivesEnabled(false) }).ts res, err := ts.Client().Get(ts.URL) if err != nil { t.Fatal(err) @@ -4394,7 +4394,7 @@ func testServerKeepAlivesEnabledResultClose(t *testing.T, mode testMode) { func TestServerEmptyBodyRace(t *testing.T) { run(t, testServerEmptyBodyRace) } func testServerEmptyBodyRace(t *testing.T, mode testMode) { var n int32 - cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req | atomic.AddInt32(&n, 1) }), optQuietLog) + cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> atomic.AddInt32(&n, 1) }), optQuietLog) var wg sync.WaitGroup const reqs = 20 for i := 0; i < reqs; i++ { @@ -4434,7 +4434,7 @@ func TestServerConnStateNew(t *testing.T) { sawNew = true // testing that this write isn't racy } }, - Handler: HandlerFunc(func { w, r | }), // irrelevant + Handler: HandlerFunc(func { w, r -> }), // irrelevant } srv.Serve(&oneConnListener{ conn: &rwTestConn{ @@ -4478,7 +4478,7 @@ func TestCloseWrite(t *testing.T) { // So add an explicit test for this. func TestServerFlushAndHijack(t *testing.T) { run(t, testServerFlushAndHijack, []testMode{http1Mode}) } func testServerFlushAndHijack(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> io.WriteString(w, "Hello, ") w.(Flusher).Flush() conn, buf, _ := w.(Hijacker).Hijack() @@ -4519,11 +4519,11 @@ func testServerKeepAliveAfterWriteError(t *testing.T, mode testMode) { } const numReq = 3 addrc := make(chan string, numReq) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> addrc <- r.RemoteAddr time.Sleep(500 * time.Millisecond) w.(Flusher).Flush() - }), func { ts | ts.Config.WriteTimeout = 250 * time.Millisecond }).ts + }), func { ts -> ts.Config.WriteTimeout = 250 * time.Millisecond }).ts errc := make(chan error, numReq) go func() { @@ -4566,7 +4566,7 @@ func TestNoContentLengthIfTransferEncoding(t *testing.T) { run(t, testNoContentLengthIfTransferEncoding, []testMode{http1Mode}) } func testNoContentLengthIfTransferEncoding(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Transfer-Encoding", "foo") io.WriteString(w, "") })).ts @@ -4612,7 +4612,7 @@ func TestTolerateCRLFBeforeRequestLine(t *testing.T) { } ln := &oneConnListener{conn: conn} numReq := 0 - go Serve(ln, HandlerFunc(func { rw, r | numReq++ })) + go Serve(ln, HandlerFunc(func { rw, r -> numReq++ })) <-conn.closec if numReq != 2 { t.Errorf("num requests = %d; want 2", numReq) @@ -4639,7 +4639,7 @@ HelloWorld closec: make(chan bool, 1), } ln := &oneConnListener{conn: conn} - go Serve(ln, HandlerFunc(func { w, r | if _, ok := r.Header["Expect"]; !ok { + go Serve(ln, HandlerFunc(func { w, r -> if _, ok := r.Header["Expect"]; !ok { t.Error("Expect header should not be filtered out") } })) <-conn.closec @@ -4672,7 +4672,7 @@ Host: foo } ln := &oneConnListener{conn: conn} numReq := 0 - go Serve(ln, HandlerFunc(func { w, r | + go Serve(ln, HandlerFunc(func { w, r -> numReq++ if r.URL.Path == "/readbody" { io.ReadAll(r.Body) @@ -4701,7 +4701,7 @@ func TestHandlerFinishSkipBigContentLengthRead(t *testing.T) { ls := &oneConnListener{conn} var inHandlerLen int - go Serve(ls, HandlerFunc(func { rw, req | + go Serve(ls, HandlerFunc(func { rw, req -> inHandlerLen = conn.readBuf.Len() rw.WriteHeader(404) })) @@ -4715,7 +4715,7 @@ func TestHandlerFinishSkipBigContentLengthRead(t *testing.T) { func TestHandlerSetsBodyNil(t *testing.T) { run(t, testHandlerSetsBodyNil) } func testHandlerSetsBodyNil(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> r.Body = nil fmt.Fprintf(w, "%v", r.RemoteAddr) })) @@ -4812,7 +4812,7 @@ func TestServerHandlersCanHandleH2PRI(t *testing.T) { } func testServerHandlersCanHandleH2PRI(t *testing.T, mode testMode) { const upgradeResponse = "upgrade here" - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> conn, br, err := w.(Hijacker).Hijack() if err != nil { t.Error(err) @@ -4916,7 +4916,7 @@ func TestServerRequestContextCancel_ServeHTTPDone(t *testing.T) { } func testServerRequestContextCancel_ServeHTTPDone(t *testing.T, mode testMode) { ctxc := make(chan context.Context, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ctx := r.Context() select { case <-ctx.Done(): @@ -4948,7 +4948,7 @@ func TestServerRequestContextCancel_ConnClose(t *testing.T) { func testServerRequestContextCancel_ConnClose(t *testing.T, mode testMode) { inHandler := make(chan struct{}) handlerDone := make(chan struct{}) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> close(inHandler) <-r.Context().Done() close(handlerDone) @@ -4968,7 +4968,7 @@ func TestServerContext_ServerContextKey(t *testing.T) { run(t, testServerContext_ServerContextKey) } func testServerContext_ServerContextKey(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ctx := r.Context() got := ctx.Value(ServerContextKey) if _, ok := got.(*Server); !ok { @@ -4987,7 +4987,7 @@ func TestServerContext_LocalAddrContextKey(t *testing.T) { } func testServerContext_LocalAddrContextKey(t *testing.T, mode testMode) { ch := make(chan any, 1) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | ch <- r.Context().Value(LocalAddrContextKey) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> ch <- r.Context().Value(LocalAddrContextKey) })) if _, err := cst.c.Head(cst.ts.URL); err != nil { t.Fatal(err) } @@ -5005,7 +5005,7 @@ func testServerContext_LocalAddrContextKey(t *testing.T, mode testMode) { func TestHandlerSetTransferEncodingChunked(t *testing.T) { setParallel(t) defer afterTest(t) - ht := newHandlerTest(HandlerFunc(func { w, r | + ht := newHandlerTest(HandlerFunc(func { w, r -> w.Header().Set("Transfer-Encoding", "chunked") w.Write([]byte("hello")) })) @@ -5020,7 +5020,7 @@ func TestHandlerSetTransferEncodingChunked(t *testing.T) { func TestHandlerSetTransferEncodingGzip(t *testing.T) { setParallel(t) defer afterTest(t) - ht := newHandlerTest(HandlerFunc(func { w, r | + ht := newHandlerTest(HandlerFunc(func { w, r -> w.Header().Set("Transfer-Encoding", "gzip") gz := gzip.NewWriter(w) gz.Write([]byte("hello")) @@ -5041,7 +5041,7 @@ func BenchmarkClientServer(b *testing.B) { func benchmarkClientServer(b *testing.B, mode testMode) { b.ReportAllocs() b.StopTimer() - ts := newClientServerTest(b, mode, HandlerFunc(func { rw, r | fmt.Fprintf(rw, "Hello world.\n") })).ts + ts := newClientServerTest(b, mode, HandlerFunc(func { rw, r -> fmt.Fprintf(rw, "Hello world.\n") })).ts b.StartTimer() c := ts.Client() @@ -5066,18 +5066,18 @@ func benchmarkClientServer(b *testing.B, mode testMode) { func BenchmarkClientServerParallel(b *testing.B) { for _, parallelism := range []int{4, 64} { - b.Run(fmt.Sprint(parallelism), func { b | - run(b, func { b, mode | benchmarkClientServerParallel(b, parallelism, mode) }, []testMode{http1Mode, https1Mode, http2Mode}) + b.Run(fmt.Sprint(parallelism), func { b -> + run(b, func { b, mode -> benchmarkClientServerParallel(b, parallelism, mode) }, []testMode{http1Mode, https1Mode, http2Mode}) }) } } func benchmarkClientServerParallel(b *testing.B, parallelism int, mode testMode) { b.ReportAllocs() - ts := newClientServerTest(b, mode, HandlerFunc(func { rw, r | fmt.Fprintf(rw, "Hello world.\n") })).ts + ts := newClientServerTest(b, mode, HandlerFunc(func { rw, r -> fmt.Fprintf(rw, "Hello world.\n") })).ts b.ResetTimer() b.SetParallelism(parallelism) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> c := ts.Client() for pb.Next() { res, err := c.Get(ts.URL) @@ -5137,7 +5137,7 @@ func BenchmarkServer(b *testing.B) { var res = []byte("Hello world.\n") b.StopTimer() - ts := httptest.NewServer(HandlerFunc(func { rw, r | + ts := httptest.NewServer(HandlerFunc(func { rw, r -> rw.Header().Set("Content-Type", "text/html; charset=utf-8") rw.Write(res) })) @@ -5185,7 +5185,7 @@ func BenchmarkClient(b *testing.B) { os.Exit(1) } fmt.Println(ln.Addr().String()) - HandleFunc("/", func { w, r | + HandleFunc("/", func { w, r -> r.ParseForm() if r.Form.Get("stop") != "" { os.Exit(0) @@ -5269,7 +5269,7 @@ Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 res := []byte("Hello world!\n") conn := newTestConn() - handler := HandlerFunc(func { rw, r | + handler := HandlerFunc(func { rw, r -> rw.Header().Set("Content-Type", "text/html; charset=utf-8") rw.Write(res) }) @@ -5323,7 +5323,7 @@ Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 closec: make(chan bool, 1), } handled := 0 - handler := HandlerFunc(func { rw, r | + handler := HandlerFunc(func { rw, r -> handled++ rw.Header().Set("Content-Type", "text/html; charset=utf-8") rw.Write(res) @@ -5352,7 +5352,7 @@ Host: golang.org closec: make(chan bool, 1), } handled := 0 - handler := HandlerFunc(func { rw, r | + handler := HandlerFunc(func { rw, r -> handled++ rw.Write(res) }) @@ -5371,7 +5371,7 @@ var response = bytes.Repeat([]byte(someResponse), 2<<10/len(someResponse)) // Both Content-Type and Content-Length set. Should be no buffering. func BenchmarkServerHandlerTypeLen(b *testing.B) { - benchmarkHandler(b, HandlerFunc(func { w, r | + benchmarkHandler(b, HandlerFunc(func { w, r -> w.Header().Set("Content-Type", "text/html") w.Header().Set("Content-Length", strconv.Itoa(len(response))) w.Write(response) @@ -5380,7 +5380,7 @@ func BenchmarkServerHandlerTypeLen(b *testing.B) { // A Content-Type is set, but no length. No sniffing, but will count the Content-Length. func BenchmarkServerHandlerNoLen(b *testing.B) { - benchmarkHandler(b, HandlerFunc(func { w, r | + benchmarkHandler(b, HandlerFunc(func { w, r -> w.Header().Set("Content-Type", "text/html") w.Write(response) })) @@ -5388,7 +5388,7 @@ func BenchmarkServerHandlerNoLen(b *testing.B) { // A Content-Length is set, but the Content-Type will be sniffed. func BenchmarkServerHandlerNoType(b *testing.B) { - benchmarkHandler(b, HandlerFunc(func { w, r | + benchmarkHandler(b, HandlerFunc(func { w, r -> w.Header().Set("Content-Length", strconv.Itoa(len(response))) w.Write(response) })) @@ -5396,7 +5396,7 @@ func BenchmarkServerHandlerNoType(b *testing.B) { // Neither a Content-Type or Content-Length, so sniffed and counted. func BenchmarkServerHandlerNoHeader(b *testing.B) { - benchmarkHandler(b, HandlerFunc(func { w, r | w.Write(response) })) + benchmarkHandler(b, HandlerFunc(func { w, r -> w.Write(response) })) } func benchmarkHandler(b *testing.B, h Handler) { @@ -5410,7 +5410,7 @@ Host: golang.org closec: make(chan bool, 1), } handled := 0 - handler := HandlerFunc(func { rw, r | + handler := HandlerFunc(func { rw, r -> handled++ h.ServeHTTP(rw, r) }) @@ -5427,7 +5427,7 @@ func BenchmarkServerHijack(b *testing.B) { req := reqBytes(`GET / HTTP/1.1 Host: golang.org `) - h := HandlerFunc(func { w, r | + h := HandlerFunc(func { w, r -> conn, _, err := w.(Hijacker).Hijack() if err != nil { panic(err) @@ -5452,7 +5452,7 @@ func benchmarkCloseNotifier(b *testing.B, mode testMode) { b.ReportAllocs() b.StopTimer() sawClose := make(chan bool) - ts := newClientServerTest(b, mode, HandlerFunc(func { rw, req | + ts := newClientServerTest(b, mode, HandlerFunc(func { rw, req -> <-rw.(CloseNotifier).CloseNotify() sawClose <- true })).ts @@ -5494,11 +5494,11 @@ func testServerIdleTimeout(t *testing.T, mode testMode) { 100 * time.Millisecond, 1 * time.Second, 10 * time.Second, - }, func { t, readHeaderTimeout | - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + }, func { t, readHeaderTimeout -> + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> io.Copy(io.Discard, r.Body) io.WriteString(w, r.RemoteAddr) - }), func { ts | + }), func { ts -> ts.Config.ReadHeaderTimeout = readHeaderTimeout ts.Config.IdleTimeout = 2 * readHeaderTimeout }) @@ -5579,7 +5579,7 @@ func TestServerSetKeepAlivesEnabledClosesConns(t *testing.T) { run(t, testServerSetKeepAlivesEnabledClosesConns, []testMode{http1Mode}) } func testServerSetKeepAlivesEnabledClosesConns(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | io.WriteString(w, r.RemoteAddr) })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> io.WriteString(w, r.RemoteAddr) })).ts c := ts.Client() tr := c.Transport.(*Transport) @@ -5604,7 +5604,7 @@ func testServerSetKeepAlivesEnabledClosesConns(t *testing.T, mode testMode) { // SetKeepAlivesEnabled should discard idle conns. ts.Config.SetKeepAlivesEnabled(false) - waitCondition(t, 10*time.Millisecond, func { d | + waitCondition(t, 10*time.Millisecond, func { d -> if conns := tr.IdleConnStrsForTesting(); len(conns) > 0 { if d > 0 { t.Logf("idle conns %v after SetKeepAlivesEnabled called = %q; waiting for empty", d, conns) @@ -5627,7 +5627,7 @@ func testServerShutdown(t *testing.T, mode testMode) { statesRes := make(chan map[ConnState]int, 1) shutdownRes := make(chan error, 1) gotOnShutdown := make(chan struct{}) - handler := HandlerFunc(func { w, r | + handler := HandlerFunc(func { w, r -> first := false once.Do(func() { statesRes <- cst.ts.Config.ExportAllConnsByState() @@ -5663,7 +5663,7 @@ func testServerShutdown(t *testing.T, mode testMode) { io.WriteString(w, r.RemoteAddr) }) - cst = newClientServerTest(t, mode, handler, func { srv | srv.Config.RegisterOnShutdown(func() { close(gotOnShutdown) }) }) + cst = newClientServerTest(t, mode, handler, func { srv -> srv.Config.RegisterOnShutdown(func() { close(gotOnShutdown) }) }) out := get(t, cst.c, cst.ts.URL) // calls t.Fail on failure t.Logf("%v: %q", cst.ts.URL, out) @@ -5685,10 +5685,10 @@ func testServerShutdownStateNew(t *testing.T, mode testMode) { } var connAccepted sync.WaitGroup - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> // nothing. - }), func { ts | - ts.Config.ConnState = func { conn, state | if state == StateNew { + }), func { ts -> + ts.Config.ConnState = func { conn, state -> if state == StateNew { connAccepted.Done() } } }).ts @@ -5759,12 +5759,12 @@ func testServerKeepAlivesEnabled(t *testing.T, mode testMode) { defer restore() } // Not parallel: messes with global variable. (http2goAwayTimeout) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> })) defer cst.close() srv := cst.ts.Config srv.SetKeepAlivesEnabled(false) for try := 0; try < 2; try++ { - waitCondition(t, 10*time.Millisecond, func { d | + waitCondition(t, 10*time.Millisecond, func { d -> if !srv.ExportAllConnsIdle() { if d > 0 { t.Logf("test server still has active conns after %v", d) @@ -5810,15 +5810,15 @@ func testServerCancelsReadTimeoutWhenIdle(t *testing.T, mode testMode) { 250 * time.Millisecond, time.Second, 2 * time.Second, - }, func { t, timeout | - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + }, func { t, timeout -> + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> select { case <-time.After(2 * timeout): fmt.Fprint(w, "ok") case <-r.Context().Done(): fmt.Fprint(w, r.Context().Err()) } - }), func { ts | + }), func { ts -> ts.Config.ReadTimeout = timeout t.Logf("Server.Config.ReadTimeout = %v", timeout) }) @@ -5864,8 +5864,8 @@ func testServerCancelsReadHeaderTimeoutWhenIdle(t *testing.T, mode testMode) { 250 * time.Millisecond, time.Second, 2 * time.Second, - }, func { t, timeout | - cst := newClientServerTest(t, mode, serve(200), func { ts | + }, func { t, timeout -> + cst := newClientServerTest(t, mode, serve(200), func { ts -> ts.Config.ReadHeaderTimeout = timeout ts.Config.IdleTimeout = 0 // disable idle timeout }) @@ -5988,7 +5988,7 @@ func testServerHijackGetsBackgroundByte(t *testing.T, mode testMode) { } done := make(chan struct{}) inHandler := make(chan bool, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> defer close(done) // Tell the client to send more data after the GET request. @@ -6044,7 +6044,7 @@ func testServerHijackGetsBackgroundByte_big(t *testing.T, mode testMode) { } done := make(chan struct{}) const size = 8 << 10 - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> defer close(done) conn, buf, err := w.(Hijacker).Hijack() @@ -6186,8 +6186,8 @@ func TestServerShutdownThenServe(t *testing.T) { func TestStripPortFromHost(t *testing.T) { mux := NewServeMux() - mux.HandleFunc("example.com/", func { w, r | fmt.Fprintf(w, "OK") }) - mux.HandleFunc("example.com:9000/", func { w, r | fmt.Fprintf(w, "uh-oh!") }) + mux.HandleFunc("example.com/", func { w, r -> fmt.Fprintf(w, "OK") }) + mux.HandleFunc("example.com:9000/", func { w, r -> fmt.Fprintf(w, "uh-oh!") }) req := httptest.NewRequest("GET", "http://example.com:9000/", nil) rw := httptest.NewRecorder() @@ -6205,14 +6205,14 @@ func testServerContexts(t *testing.T, mode testMode) { type baseKey struct{} type connKey struct{} ch := make(chan context.Context, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, r | ch <- r.Context() }), func { ts | - ts.Config.BaseContext = func { ln | + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, r -> ch <- r.Context() }), func { ts -> + ts.Config.BaseContext = func { ln -> if strings.Contains(reflect.TypeOf(ln).String(), "onceClose") { t.Errorf("unexpected onceClose listener type %T", ln) } return context.WithValue(context.Background(), baseKey{}, "base") } - ts.Config.ConnContext = func { ctx, c | + ts.Config.ConnContext = func { ctx, c -> if got, want := ctx.Value(baseKey{}), "base"; got != want { t.Errorf("in ConnContext, base context key = %#v; want %q", got, want) } @@ -6239,8 +6239,8 @@ func TestConnContextNotModifyingAllContexts(t *testing.T) { } func testConnContextNotModifyingAllContexts(t *testing.T, mode testMode) { type connKey struct{} - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, r | rw.Header().Set("Connection", "close") }), func { ts | - ts.Config.ConnContext = func { ctx, c | + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, r -> rw.Header().Set("Connection", "close") }), func { ts -> + ts.Config.ConnContext = func { ctx, c -> if got := ctx.Value(connKey{}); got != nil { t.Errorf("in ConnContext, unexpected context key = %#v", got) } @@ -6270,7 +6270,7 @@ func TestUnsupportedTransferEncodingsReturn501(t *testing.T) { run(t, testUnsupportedTransferEncodingsReturn501, []testMode{http1Mode}) } func testUnsupportedTransferEncodingsReturn501(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.Write([]byte("Hello, World!")) })).ts + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Write([]byte("Hello, World!")) })).ts serverURL, err := url.Parse(cst.URL) if err != nil { @@ -6369,8 +6369,8 @@ func testContentEncodingNoSniffing(t *testing.T, mode testMode) { } for _, tt := range settings { - t.Run(tt.name, func { t | - cst := newClientServerTest(t, mode, HandlerFunc(func { rw, r | + t.Run(tt.name, func { t -> + cst := newClientServerTest(t, mode, HandlerFunc(func { rw, r -> if tt.contentEncoding != nil { rw.Header().Set("Content-Encoding", tt.contentEncoding.(string)) } @@ -6433,12 +6433,12 @@ func testTimeoutHandlerSuperfluousLogs(t *testing.T, mode testMode) { for _, tt := range tests { tt := tt - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> exitHandler := make(chan bool, 1) defer close(exitHandler) lastLine := make(chan int, 1) - sh := HandlerFunc(func { w, r | + sh := HandlerFunc(func { w, r -> w.WriteHeader(404) w.WriteHeader(404) w.WriteHeader(404) @@ -6523,7 +6523,7 @@ func fetchWireResponse(host string, http1ReqBody []byte) ([]byte, error) { func BenchmarkResponseStatusLine(b *testing.B) { b.ReportAllocs() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> bw := bufio.NewWriter(io.Discard) var buf3 [3]byte for pb.Next() { @@ -6540,7 +6540,7 @@ func testDisableKeepAliveUpgrade(t *testing.T, mode testMode) { t.Skip("skipping in short mode") } - s := newClientServerTest(t, mode, HandlerFunc(func { w, r | + s := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Connection", "Upgrade") w.Header().Set("Upgrade", "someProto") w.WriteHeader(StatusSwitchingProtocols) @@ -6553,7 +6553,7 @@ func testDisableKeepAliveUpgrade(t *testing.T, mode testMode) { // Copy from the *bufio.ReadWriter, which may contain buffered data. // Copy to the net.Conn, to avoid buffering the output. io.Copy(c, buf) - }), func { ts | ts.Config.SetKeepAlivesEnabled(false) }).ts + }), func { ts -> ts.Config.SetKeepAlivesEnabled(false) }).ts cl := s.Client() cl.Transport.(*Transport).DisableKeepAlives = true @@ -6602,7 +6602,7 @@ func TestWriteHeaderSwitchingProtocols(t *testing.T) { func testWriteHeaderSwitchingProtocols(t *testing.T, mode testMode) { const wantBody = "want" const wantUpgrade = "someProto" - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Connection", "Upgrade") w.Header().Set("Upgrade", wantUpgrade) w.WriteHeader(StatusSwitchingProtocols) @@ -6623,7 +6623,7 @@ func testWriteHeaderSwitchingProtocols(t *testing.T, mode testMode) { if _, err := c.Write([]byte(wantBody)); err != nil { t.Errorf("Write to hijacked body: %v", err) } - }), func { ts | + }), func { ts -> // Don't spam log with warning about superfluous WriteHeader call. ts.Config.ErrorLog = log.New(tlogWriter{t}, "log: ", 0) }).ts @@ -6690,13 +6690,13 @@ func TestQuerySemicolon(t *testing.T) { {"?a=1;x=good;x=bad", "", "good", true}, } - run(t, func { t, mode | + run(t, func { t, mode -> for _, tt := range tests { - t.Run(tt.query+"/allow=false", func { t | + t.Run(tt.query+"/allow=false", func { t -> allowSemicolons := false testQuerySemicolon(t, mode, tt.query, tt.xNoSemicolons, allowSemicolons, tt.expectParseFormErr) }) - t.Run(tt.query+"/allow=true", func { t | + t.Run(tt.query+"/allow=true", func { t -> allowSemicolons, expectParseFormErr := true, false testQuerySemicolon(t, mode, tt.query, tt.xWithSemicolons, allowSemicolons, expectParseFormErr) }) @@ -6728,7 +6728,7 @@ func testQuerySemicolon(t *testing.T, mode testMode, query string, wantX string, } logBuf := &strings.Builder{} - ts := newClientServerTest(t, mode, h, func { ts | ts.Config.ErrorLog = log.New(logBuf, "", 0) }).ts + ts := newClientServerTest(t, mode, h, func { ts -> ts.Config.ErrorLog = log.New(logBuf, "", 0) }).ts req, _ := NewRequest("GET", ts.URL+query, nil) res, err := ts.Client().Do(req) @@ -6752,8 +6752,8 @@ func TestMaxBytesHandler(t *testing.T) { for _, maxSize := range []int64{100, 1_000, 1_000_000} { for _, requestSize := range []int64{100, 1_000, 1_000_000} { t.Run(fmt.Sprintf("max size %d request size %d", maxSize, requestSize), - func { t | - run(t, func { t, mode | testMaxBytesHandler(t, mode, maxSize, requestSize) }, testNotParallel) + func { t -> + run(t, func { t, mode -> testMaxBytesHandler(t, mode, maxSize, requestSize) }, testNotParallel) }) } } @@ -6769,7 +6769,7 @@ func testMaxBytesHandler(t *testing.T, mode testMode, maxSize, requestSize int64 500 * time.Millisecond, time.Second, 5 * time.Second, - }, func { t, timeout | + }, func { t, timeout -> SetRSTAvoidanceDelay(t, timeout) t.Logf("set RST avoidance delay to %v", timeout) @@ -6777,7 +6777,7 @@ func testMaxBytesHandler(t *testing.T, mode testMode, maxSize, requestSize int64 handlerN int64 handlerErr error ) - echo := HandlerFunc(func { w, r | + echo := HandlerFunc(func { w, r -> var buf bytes.Buffer handlerN, handlerErr = io.Copy(&buf, r.Body) io.Copy(w, &buf) @@ -6849,7 +6849,7 @@ func testMaxBytesHandler(t *testing.T, mode testMode, maxSize, requestSize int64 } func TestEarlyHints(t *testing.T) { - ht := newHandlerTest(HandlerFunc(func { w, r | + ht := newHandlerTest(HandlerFunc(func { w, r -> h := w.Header() h.Add("Link", "; rel=preload; as=style") h.Add("Link", "; rel=preload; as=script") @@ -6868,7 +6868,7 @@ func TestEarlyHints(t *testing.T) { } } func TestProcessing(t *testing.T) { - ht := newHandlerTest(HandlerFunc(func { w, r | + ht := newHandlerTest(HandlerFunc(func { w, r -> w.WriteHeader(StatusProcessing) w.Write([]byte("stuff")) })) @@ -6894,7 +6894,7 @@ func testParseFormCleanup(t *testing.T, mode testMode) { t.Skip("https://go.dev/issue/25965") } - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> r.ParseMultipartForm(maxMemory) f, _, err := r.FormFile(key) if err != nil { @@ -6944,23 +6944,23 @@ func testParseFormCleanup(t *testing.T, mode testMode) { func TestHeadBody(t *testing.T) { const identityMode = false const chunkedMode = true - run(t, func { t, mode | - t.Run("identity", func { t | testHeadBody(t, mode, identityMode, "HEAD") }) - t.Run("chunked", func { t | testHeadBody(t, mode, chunkedMode, "HEAD") }) + run(t, func { t, mode -> + t.Run("identity", func { t -> testHeadBody(t, mode, identityMode, "HEAD") }) + t.Run("chunked", func { t -> testHeadBody(t, mode, chunkedMode, "HEAD") }) }) } func TestGetBody(t *testing.T) { const identityMode = false const chunkedMode = true - run(t, func { t, mode | - t.Run("identity", func { t | testHeadBody(t, mode, identityMode, "GET") }) - t.Run("chunked", func { t | testHeadBody(t, mode, chunkedMode, "GET") }) + run(t, func { t, mode -> + t.Run("identity", func { t -> testHeadBody(t, mode, identityMode, "GET") }) + t.Run("chunked", func { t -> testHeadBody(t, mode, chunkedMode, "GET") }) }) } func testHeadBody(t *testing.T, mode testMode, chunked bool, method string) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> b, err := io.ReadAll(r.Body) if err != nil { t.Errorf("server reading body: %v", err) @@ -7009,7 +7009,7 @@ func testDisableContentLength(t *testing.T, mode testMode) { t.Skip("skipping until h2_bundle.go is updated; see https://go-review.googlesource.com/c/net/+/471535") } - noCL := newClientServerTest(t, mode, HandlerFunc(func { w, r | + noCL := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header()["Content-Length"] = nil // disable the default Content-Length response fmt.Fprintf(w, "OK") })) @@ -7025,7 +7025,7 @@ func testDisableContentLength(t *testing.T, mode testMode) { t.Fatal(err) } - withCL := newClientServerTest(t, mode, HandlerFunc(func { w, r | fmt.Fprintf(w, "OK") })) + withCL := newClientServerTest(t, mode, HandlerFunc(func { w, r -> fmt.Fprintf(w, "OK") })) res, err = withCL.c.Get(withCL.ts.URL) if err != nil { @@ -7042,7 +7042,7 @@ func testDisableContentLength(t *testing.T, mode testMode) { func TestErrorContentLength(t *testing.T) { run(t, testErrorContentLength) } func testErrorContentLength(t *testing.T, mode testMode) { const errorBody = "an error occurred" - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Length", "1000") Error(w, errorBody, 400) })) @@ -7087,12 +7087,12 @@ func TestServerReadAfterWriteHeader100Continue(t *testing.T) { func testServerReadAfterWriteHeader100Continue(t *testing.T, mode testMode) { t.Skip("https://go.dev/issue/67555") body := []byte("body") - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.WriteHeader(200) NewResponseController(w).Flush() io.ReadAll(r.Body) w.Write(body) - }), func { tr | tr.ExpectContinueTimeout = 24 * time.Hour })// forever + }), func { tr -> tr.ExpectContinueTimeout = 24 * time.Hour })// forever req, _ := NewRequest("GET", cst.ts.URL, strings.NewReader("body")) req.Header.Set("Expect", "100-continue") @@ -7116,11 +7116,11 @@ func TestServerReadAfterHandlerDone100Continue(t *testing.T) { func testServerReadAfterHandlerDone100Continue(t *testing.T, mode testMode) { t.Skip("https://go.dev/issue/67555") readyc := make(chan struct{}) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | go func() { + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> go func() { <-readyc io.ReadAll(r.Body) <-readyc - }() }), func { tr | tr.ExpectContinueTimeout = 24 * time.Hour })// forever + }() }), func { tr -> tr.ExpectContinueTimeout = 24 * time.Hour })// forever req, _ := NewRequest("GET", cst.ts.URL, strings.NewReader("body")) req.Header.Set("Expect", "100-continue") @@ -7139,14 +7139,14 @@ func TestServerReadAfterHandlerAbort100Continue(t *testing.T) { func testServerReadAfterHandlerAbort100Continue(t *testing.T, mode testMode) { t.Skip("https://go.dev/issue/67555") readyc := make(chan struct{}) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> go func() { <-readyc io.ReadAll(r.Body) <-readyc }() panic(ErrAbortHandler) - }), func { tr | tr.ExpectContinueTimeout = 24 * time.Hour })// forever + }), func { tr -> tr.ExpectContinueTimeout = 24 * time.Hour })// forever req, _ := NewRequest("GET", cst.ts.URL, strings.NewReader("body")) req.Header.Set("Expect", "100-continue") diff --git a/src/net/http/servemux121.go b/src/net/http/servemux121.go index d67fe707d6544..c8232116b27bf 100644 --- a/src/net/http/servemux121.go +++ b/src/net/http/servemux121.go @@ -79,7 +79,7 @@ func (mux *serveMux121) handle(pattern string, handler Handler) { func appendSorted(es []muxEntry, e muxEntry) []muxEntry { n := len(es) - i := sort.Search(n, func { i | return len(es[i].pattern) < len(e.pattern) }) + i := sort.Search(n, func { i -> return len(es[i].pattern) < len(e.pattern) }) if i == n { return append(es, e) } diff --git a/src/net/http/server.go b/src/net/http/server.go index 29a2f74fd57fd..36b42d5a42923 100644 --- a/src/net/http/server.go +++ b/src/net/http/server.go @@ -2269,7 +2269,7 @@ func StripPrefix(prefix string, h Handler) Handler { if prefix == "" { return h } - return HandlerFunc(func { w, r | + return HandlerFunc(func { w, r -> p := strings.TrimPrefix(r.URL.Path, prefix) rp := strings.TrimPrefix(r.URL.RawPath, prefix) if len(p) < len(r.URL.Path) && (r.URL.RawPath == "" || len(rp) < len(r.URL.RawPath)) { @@ -2628,7 +2628,7 @@ func (mux *ServeMux) findHandler(r *Request) (h Handler, patStr string, _ *patte // matches except for the method. allowedMethods := mux.matchingMethods(host, path) if len(allowedMethods) > 0 { - return HandlerFunc(func { w, r | + return HandlerFunc(func { w, r -> w.Header().Set("Allow", strings.Join(allowedMethods, ", ")) Error(w, StatusText(StatusMethodNotAllowed), StatusMethodNotAllowed) }), "", nil, nil @@ -2826,7 +2826,7 @@ func (mux *ServeMux) registerErr(patstr string, handler Handler) error { mux.mu.Lock() defer mux.mu.Unlock() // Check for conflict. - if err := mux.index.possiblyConflictingPatterns(pat, func { pat2 | + if err := mux.index.possiblyConflictingPatterns(pat, func { pat2 -> if pat.conflictsWith(pat2) { d := describeConflict(pat, pat2) return fmt.Errorf("pattern %q (registered at %s) conflicts with pattern %q (registered at %s):\n%s", @@ -3222,7 +3222,7 @@ func badServeHTTP(serverHandler, ResponseWriter, *Request) // // AllowQuerySemicolons should be invoked before [Request.ParseForm] is called. func AllowQuerySemicolons(h Handler) Handler { - return HandlerFunc(func { w, r | + return HandlerFunc(func { w, r -> if strings.Contains(r.URL.RawQuery, ";") { r2 := new(Request) *r2 = *r @@ -3900,7 +3900,7 @@ func tlsRecordHeaderLooksLikeHTTP(hdr [5]byte) bool { // MaxBytesHandler returns a [Handler] that runs h with its [ResponseWriter] and [Request.Body] wrapped by a MaxBytesReader. func MaxBytesHandler(h Handler, n int64) Handler { - return HandlerFunc(func { w, r | + return HandlerFunc(func { w, r -> r2 := *r r2.Body = MaxBytesReader(w, r.Body, n) h.ServeHTTP(w, &r2) diff --git a/src/net/http/server_test.go b/src/net/http/server_test.go index 06b21eb33b4f3..2a633d63bd6fc 100644 --- a/src/net/http/server_test.go +++ b/src/net/http/server_test.go @@ -148,7 +148,7 @@ func TestRegisterErr(t *testing.T) { {"/{x", h, `parsing "/\{x": at offset 1: bad wildcard segment`}, {"/a", h, `conflicts with pattern.* \(registered at .*/server_test.go:\d+`}, } { - t.Run(fmt.Sprintf("%s:%#v", test.pattern, test.handler), func { t | + t.Run(fmt.Sprintf("%s:%#v", test.pattern, test.handler), func { t -> err := mux.registerErr(test.pattern, test.handler) if err == nil { t.Fatal("got nil error") @@ -222,7 +222,7 @@ func TestEscapedPathsAndPatterns(t *testing.T) { mux := NewServeMux() for _, m := range matches { - mux.HandleFunc(m.pattern, func { w, r | }) + mux.HandleFunc(m.pattern, func { w, r -> }) } for _, m := range matches { @@ -246,8 +246,8 @@ func TestEscapedPathsAndPatterns(t *testing.T) { } } - t.Run("latest", func { t | run(t, false) }) - t.Run("1.21", func { t | run(t, true) }) + t.Run("latest", func { t -> run(t, false) }) + t.Run("1.21", func { t -> run(t, true) }) } func TestCleanPath(t *testing.T) { diff --git a/src/net/http/sniff_test.go b/src/net/http/sniff_test.go index 74c3a0c630a5b..bad45f9cdad99 100644 --- a/src/net/http/sniff_test.go +++ b/src/net/http/sniff_test.go @@ -90,7 +90,7 @@ func TestDetectContentType(t *testing.T) { func TestServerContentTypeSniff(t *testing.T) { run(t, testServerContentTypeSniff) } func testServerContentTypeSniff(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> i, _ := strconv.Atoi(r.FormValue("i")) tt := sniffTests[i] n, err := w.Write(tt.data) @@ -132,7 +132,7 @@ func testServerContentTypeSniff(t *testing.T, mode testMode) { // even if it's the empty string. func TestServerIssue5953(t *testing.T) { run(t, testServerIssue5953) } func testServerIssue5953(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header()["Content-Type"] = []string{""} fmt.Fprintf(w, "hi") })) @@ -228,7 +228,7 @@ func testContentTypeWithVariousSources(t *testing.T, mode testMode) { } }, }} { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> cst := newClientServerTest(t, mode, HandlerFunc(test.handler)) resp, err := cst.c.Get(cst.ts.URL) @@ -255,7 +255,7 @@ func testContentTypeWithVariousSources(t *testing.T, mode testMode) { func TestSniffWriteSize(t *testing.T) { run(t, testSniffWriteSize) } func testSniffWriteSize(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> size, _ := strconv.Atoi(r.FormValue("size")) written, err := io.WriteString(w, strings.Repeat("a", size)) if err != nil { diff --git a/src/net/http/transfer.go b/src/net/http/transfer.go index 1f59b9ec0dcfb..5e3852f801086 100644 --- a/src/net/http/transfer.go +++ b/src/net/http/transfer.go @@ -783,7 +783,7 @@ func fixTrailer(header Header, chunked bool) (Header, error) { trailer := make(Header) var err error for _, v := range vv { - foreachHeaderElement(v, func { key | + foreachHeaderElement(v, func { key -> key = CanonicalHeaderKey(key) switch key { case "Transfer-Encoding", "Trailer", "Content-Length": diff --git a/src/net/http/transfer_test.go b/src/net/http/transfer_test.go index 52a9793852f06..0c9ebf7499730 100644 --- a/src/net/http/transfer_test.go +++ b/src/net/http/transfer_test.go @@ -233,7 +233,7 @@ func TestTransferWriterWriteBodyReaderTypes(t *testing.T) { } for _, tc := range cases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> body, cleanup, err := tc.bodyFunc() if err != nil { t.Fatal(err) diff --git a/src/net/http/transport.go b/src/net/http/transport.go index 3567eb50405bb..822e66e9f73a5 100644 --- a/src/net/http/transport.go +++ b/src/net/http/transport.go @@ -846,7 +846,7 @@ func (t *Transport) CloseIdleConnections() { } } t.connsPerHostMu.Lock() - t.dialsInProgress.all(func { w | if w.cancelCtx != nil && !w.waiting() { + t.dialsInProgress.all(func { w -> if w.cancelCtx != nil && !w.waiting() { w.cancelCtx() } }) t.connsPerHostMu.Unlock() @@ -1764,7 +1764,7 @@ func (t *Transport) dialConn(ctx context.Context, cm connectMethod) (pconn *pers case cm.targetScheme == "http": pconn.isProxy = true if pa := cm.proxyAuth(); pa != "" { - pconn.mutateHeaderFunc = func { h | h.Set("Proxy-Authorization", pa) } + pconn.mutateHeaderFunc = func { h -> h.Set("Proxy-Authorization", pa) } } case cm.targetScheme == "https": conn := pconn.conn diff --git a/src/net/http/transport_dial_test.go b/src/net/http/transport_dial_test.go index 700b16237c642..b75f7587dd149 100644 --- a/src/net/http/transport_dial_test.go +++ b/src/net/http/transport_dial_test.go @@ -118,7 +118,7 @@ func newTransportDialTester(t *testing.T, mode testMode) *transportDialTester { t: t, dials: make(chan *transportDialTesterConn), } - dt.cst = newClientServerTest(t, mode, http.HandlerFunc(func { w, r | + dt.cst = newClientServerTest(t, mode, http.HandlerFunc(func { w, r -> // Write response headers when we receive a request. http.NewResponseController(w).EnableFullDuplex() w.WriteHeader(200) @@ -126,8 +126,8 @@ func newTransportDialTester(t *testing.T, mode testMode) *transportDialTester { // Wait for the client to send the request body, // to synchronize with the rest of the test. io.ReadAll(r.Body) - }), func { tr | - tr.DialContext = func { ctx, network, address | + }), func { tr -> + tr.DialContext = func { ctx, network, address -> c := &transportDialTesterConn{ t: t, ready: make(chan error), diff --git a/src/net/http/transport_internal_test.go b/src/net/http/transport_internal_test.go index 47e0465a044ea..2401116d7a974 100644 --- a/src/net/http/transport_internal_test.go +++ b/src/net/http/transport_internal_test.go @@ -231,7 +231,7 @@ func TestTransportBodyAltRewind(t *testing.T) { DisableKeepAlives: true, TLSNextProto: map[string]func(string, *tls.Conn) RoundTripper{ "foo": func(authority string, c *tls.Conn) RoundTripper { - return roundTripFunc(func { r | + return roundTripFunc(func { r -> n, _ := io.Copy(io.Discard, r.Body) if n == 0 { t.Error("body length is zero") diff --git a/src/net/http/transport_test.go b/src/net/http/transport_test.go index 58ae515e574a2..564976832b719 100644 --- a/src/net/http/transport_test.go +++ b/src/net/http/transport_test.go @@ -51,7 +51,7 @@ import ( // and then verify that the final 2 responses get errors back. // hostPortHandler writes back the client's "host:port". -var hostPortHandler = HandlerFunc(func { w, r | +var hostPortHandler = HandlerFunc(func { w, r -> if r.FormValue("close") == "true" { w.Header().Set("Connection", "close") } @@ -139,7 +139,7 @@ func (tcs *testConnSet) check(t *testing.T) { func TestReuseRequest(t *testing.T) { run(t, testReuseRequest) } func testReuseRequest(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.Write([]byte("{}")) })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Write([]byte("{}")) })).ts c := ts.Client() req, _ := NewRequest("GET", ts.URL, nil) @@ -353,7 +353,7 @@ func testTransportRespectRequestWantsClose(t *testing.T, mode testMode) { for _, tc := range tests { t.Run(fmt.Sprintf("DisableKeepAlive=%v,RequestClose=%v", tc.disableKeepAlives, tc.close), - func { t | + func { t -> ts := newClientServerTest(t, mode, hostPortHandler).ts c := ts.Client() @@ -428,7 +428,7 @@ func testTransportReadToEndReusesConn(t *testing.T, mode testMode) { const msg = "foobar" var addrSeen map[string]int - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> addrSeen[r.RemoteAddr]++ if r.URL.Path == "/chunked/" { w.WriteHeader(200) @@ -479,7 +479,7 @@ func testTransportMaxPerHostIdleConns(t *testing.T, mode testMode) { resch := make(chan string) gotReq := make(chan bool) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> gotReq <- true var msg string select { @@ -563,7 +563,7 @@ func TestTransportMaxConnsPerHostIncludeDialInProgress(t *testing.T) { run(t, testTransportMaxConnsPerHostIncludeDialInProgress) } func testTransportMaxConnsPerHostIncludeDialInProgress(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> _, err := w.Write([]byte("foo")) if err != nil { t.Fatalf("Write: %v", err) @@ -573,7 +573,7 @@ func testTransportMaxConnsPerHostIncludeDialInProgress(t *testing.T, mode testMo tr := c.Transport.(*Transport) dialStarted := make(chan struct{}) stallDial := make(chan struct{}) - tr.Dial = func { network, addr | + tr.Dial = func { network, addr -> dialStarted <- struct{}{} <-stallDial return net.Dial(network, addr) @@ -633,7 +633,7 @@ func TestTransportMaxConnsPerHost(t *testing.T) { func testTransportMaxConnsPerHost(t *testing.T, mode testMode) { CondSkipHTTP2(t) - h := HandlerFunc(func { w, r | + h := HandlerFunc(func { w, r -> _, err := w.Write([]byte("foo")) if err != nil { t.Fatalf("Write: %v", err) @@ -648,7 +648,7 @@ func testTransportMaxConnsPerHost(t *testing.T, mode testMode) { mu := sync.Mutex{} var conns []net.Conn var dialCnt, gotConnCnt, tlsHandshakeCnt int32 - tr.Dial = func { network, addr | + tr.Dial = func { network, addr -> atomic.AddInt32(&dialCnt, 1) c, err := net.Dial(network, addr) mu.Lock() @@ -738,7 +738,7 @@ func TestTransportMaxConnsPerHostDialCancellation(t *testing.T) { func testTransportMaxConnsPerHostDialCancellation(t *testing.T, mode testMode) { CondSkipHTTP2(t) - h := HandlerFunc(func { w, r | + h := HandlerFunc(func { w, r -> _, err := w.Write([]byte("foo")) if err != nil { t.Fatalf("Write: %v", err) @@ -782,7 +782,7 @@ func TestTransportRemovesDeadIdleConnections(t *testing.T) { run(t, testTransportRemovesDeadIdleConnections, []testMode{http1Mode}) } func testTransportRemovesDeadIdleConnections(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | io.WriteString(w, r.RemoteAddr) })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> io.WriteString(w, r.RemoteAddr) })).ts c := ts.Client() tr := c.Transport.(*Transport) @@ -811,7 +811,7 @@ func testTransportRemovesDeadIdleConnections(t *testing.T, mode testMode) { ts.CloseClientConnections() var keys2 []string - waitCondition(t, 10*time.Millisecond, func { d | + waitCondition(t, 10*time.Millisecond, func { d -> keys2 = tr.IdleConnKeysForTesting() if len(keys2) != 0 { if d > 0 { @@ -891,7 +891,7 @@ func testStressSurpriseServerCloses(t *testing.T, mode testMode) { if testing.Short() { t.Skip("skipping test in short mode") } - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Length", "5") w.Header().Set("Content-Type", "text/plain") w.Write([]byte("Hello")) @@ -940,7 +940,7 @@ func testStressSurpriseServerCloses(t *testing.T, mode testMode) { // with no bodies properly func TestTransportHeadResponses(t *testing.T) { run(t, testTransportHeadResponses) } func testTransportHeadResponses(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.Method != "HEAD" { panic("expected HEAD; got " + r.Method) } @@ -975,7 +975,7 @@ func TestTransportHeadChunkedResponse(t *testing.T) { run(t, testTransportHeadChunkedResponse, []testMode{http1Mode}, testNotParallel) } func testTransportHeadChunkedResponse(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.Method != "HEAD" { panic("expected HEAD; got " + r.Method) } @@ -1026,7 +1026,7 @@ var roundTripTests = []struct { func TestRoundTripGzip(t *testing.T) { run(t, testRoundTripGzip) } func testRoundTripGzip(t *testing.T, mode testMode) { const responseBody = "test response body" - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> accept := req.Header.Get("Accept-Encoding") if expect := req.FormValue("expect_accept"); accept != expect { t.Errorf("in handler, test %v: Accept-Encoding = %q, want %q", @@ -1092,7 +1092,7 @@ func testTransportGzip(t *testing.T, mode testMode) { } const testString = "The test string aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" const nRandBytes = 1024 * 1024 - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> if req.Method == "HEAD" { if g := req.Header.Get("Accept-Encoding"); g != "" { t.Errorf("HEAD request sent with Accept-Encoding of %q; want none", g) @@ -1397,9 +1397,9 @@ func testSOCKS5Proxy(t *testing.T, mode testMode) { sentinelHeader := "X-Sentinel" sentinelValue := "12345" - h := HandlerFunc(func { w, r | w.Header().Set(sentinelHeader, sentinelValue) }) + h := HandlerFunc(func { w, r -> w.Header().Set(sentinelHeader, sentinelValue) }) for _, useTLS := range []bool{false, true} { - t.Run(fmt.Sprintf("useTLS=%v", useTLS), func { t | + t.Run(fmt.Sprintf("useTLS=%v", useTLS), func { t -> ts := newClientServerTest(t, mode, h).ts go proxy(t) c := ts.Client() @@ -1436,11 +1436,11 @@ func TestTransportProxy(t *testing.T) { for _, testCase := range testCases { siteMode := testCase.siteMode proxyMode := testCase.proxyMode - t.Run(fmt.Sprintf("site=%v/proxy=%v", siteMode, proxyMode), func { t | + t.Run(fmt.Sprintf("site=%v/proxy=%v", siteMode, proxyMode), func { t -> siteCh := make(chan *Request, 1) - h1 := HandlerFunc(func { w, r | siteCh <- r }) + h1 := HandlerFunc(func { w, r -> siteCh <- r }) proxyCh := make(chan *Request, 1) - h2 := HandlerFunc(func { w, r | + h2 := HandlerFunc(func { w, r -> proxyCh <- r // Implement an entire CONNECT proxy if r.Method == "CONNECT" { @@ -1556,9 +1556,9 @@ func TestOnProxyConnectResponse(t *testing.T) { }, } for _, tcase := range tcases { - h1 := HandlerFunc(func { w, r | }) + h1 := HandlerFunc(func { w, r -> }) - h2 := HandlerFunc(func { w, r | + h2 := HandlerFunc(func { w, r -> // Implement an entire CONNECT proxy if r.Method == "CONNECT" { if tcase.proxyStatusCode != StatusOK { @@ -1615,7 +1615,7 @@ func TestOnProxyConnectResponse(t *testing.T) { dials atomic.Int32 closes atomic.Int32 ) - c.Transport.(*Transport).DialContext = func { ctx, network, addr | + c.Transport.(*Transport).DialContext = func { ctx, network, addr -> conn, err := net.Dial(network, addr) if err != nil { return nil, err @@ -1630,7 +1630,7 @@ func TestOnProxyConnectResponse(t *testing.T) { } c.Transport.(*Transport).Proxy = ProxyURL(pu) - c.Transport.(*Transport).OnProxyConnectResponse = func { ctx, proxyURL, connectReq, connectRes | + c.Transport.(*Transport).OnProxyConnectResponse = func { ctx, proxyURL, connectReq, connectRes -> if proxyURL.String() != pu.String() { t.Errorf("proxy url got %s, want %s", proxyURL, pu) } @@ -1665,7 +1665,7 @@ func TestOnProxyConnectResponse(t *testing.T) { // when they're slow to reply to HTTPS CONNECT responses. func TestTransportProxyHTTPSConnectLeak(t *testing.T) { cancelc := make(chan struct{}) - SetTestHookProxyConnectTimeout(t, func { ctx, timeout | + SetTestHookProxyConnectTimeout(t, func { ctx, timeout -> ctx, cancel := context.WithCancel(ctx) go func() { select { @@ -1822,7 +1822,7 @@ func testTransportProxyDialDoesNotMutateProxyConnectHeader(t *testing.T, mode te // Content-Encoding is removed. func TestTransportGzipRecursive(t *testing.T) { run(t, testTransportGzipRecursive) } func testTransportGzipRecursive(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Encoding", "gzip") w.Write(rgz) })).ts @@ -1849,7 +1849,7 @@ func testTransportGzipRecursive(t *testing.T, mode testMode) { // a short gzip body func TestTransportGzipShort(t *testing.T) { run(t, testTransportGzipShort) } func testTransportGzipShort(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Encoding", "gzip") w.Write([]byte{0x1f, 0x8b}) })).ts @@ -1893,7 +1893,7 @@ func testTransportPersistConnLeak(t *testing.T, mode testMode) { const numReq = 25 gotReqCh := make(chan bool, numReq) unblockCh := make(chan bool, numReq) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> gotReqCh <- true <-unblockCh w.Header().Set("Content-Length", "0") @@ -1964,7 +1964,7 @@ func testTransportPersistConnLeakShortBody(t *testing.T, mode testMode) { } // Not parallel: measures goroutines. - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> })).ts c := ts.Client() tr := c.Transport.(*Transport) @@ -2041,7 +2041,7 @@ func TestTransportPersistConnLeakNeverIdle(t *testing.T) { run(t, testTransportPersistConnLeakNeverIdle, []testMode{http1Mode}) } func testTransportPersistConnLeakNeverIdle(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> // Close every connection so that it cannot be kept alive. conn, _, err := w.(Hijacker).Hijack() if err != nil { @@ -2117,7 +2117,7 @@ func testTransportPersistConnContextLeakMaxConnsPerHost(t *testing.T, mode testM t.Skip("https://go.dev/issue/56021") } - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> runtime.Gosched() w.WriteHeader(StatusOK) })).ts @@ -2175,7 +2175,7 @@ func testTransportIdleConnCrash(t *testing.T, mode testMode) { var tr *Transport unblockCh := make(chan bool, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> <-unblockCh tr.CloseIdleConnections() })).ts @@ -2203,7 +2203,7 @@ func testTransportIdleConnCrash(t *testing.T, mode testMode) { func TestIssue3644(t *testing.T) { run(t, testIssue3644) } func testIssue3644(t *testing.T, mode testMode) { const numFoos = 5000 - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Connection", "close") for i := 0; i < numFoos; i++ { w.Write([]byte("foo ")) @@ -2240,12 +2240,12 @@ func testIssue3595(t *testing.T, mode testMode) { 500 * time.Millisecond, time.Second, 5 * time.Second, - }, func { t, timeout | + }, func { t, timeout -> SetRSTAvoidanceDelay(t, timeout) t.Logf("set RST avoidance delay to %v", timeout) const deniedMsg = "sorry, denied." - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | Error(w, deniedMsg, StatusUnauthorized) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> Error(w, deniedMsg, StatusUnauthorized) })) // We need to close cst explicitly here so that in-flight server // requests don't race with the call to SetRSTAvoidanceDelay for a retry. defer cst.close() @@ -2274,7 +2274,7 @@ func testIssue3595(t *testing.T, mode testMode) { // "client fails to handle requests with no body and chunked encoding" func TestChunkedNoContent(t *testing.T) { run(t, testChunkedNoContent) } func testChunkedNoContent(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.WriteHeader(StatusNoContent) })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.WriteHeader(StatusNoContent) })).ts c := ts.Client() for _, closeBody := range []bool{true, false} { @@ -2302,7 +2302,7 @@ func testTransportConcurrency(t *testing.T, mode testMode) { maxProcs, numReqs = 4, 50 } defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(maxProcs)) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | fmt.Fprintf(w, "%v", r.FormValue("echo")) })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> fmt.Fprintf(w, "%v", r.FormValue("echo")) })).ts var wg sync.WaitGroup wg.Add(numReqs) @@ -2356,12 +2356,12 @@ func testTransportConcurrency(t *testing.T, mode testMode) { func TestIssue4191_InfiniteGetTimeout(t *testing.T) { run(t, testIssue4191_InfiniteGetTimeout) } func testIssue4191_InfiniteGetTimeout(t *testing.T, mode testMode) { mux := NewServeMux() - mux.HandleFunc("/get", func { w, r | io.Copy(w, neverEnding('a')) }) + mux.HandleFunc("/get", func { w, r -> io.Copy(w, neverEnding('a')) }) ts := newClientServerTest(t, mode, mux).ts connc := make(chan net.Conn, 1) c := ts.Client() - c.Transport.(*Transport).Dial = func { n, addr | + c.Transport.(*Transport).Dial = func { n, addr -> conn, err := net.Dial(n, addr) if err != nil { return nil, err @@ -2393,8 +2393,8 @@ func TestIssue4191_InfiniteGetToPutTimeout(t *testing.T) { func testIssue4191_InfiniteGetToPutTimeout(t *testing.T, mode testMode) { const debug = false mux := NewServeMux() - mux.HandleFunc("/get", func { w, r | io.Copy(w, neverEnding('a')) }) - mux.HandleFunc("/put", func { w, r | + mux.HandleFunc("/get", func { w, r -> io.Copy(w, neverEnding('a')) }) + mux.HandleFunc("/put", func { w, r -> defer r.Body.Close() io.Copy(io.Discard, r.Body) }) @@ -2402,7 +2402,7 @@ func testIssue4191_InfiniteGetToPutTimeout(t *testing.T, mode testMode) { timeout := 100 * time.Millisecond c := ts.Client() - c.Transport.(*Transport).Dial = func { n, addr | + c.Transport.(*Transport).Dial = func { n, addr -> conn, err := net.Dial(n, addr) if err != nil { return nil, err @@ -2463,11 +2463,11 @@ func testTransportResponseHeaderTimeout(t *testing.T, mode testMode) { var srvWG sync.WaitGroup inHandler := make(chan bool, 1) mux := NewServeMux() - mux.HandleFunc("/fast", func { w, r | + mux.HandleFunc("/fast", func { w, r -> inHandler <- true srvWG.Done() }) - mux.HandleFunc("/slow", func { w, r | + mux.HandleFunc("/slow", func { w, r -> inHandler <- true <-r.Context().Done() srvWG.Done() @@ -2544,7 +2544,7 @@ type cancelTest struct { // runCancelTestTransport uses Transport.CancelRequest. func runCancelTestTransport(t *testing.T, mode testMode, f func(t *testing.T, test cancelTest)) { - t.Run("TransportCancel", func { t | + t.Run("TransportCancel", func { t -> f(t, cancelTest{ mode: mode, newReq: func(req *Request) *Request { @@ -2605,12 +2605,12 @@ func runCancelTestContext(t *testing.T, mode testMode, f func(t *testing.T, test } func runCancelTest(t *testing.T, f func(t *testing.T, test cancelTest), opts ...any) { - run(t, func { t, mode | + run(t, func { t, mode -> if mode == http1Mode { - t.Run("TransportCancel", func { t | runCancelTestTransport(t, mode, f) }) + t.Run("TransportCancel", func { t -> runCancelTestTransport(t, mode, f) }) } - t.Run("RequestCancel", func { t | runCancelTestChannel(t, mode, f) }) - t.Run("ContextCancel", func { t | runCancelTestContext(t, mode, f) }) + t.Run("RequestCancel", func { t -> runCancelTestChannel(t, mode, f) }) + t.Run("ContextCancel", func { t -> runCancelTestContext(t, mode, f) }) }, opts...) } @@ -2624,7 +2624,7 @@ func testTransportCancelRequest(t *testing.T, test cancelTest) { const msg = "Hello" unblockc := make(chan bool) - ts := newClientServerTest(t, test.mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, test.mode, HandlerFunc(func { w, r -> io.WriteString(w, msg) w.(Flusher).Flush() // send headers and some body <-unblockc @@ -2656,7 +2656,7 @@ func testTransportCancelRequest(t *testing.T, test cancelTest) { // Verify no outstanding requests after readLoop/writeLoop // goroutines shut down. - waitCondition(t, 10*time.Millisecond, func { d | + waitCondition(t, 10*time.Millisecond, func { d -> n := tr.NumPendingRequestsForTesting() if n > 0 { if d > 0 { @@ -2673,7 +2673,7 @@ func testTransportCancelRequestInDo(t *testing.T, test cancelTest, body io.Reade t.Skip("skipping test in -short mode") } unblockc := make(chan bool) - ts := newClientServerTest(t, test.mode, HandlerFunc(func { w, r | <-unblockc })).ts + ts := newClientServerTest(t, test.mode, HandlerFunc(func { w, r -> <-unblockc })).ts defer close(unblockc) c := ts.Client() @@ -2688,7 +2688,7 @@ func testTransportCancelRequestInDo(t *testing.T, test cancelTest, body io.Reade }() unblockc <- true - waitCondition(t, 10*time.Millisecond, func { d | + waitCondition(t, 10*time.Millisecond, func { d -> test.cancel(tr, req) select { case <-donec: @@ -2703,11 +2703,11 @@ func testTransportCancelRequestInDo(t *testing.T, test cancelTest, body io.Reade } func TestTransportCancelRequestInDo(t *testing.T) { - runCancelTest(t, func { t, test | testTransportCancelRequestInDo(t, test, nil) }) + runCancelTest(t, func { t, test -> testTransportCancelRequestInDo(t, test, nil) }) } func TestTransportCancelRequestWithBodyInDo(t *testing.T) { - runCancelTest(t, func { t, test | testTransportCancelRequestInDo(t, test, bytes.NewBuffer([]byte{0})) }) + runCancelTest(t, func { t, test -> testTransportCancelRequestInDo(t, test, bytes.NewBuffer([]byte{0})) }) } func TestTransportCancelRequestInDial(t *testing.T) { @@ -2784,7 +2784,7 @@ func testTransportCancelRequestWithBody(t *testing.T, test cancelTest) { const msg = "Hello" unblockc := make(chan struct{}) - ts := newClientServerTest(t, test.mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, test.mode, HandlerFunc(func { w, r -> io.WriteString(w, msg) w.(Flusher).Flush() // send headers and some body <-unblockc @@ -2817,7 +2817,7 @@ func testTransportCancelRequestWithBody(t *testing.T, test cancelTest) { // Verify no outstanding requests after readLoop/writeLoop // goroutines shut down. - waitCondition(t, 10*time.Millisecond, func { d | + waitCondition(t, 10*time.Millisecond, func { d -> n := tr.NumPendingRequestsForTesting() if n > 0 { if d > 0 { @@ -2831,14 +2831,14 @@ func testTransportCancelRequestWithBody(t *testing.T, test cancelTest) { func TestTransportCancelRequestBeforeDo(t *testing.T) { // We can't cancel a request that hasn't started using Transport.CancelRequest. - run(t, func { t, mode | - t.Run("RequestCancel", func { t | runCancelTestChannel(t, mode, testTransportCancelRequestBeforeDo) }) - t.Run("ContextCancel", func { t | runCancelTestContext(t, mode, testTransportCancelRequestBeforeDo) }) + run(t, func { t, mode -> + t.Run("RequestCancel", func { t -> runCancelTestChannel(t, mode, testTransportCancelRequestBeforeDo) }) + t.Run("ContextCancel", func { t -> runCancelTestContext(t, mode, testTransportCancelRequestBeforeDo) }) }) } func testTransportCancelRequestBeforeDo(t *testing.T, test cancelTest) { unblockc := make(chan bool) - cst := newClientServerTest(t, test.mode, HandlerFunc(func { w, r | <-unblockc })) + cst := newClientServerTest(t, test.mode, HandlerFunc(func { w, r -> <-unblockc })) defer close(unblockc) c := cst.ts.Client() @@ -2901,7 +2901,7 @@ func TestTransportCloseResponseBody(t *testing.T) { run(t, testTransportCloseRes func testTransportCloseResponseBody(t *testing.T, mode testMode) { writeErr := make(chan error, 1) msg := []byte("young\n") - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> for { _, err := w.Write(msg) if err != nil { @@ -3007,18 +3007,18 @@ func TestTransportSocketLateBinding(t *testing.T) { run(t, testTransportSocketLa func testTransportSocketLateBinding(t *testing.T, mode testMode) { mux := NewServeMux() fooGate := make(chan bool, 1) - mux.HandleFunc("/foo", func { w, r | + mux.HandleFunc("/foo", func { w, r -> w.Header().Set("foo-ipport", r.RemoteAddr) w.(Flusher).Flush() <-fooGate }) - mux.HandleFunc("/bar", func { w, r | w.Header().Set("bar-ipport", r.RemoteAddr) }) + mux.HandleFunc("/bar", func { w, r -> w.Header().Set("bar-ipport", r.RemoteAddr) }) ts := newClientServerTest(t, mode, mux).ts dialGate := make(chan bool, 1) dialing := make(chan bool) c := ts.Client() - c.Transport.(*Transport).Dial = func { n, addr | + c.Transport.(*Transport).Dial = func { n, addr -> for { select { case ok := <-dialGate: @@ -3188,7 +3188,7 @@ func TestTransportIgnore1xxResponses(t *testing.T) { run(t, testTransportIgnore1xxResponses, []testMode{http1Mode}) } func testTransportIgnore1xxResponses(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> conn, buf, _ := w.(Hijacker).Hijack() buf.Write([]byte("HTTP/1.1 123 OneTwoThree\r\nFoo: bar\r\n\r\nHTTP/1.1 200 OK\r\nBar: baz\r\nContent-Length: 5\r\n\r\nHello")) buf.Flush() @@ -3222,7 +3222,7 @@ func TestTransportLimits1xxResponses(t *testing.T) { run(t, testTransportLimits1xxResponses, []testMode{http1Mode}) } func testTransportLimits1xxResponses(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> conn, buf, _ := w.(Hijacker).Hijack() for i := 0; i < 10; i++ { buf.Write([]byte("HTTP/1.1 123 OneTwoThree\r\n\r\n")) @@ -3250,7 +3250,7 @@ func TestTransportTreat101Terminal(t *testing.T) { run(t, testTransportTreat101Terminal, []testMode{http1Mode}) } func testTransportTreat101Terminal(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> conn, buf, _ := w.(Hijacker).Hijack() buf.Write([]byte("HTTP/1.1 101 Switching Protocols\r\n\r\n")) buf.Write([]byte("HTTP/1.1 204 No Content\r\n\r\n")) @@ -3362,7 +3362,7 @@ func TestProxyFromEnvironment(t *testing.T) { ResetProxyEnv() defer ResetProxyEnv() for _, tt := range proxyFromEnvTests { - testProxyForRequest(t, tt, func { req | + testProxyForRequest(t, tt, func { req -> os.Setenv("HTTP_PROXY", tt.env) os.Setenv("HTTPS_PROXY", tt.httpsenv) os.Setenv("NO_PROXY", tt.noenv) @@ -3377,7 +3377,7 @@ func TestProxyFromEnvironmentLowerCase(t *testing.T) { ResetProxyEnv() defer ResetProxyEnv() for _, tt := range proxyFromEnvTests { - testProxyForRequest(t, tt, func { req | + testProxyForRequest(t, tt, func { req -> os.Setenv("http_proxy", tt.env) os.Setenv("https_proxy", tt.httpsenv) os.Setenv("no_proxy", tt.noenv) @@ -3396,7 +3396,7 @@ func testIdleConnChannelLeak(t *testing.T, mode testMode) { var mu sync.Mutex var n int - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> mu.Lock() n++ mu.Unlock() @@ -3409,7 +3409,7 @@ func testIdleConnChannelLeak(t *testing.T, mode testMode) { c := ts.Client() tr := c.Transport.(*Transport) - tr.Dial = func { netw, addr | return net.Dial(netw, ts.Listener.Addr().String()) } + tr.Dial = func { netw, addr -> return net.Dial(netw, ts.Listener.Addr().String()) } // First, without keep-alives. for _, disableKeep := range []bool{true, false} { @@ -3449,7 +3449,7 @@ func TestTransportClosesRequestBody(t *testing.T) { run(t, testTransportClosesRequestBody, []testMode{http1Mode}) } func testTransportClosesRequestBody(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | io.Copy(io.Discard, r.Body) })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> io.Copy(io.Discard, r.Body) })).ts c := ts.Client() @@ -3521,7 +3521,7 @@ func TestTLSServerClosesConnection(t *testing.T) { } func testTLSServerClosesConnection(t *testing.T, mode testMode) { closedc := make(chan bool, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if strings.Contains(r.URL.Path, "/keep-alive-then-die") { conn, _, _ := w.(Hijacker).Hijack() conn.Write([]byte("HTTP/1.1 200 OK\r\nContent-Length: 3\r\n\r\nfoo")) @@ -3630,7 +3630,7 @@ func testTransportNoReuseAfterEarlyResponse(t *testing.T, mode testMode) { copying.Wait() }() - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.Method == "GET" { io.WriteString(w, "bar") return @@ -3672,7 +3672,7 @@ func testTransportNoReuseAfterEarlyResponse(t *testing.T, mode testMode) { // when a server hangs up immediately after saying it would keep-alive. func TestTransportIssue10457(t *testing.T) { run(t, testTransportIssue10457, []testMode{http1Mode}) } func testTransportIssue10457(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> // Send a response with no body, keep-alive // (implicit), and then lie and immediately close the // connection. This forces the Transport's readLoop to @@ -3794,7 +3794,7 @@ func testRetryRequestsOnError(t *testing.T, mode testMode) { } for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> var ( mu sync.Mutex logbuf strings.Builder @@ -3806,14 +3806,14 @@ func testRetryRequestsOnError(t *testing.T, mode testMode) { logbuf.WriteByte('\n') } - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> logf("Handler") w.Header().Set("X-Status", "ok") })).ts var writeNumAtomic int32 c := ts.Client() - c.Transport.(*Transport).Dial = func { network, addr | + c.Transport.(*Transport).Dial = func { network, addr -> logf("Dial") c, err := net.Dial(network, ts.Listener.Addr().String()) if err != nil { @@ -3882,7 +3882,7 @@ Handler func TestTransportClosesBodyOnError(t *testing.T) { run(t, testTransportClosesBodyOnError) } func testTransportClosesBodyOnError(t *testing.T, mode testMode) { readBody := make(chan error, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> _, err := io.ReadAll(r.Body) readBody <- err })).ts @@ -3926,13 +3926,13 @@ func testTransportDialTLS(t *testing.T, mode testMode) { var mu sync.Mutex // guards following var gotReq, didDial bool - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> mu.Lock() gotReq = true mu.Unlock() })).ts c := ts.Client() - c.Transport.(*Transport).DialTLS = func { netw, addr | + c.Transport.(*Transport).DialTLS = func { netw, addr -> mu.Lock() didDial = true mu.Unlock() @@ -3967,13 +3967,13 @@ func testTransportDialContext(t *testing.T, mode testMode) { gotCtxValue any ) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> mu.Lock() gotReq = true mu.Unlock() })).ts c := ts.Client() - c.Transport.(*Transport).DialContext = func { ctx, netw, addr | + c.Transport.(*Transport).DialContext = func { ctx, netw, addr -> mu.Lock() gotCtxValue = ctx.Value(ctxKey) mu.Unlock() @@ -4011,13 +4011,13 @@ func testTransportDialTLSContext(t *testing.T, mode testMode) { gotCtxValue any ) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> mu.Lock() gotReq = true mu.Unlock() })).ts c := ts.Client() - c.Transport.(*Transport).DialTLSContext = func { ctx, netw, addr | + c.Transport.(*Transport).DialTLSContext = func { ctx, netw, addr -> mu.Lock() gotCtxValue = ctx.Value(ctxKey) mu.Unlock() @@ -4152,7 +4152,7 @@ func testTransportRemovesH2ConnsAfterIdle(t *testing.T, mode testMode) { tr.MaxIdleConnsPerHost = 1 tr.IdleConnTimeout = timeout } - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | }), trFunc) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> }), trFunc) retry = false tooShort := func(err error) bool { @@ -4192,7 +4192,7 @@ func testTransportRemovesH2ConnsAfterIdle(t *testing.T, mode testMode) { // golang.org/issue/8923 func TestTransportRangeAndGzip(t *testing.T) { run(t, testTransportRangeAndGzip) } func testTransportRangeAndGzip(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { t.Error("Transport advertised gzip support in the Accept header") } @@ -4214,7 +4214,7 @@ func testTransportRangeAndGzip(t *testing.T, mode testMode) { // Test for issue 10474 func TestTransportResponseCancelRace(t *testing.T) { run(t, testTransportResponseCancelRace) } func testTransportResponseCancelRace(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> // important that this response has a body. var b [1024]byte w.Write(b[:]) @@ -4255,9 +4255,9 @@ func TestTransportContentEncodingCaseInsensitive(t *testing.T) { func testTransportContentEncodingCaseInsensitive(t *testing.T, mode testMode) { for _, ce := range []string{"gzip", "GZIP"} { ce := ce - t.Run(ce, func { t | + t.Run(ce, func { t -> const encodedString = "Hello Gopher" - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Encoding", ce) gz := gzip.NewWriter(w) gz.Write([]byte(encodedString)) @@ -4287,9 +4287,9 @@ func TestConnClosedBeforeRequestIsWritten(t *testing.T) { run(t, testConnClosedBeforeRequestIsWritten, testNotParallel, []testMode{http1Mode}) } func testConnClosedBeforeRequestIsWritten(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | }), - func { tr | - tr.DialContext = func { _, network, addr | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> }), + func { tr -> + tr.DialContext = func { _, network, addr -> // Connection immediately returns errors. return &funcConn{ read: func([]byte) (int, error) { @@ -4417,7 +4417,7 @@ func TestTransportFlushesBodyChunks(t *testing.T) { func TestTransportFlushesRequestHeader(t *testing.T) { run(t, testTransportFlushesRequestHeader) } func testTransportFlushesRequestHeader(t *testing.T, mode testMode) { gotReq := make(chan struct{}) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | close(gotReq) })) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> close(gotReq) })) pr, pw := io.Pipe() req, err := NewRequest("POST", cst.ts.URL, pr) @@ -4474,12 +4474,12 @@ func testTransportPrefersResponseOverWriteError(t *testing.T, mode testMode) { 500 * time.Millisecond, time.Second, 5 * time.Second, - }, func { t, timeout | + }, func { t, timeout -> SetRSTAvoidanceDelay(t, timeout) t.Logf("set RST avoidance delay to %v", timeout) const contentLengthLimit = 1024 * 1024 // 1MB - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.ContentLength >= contentLengthLimit { w.WriteHeader(StatusBadRequest) r.Body.Close() @@ -4609,7 +4609,7 @@ func TestTransportReuseConnEmptyResponseBody(t *testing.T) { run(t, testTransportReuseConnEmptyResponseBody) } func testTransportReuseConnEmptyResponseBody(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | w.Header().Set("X-Addr", r.RemoteAddr) }))// Empty response body. + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("X-Addr", r.RemoteAddr) }))// Empty response body. n := 100 if testing.Short() { @@ -4715,17 +4715,17 @@ func TestNoCrashReturningTransportAltConn(t *testing.T) { } func TestTransportReuseConnection_Gzip_Chunked(t *testing.T) { - run(t, func { t, mode | testTransportReuseConnection_Gzip(t, mode, true) }) + run(t, func { t, mode -> testTransportReuseConnection_Gzip(t, mode, true) }) } func TestTransportReuseConnection_Gzip_ContentLength(t *testing.T) { - run(t, func { t, mode | testTransportReuseConnection_Gzip(t, mode, false) }) + run(t, func { t, mode -> testTransportReuseConnection_Gzip(t, mode, false) }) } // Make sure we re-use underlying TCP connection for gzipped responses too. func testTransportReuseConnection_Gzip(t *testing.T, mode testMode, chunked bool) { addr := make(chan string, 2) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> addr <- r.RemoteAddr w.Header().Set("Content-Encoding", "gzip") if chunked { @@ -4770,7 +4770,7 @@ func testTransportResponseHeaderLength(t *testing.T, mode testMode) { if mode == http2Mode { t.Skip("HTTP/2 Transport doesn't support MaxResponseHeaderBytes") } - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | if r.URL.Path == "/long" { + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.URL.Path == "/long" { w.Header().Set("Long", strings.Repeat("a", 1<<20)) } })).ts c := ts.Client() @@ -4799,18 +4799,18 @@ func testTransportResponseHeaderLength(t *testing.T, mode testMode) { } func TestTransportEventTrace(t *testing.T) { - run(t, func { t, mode | testTransportEventTrace(t, mode, false) }, testNotParallel) + run(t, func { t, mode -> testTransportEventTrace(t, mode, false) }, testNotParallel) } // test a non-nil httptrace.ClientTrace but with all hooks set to zero. func TestTransportEventTrace_NoHooks(t *testing.T) { - run(t, func { t, mode | testTransportEventTrace(t, mode, true) }, testNotParallel) + run(t, func { t, mode -> testTransportEventTrace(t, mode, true) }, testNotParallel) } func testTransportEventTrace(t *testing.T, mode testMode, noHooks bool) { const resBody = "some body" gotWroteReqEvent := make(chan struct{}, 500) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.Method == "GET" { // Do nothing for the second request. return @@ -4822,7 +4822,7 @@ func testTransportEventTrace(t *testing.T, mode testMode, noHooks bool) { <-gotWroteReqEvent } io.WriteString(w, resBody) - }), func { tr | if tr.TLSClientConfig != nil { + }), func { tr -> if tr.TLSClientConfig != nil { tr.TLSClientConfig.InsecureSkipVerify = true } }) defer cst.close() @@ -4845,7 +4845,7 @@ func testTransportEventTrace(t *testing.T, mode testMode, noHooks bool) { } // Install a fake DNS server. - ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func { ctx, network, host | + ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func { ctx, network, host -> if host != "dns-is-faked.golang" { t.Errorf("unexpected DNS host lookup for %q/%q", network, host) return nil, nil @@ -4885,7 +4885,7 @@ func testTransportEventTrace(t *testing.T, mode testMode, noHooks bool) { } if mode == http2Mode { trace.TLSHandshakeStart = func() { logf("tls handshake start") } - trace.TLSHandshakeDone = func { s, err | logf("tls handshake done. ConnectionState = %v \n err = %v", s, err) } + trace.TLSHandshakeDone = func { s, err -> logf("tls handshake done. ConnectionState = %v \n err = %v", s, err) } } if noHooks { // zero out all func pointers, trying to get some path to crash @@ -4998,8 +4998,8 @@ func testTransportEventTraceTLSVerify(t *testing.T, mode testMode) { buf.WriteByte('\n') } - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | t.Error("Unexpected request") }), func { ts | - ts.Config.ErrorLog = log.New(funcWriter(func { p | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> t.Error("Unexpected request") }), func { ts -> + ts.Config.ErrorLog = log.New(funcWriter(func { p -> logf("%s", p) return len(p), nil }), "", 0) @@ -5140,7 +5140,7 @@ func TestTLSHandshakeTrace(t *testing.T) { run(t, testTLSHandshakeTrace, []testMode{https1Mode, http2Mode}) } func testTLSHandshakeTrace(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | })).ts + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> })).ts var mu sync.Mutex var start, done bool @@ -5186,7 +5186,7 @@ func TestTransportMaxIdleConns(t *testing.T) { run(t, testTransportMaxIdleConns, []testMode{http1Mode}) } func testTransportMaxIdleConns(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> // No body for convenience. })).ts c := ts.Client() @@ -5197,7 +5197,7 @@ func testTransportMaxIdleConns(t *testing.T, mode testMode) { if err != nil { t.Fatal(err) } - ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func { ctx, _, host | return []net.IPAddr{{IP: net.ParseIP(ip)}}, nil }) + ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func { ctx, _, host -> return []net.IPAddr{{IP: net.ParseIP(ip)}}, nil }) hitHost := func(n int) { req, _ := NewRequest("GET", fmt.Sprintf("http://host-%d.dns-is-faked.golang:"+port, n), nil) @@ -5243,7 +5243,7 @@ func testTransportIdleConnTimeout(t *testing.T, mode testMode) { timeout := 1 * time.Millisecond timeoutLoop: for { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> // No body for convenience. })) tr := cst.tr @@ -5304,7 +5304,7 @@ timeoutLoop: time.Sleep(timeout / 2) } - waitCondition(t, timeout/2, func { d | + waitCondition(t, timeout/2, func { d -> if got := idleConns(); len(got) != 0 { if d >= timeout*3/2 { t.Logf("after %v, idle conns = %q", d, got) @@ -5330,7 +5330,7 @@ timeoutLoop: // idle pool. Then we give it a of time to explode. func TestIdleConnH2Crash(t *testing.T) { run(t, testIdleConnH2Crash, []testMode{http2Mode}) } func testIdleConnH2Crash(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> // nothing })) @@ -5342,7 +5342,7 @@ func testIdleConnH2Crash(t *testing.T, mode testMode) { defer close(testDone) cst.tr.IdleConnTimeout = 5 * time.Millisecond - cst.tr.DialTLS = func { network, addr | + cst.tr.DialTLS = func { network, addr -> c, err := tls.Dial(network, addr, &tls.Config{ InsecureSkipVerify: true, NextProtos: []string{"h2"}, @@ -5425,7 +5425,7 @@ func testTransportIDNA(t *testing.T, mode testMode) { const punyDomain = "xn--c1ae0ajs.xn--c1aw" var port string - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> want := punyDomain + ":" + port if r.Host != want { t.Errorf("Host header = %q; want %q", r.Host, want) @@ -5438,7 +5438,7 @@ func testTransportIDNA(t *testing.T, mode testMode) { } } w.Header().Set("Hit-Handler", "1") - }), func { tr | if tr.TLSClientConfig != nil { + }), func { tr -> if tr.TLSClientConfig != nil { tr.TLSClientConfig.InsecureSkipVerify = true } }) @@ -5448,7 +5448,7 @@ func testTransportIDNA(t *testing.T, mode testMode) { } // Install a fake DNS server. - ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func { ctx, network, host | + ctx := context.WithValue(context.Background(), nettrace.LookupIPAltResolverKey{}, func { ctx, network, host -> if host != punyDomain { t.Errorf("got DNS host lookup for %q/%q; want %q", network, host, punyDomain) return nil, nil @@ -5492,7 +5492,7 @@ func TestTransportProxyConnectHeader(t *testing.T) { } func testTransportProxyConnectHeader(t *testing.T, mode testMode) { reqc := make(chan *Request, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.Method != "CONNECT" { t.Errorf("method = %q; want CONNECT", r.Method) } @@ -5506,7 +5506,7 @@ func testTransportProxyConnectHeader(t *testing.T, mode testMode) { })).ts c := ts.Client() - c.Transport.(*Transport).Proxy = func { r | return url.Parse(ts.URL) } + c.Transport.(*Transport).Proxy = func { r -> return url.Parse(ts.URL) } c.Transport.(*Transport).ProxyConnectHeader = Header{ "User-Agent": {"foo"}, "Other": {"bar"}, @@ -5532,7 +5532,7 @@ func TestTransportProxyGetConnectHeader(t *testing.T) { } func testTransportProxyGetConnectHeader(t *testing.T, mode testMode) { reqc := make(chan *Request, 1) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.Method != "CONNECT" { t.Errorf("method = %q; want CONNECT", r.Method) } @@ -5546,13 +5546,13 @@ func testTransportProxyGetConnectHeader(t *testing.T, mode testMode) { })).ts c := ts.Client() - c.Transport.(*Transport).Proxy = func { r | return url.Parse(ts.URL) } + c.Transport.(*Transport).Proxy = func { r -> return url.Parse(ts.URL) } // These should be ignored: c.Transport.(*Transport).ProxyConnectHeader = Header{ "User-Agent": {"foo"}, "Other": {"bar"}, } - c.Transport.(*Transport).GetProxyConnectHeader = func { ctx, proxyURL, target | return Header{ + c.Transport.(*Transport).GetProxyConnectHeader = func { ctx, proxyURL, target -> return Header{ "User-Agent": {"foo2"}, "Other": {"bar2"}, }, nil } @@ -5726,7 +5726,7 @@ func TestNoBodyOnChunked304Response(t *testing.T) { run(t, testNoBodyOnChunked304Response, []testMode{http1Mode}) } func testNoBodyOnChunked304Response(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> conn, buf, _ := w.(Hijacker).Hijack() buf.Write([]byte("HTTP/1.1 304 NOT MODIFIED\r\nTransfer-Encoding: chunked\r\n\r\n0\r\n\r\n")) buf.Flush() @@ -5792,7 +5792,7 @@ func testClientTimeoutKillsConn_BeforeHeaders(t *testing.T, mode testMode) { inHandler := make(chan bool) cancelHandler := make(chan struct{}) handlerDone := make(chan bool) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> <-r.Context().Done() select { @@ -5854,7 +5854,7 @@ func testClientTimeoutKillsConn_AfterHeaders(t *testing.T, mode testMode) { inHandler := make(chan bool) cancelHandler := make(chan struct{}) handlerDone := make(chan bool) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Length", "100") w.(Flusher).Flush() @@ -5919,7 +5919,7 @@ func TestTransportResponseBodyWritableOnProtocolSwitch(t *testing.T) { func testTransportResponseBodyWritableOnProtocolSwitch(t *testing.T, mode testMode) { done := make(chan struct{}) defer close(done) - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> conn, _, err := w.(Hijacker).Hijack() if err != nil { t.Error(err) @@ -5967,7 +5967,7 @@ func testTransportResponseBodyWritableOnProtocolSwitch(t *testing.T, mode testMo func TestTransportCONNECTBidi(t *testing.T) { run(t, testTransportCONNECTBidi, []testMode{http1Mode}) } func testTransportCONNECTBidi(t *testing.T, mode testMode) { const target = "backend:443" - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if r.Method != "CONNECT" { t.Errorf("unexpected method %q", r.Method) w.WriteHeader(500) @@ -6072,7 +6072,7 @@ func TestTransportRequestReplayable(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> got := tt.req.ExportIsReplayable() if got != tt.want { t.Errorf("replyable = %v; want %v", got, tt.want) @@ -6159,7 +6159,7 @@ func testTransportRequestWriteRoundTrip(t *testing.T, mode testMode) { } for _, tc := range cases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> r, cleanup, err := tc.readerFunc() if err != nil { t.Fatal(err) @@ -6168,7 +6168,7 @@ func testTransportRequestWriteRoundTrip(t *testing.T, mode testMode) { tConn := &testMockTCPConn{} trFunc := func(tr *Transport) { - tr.DialContext = func { ctx, network, addr | + tr.DialContext = func { ctx, network, addr -> var d net.Dialer conn, err := d.DialContext(ctx, network, addr) if err != nil { @@ -6188,7 +6188,7 @@ func testTransportRequestWriteRoundTrip(t *testing.T, mode testMode) { cst := newClientServerTest( t, mode, - HandlerFunc(func { w, r | + HandlerFunc(func { w, r -> io.Copy(io.Discard, r.Body) r.Body.Close() w.WriteHeader(200) @@ -6314,7 +6314,7 @@ func testTransportIgnores408(t *testing.T, mode testMode) { const target = "backend:443" - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> nc, _, err := w.(Hijacker).Hijack() if err != nil { t.Error(err) @@ -6343,7 +6343,7 @@ func testTransportIgnores408(t *testing.T, mode testMode) { t.Fatalf("got %q; want ok", slurp) } - waitCondition(t, 1*time.Millisecond, func { d | + waitCondition(t, 1*time.Millisecond, func { d -> if n := cst.tr.IdleConnKeyCountForTesting(); n != 0 { if d > 0 { t.Logf("%v idle conns still present after %v", n, d) @@ -6361,7 +6361,7 @@ func TestInvalidHeaderResponse(t *testing.T) { run(t, testInvalidHeaderResponse, []testMode{http1Mode}) } func testInvalidHeaderResponse(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> conn, buf, _ := w.(Hijacker).Hijack() buf.Write([]byte("HTTP/1.1 200 OK\r\n" + "Date: Wed, 30 Aug 2017 19:09:27 GMT\r\n" + @@ -6400,7 +6400,7 @@ func TestTransportClosesBodyOnInvalidRequests(t *testing.T) { run(t, testTransportClosesBodyOnInvalidRequests) } func testTransportClosesBodyOnInvalidRequests(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | t.Errorf("Should not have been invoked") })).ts + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> t.Errorf("Should not have been invoked") })).ts u, _ := url.Parse(cst.URL) @@ -6461,7 +6461,7 @@ func testTransportClosesBodyOnInvalidRequests(t *testing.T, mode testMode) { } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> var bc bodyCloser req := tt.req req.Body = &bc @@ -6505,14 +6505,14 @@ func TestDontCacheBrokenHTTP2Conn(t *testing.T) { run(t, testDontCacheBrokenHTTP2Conn, []testMode{http2Mode}) } func testDontCacheBrokenHTTP2Conn(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | }), optQuietLog) + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> }), optQuietLog) var brokenState brokenState const numReqs = 5 var numDials, gotConns uint32 // atomic - cst.tr.Dial = func { netw, addr | + cst.tr.Dial = func { netw, addr -> atomic.AddUint32(&numDials, 1) c, err := net.Dial(netw, addr) if err != nil { @@ -6572,7 +6572,7 @@ func TestTransportDecrementConnWhenIdleConnRemoved(t *testing.T) { func testTransportDecrementConnWhenIdleConnRemoved(t *testing.T, mode testMode) { CondSkipHTTP2(t) - h := HandlerFunc(func { w, r | + h := HandlerFunc(func { w, r -> _, err := w.Write([]byte("foo")) if err != nil { t.Fatalf("Write: %v", err) @@ -6650,11 +6650,11 @@ func (f roundTripFunc) RoundTrip(r *Request) (*Response, error) { return f(r) } // Issue 32441: body is not reset after ErrSkipAltProtocol func TestIssue32441(t *testing.T) { run(t, testIssue32441, []testMode{http1Mode}) } func testIssue32441(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { w, r | if n, _ := io.Copy(io.Discard, r.Body); n == 0 { + ts := newClientServerTest(t, mode, HandlerFunc(func { w, r -> if n, _ := io.Copy(io.Discard, r.Body); n == 0 { t.Error("body length is zero") } })).ts c := ts.Client() - c.Transport.(*Transport).RegisterProtocol("http", roundTripFunc(func { r | + c.Transport.(*Transport).RegisterProtocol("http", roundTripFunc(func { r -> // Draining body to trigger failure condition on actual request to server. if n, _ := io.Copy(io.Discard, r.Body); n == 0 { t.Error("body length is zero during round trip") @@ -6672,7 +6672,7 @@ func TestTransportRejectsSignInContentLength(t *testing.T) { run(t, testTransportRejectsSignInContentLength, []testMode{http1Mode}) } func testTransportRejectsSignInContentLength(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { w, r | + cst := newClientServerTest(t, mode, HandlerFunc(func { w, r -> w.Header().Set("Content-Length", "+3") w.Write([]byte("abc")) })).ts @@ -6793,7 +6793,7 @@ func TestCancelRequestWhenSharingConnection(t *testing.T) { } func testCancelRequestWhenSharingConnection(t *testing.T, mode testMode) { reqc := make(chan chan struct{}, 2) - ts := newClientServerTest(t, mode, HandlerFunc(func { w, req | + ts := newClientServerTest(t, mode, HandlerFunc(func { w, req -> ch := make(chan struct{}, 1) reqc <- ch <-ch @@ -6876,7 +6876,7 @@ func testCancelRequestWhenSharingConnection(t *testing.T, mode testMode) { func TestHandlerAbortRacesBodyRead(t *testing.T) { run(t, testHandlerAbortRacesBodyRead) } func testHandlerAbortRacesBodyRead(t *testing.T, mode testMode) { - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> go io.Copy(io.Discard, req.Body) panic(ErrAbortHandler) })).ts @@ -6906,7 +6906,7 @@ func testRequestSanitization(t *testing.T, mode testMode) { // Remove this after updating x/net. t.Skip("https://go.dev/issue/60374 test fails when run with HTTP/2") } - ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req | if h, ok := req.Header["X-Evil"]; ok { + ts := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> if h, ok := req.Header["X-Evil"]; ok { t.Errorf("request has X-Evil header: %q", h) } })).ts req, _ := NewRequest("GET", ts.URL, nil) @@ -6924,7 +6924,7 @@ func TestProxyAuthHeader(t *testing.T) { func testProxyAuthHeader(t *testing.T, mode testMode) { const username = "u" const password = "@/?!" - cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req | + cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> // Copy the Proxy-Authorization header to a new Request, // since Request.BasicAuth only parses the Authorization header. var r2 Request @@ -7000,7 +7000,7 @@ func TestTransportReqCancelerCleanupOnRequestBodyWriteError(t *testing.T) { // Verify no outstanding requests after readLoop/writeLoop // goroutines shut down. - waitCondition(t, 10*time.Millisecond, func { d | + waitCondition(t, 10*time.Millisecond, func { d -> n := tr.NumPendingRequestsForTesting() if n > 0 { if d > 0 { @@ -7017,7 +7017,7 @@ func TestValidateClientRequestTrailers(t *testing.T) { } func testValidateClientRequestTrailers(t *testing.T, mode testMode) { - cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req | rw.Write([]byte("Hello")) })).ts + cst := newClientServerTest(t, mode, HandlerFunc(func { rw, req -> rw.Write([]byte("Hello")) })).ts cases := []struct { trailer Header @@ -7029,7 +7029,7 @@ func testValidateClientRequestTrailers(t *testing.T, mode testMode) { for i, tt := range cases { testName := fmt.Sprintf("%s%d", mode, i) - t.Run(testName, func { t | + t.Run(testName, func { t -> req, err := NewRequest("GET", cst.URL, nil) if err != nil { t.Fatal(err) diff --git a/src/net/http/triv.go b/src/net/http/triv.go index 10410e4b76fab..0f1cd7c53d998 100644 --- a/src/net/http/triv.go +++ b/src/net/http/triv.go @@ -68,7 +68,7 @@ var booleanflag = flag.Bool("boolean", true, "another flag for testing") func FlagServer(w http.ResponseWriter, req *http.Request) { w.Header().Set("Content-Type", "text/plain; charset=utf-8") fmt.Fprint(w, "Flags:\n") - flag.VisitAll(func { f | + flag.VisitAll(func { f -> if f.Value.String() != f.DefValue { fmt.Fprintf(w, "%s = %s [default = %s]\n", f.Name, f.Value.String(), f.DefValue) } else { diff --git a/src/net/ip_test.go b/src/net/ip_test.go index 05c326f326f4b..9654cf29d5537 100644 --- a/src/net/ip_test.go +++ b/src/net/ip_test.go @@ -274,9 +274,9 @@ var sink string func BenchmarkIPString(b *testing.B) { testHookUninstaller.Do(uninstallTestHooks) - b.Run("IPv4", func { b | benchmarkIPString(b, IPv4len) }) + b.Run("IPv4", func { b -> benchmarkIPString(b, IPv4len) }) - b.Run("IPv6", func { b | benchmarkIPString(b, IPv6len) }) + b.Run("IPv6", func { b -> benchmarkIPString(b, IPv6len) }) } func benchmarkIPString(b *testing.B, size int) { @@ -752,8 +752,8 @@ func TestIPAddrScope(t *testing.T) { } func BenchmarkIPEqual(b *testing.B) { - b.Run("IPv4", func { b | benchmarkIPEqual(b, IPv4len) }) - b.Run("IPv6", func { b | benchmarkIPEqual(b, IPv6len) }) + b.Run("IPv4", func { b -> benchmarkIPEqual(b, IPv4len) }) + b.Run("IPv6", func { b -> benchmarkIPEqual(b, IPv6len) }) } func benchmarkIPEqual(b *testing.B, size int) { diff --git a/src/net/iprawsock_posix.go b/src/net/iprawsock_posix.go index 6fab5dea82682..9b718f33aef5a 100644 --- a/src/net/iprawsock_posix.go +++ b/src/net/iprawsock_posix.go @@ -124,7 +124,7 @@ func (sd *sysDialer) dialIP(ctx context.Context, laddr, raddr *IPAddr) (*IPConn, } ctrlCtxFn := sd.Dialer.ControlContext if ctrlCtxFn == nil && sd.Dialer.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sd.Dialer.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sd.Dialer.Control(network, address, c) } } fd, err := internetSocket(ctx, network, laddr, raddr, syscall.SOCK_RAW, proto, "dial", ctrlCtxFn) if err != nil { @@ -145,7 +145,7 @@ func (sl *sysListener) listenIP(ctx context.Context, laddr *IPAddr) (*IPConn, er } var ctrlCtxFn func(ctx context.Context, network, address string, c syscall.RawConn) error if sl.ListenConfig.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sl.ListenConfig.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sl.ListenConfig.Control(network, address, c) } } fd, err := internetSocket(ctx, network, laddr, nil, syscall.SOCK_RAW, proto, "listen", ctrlCtxFn) if err != nil { diff --git a/src/net/ipsock_test.go b/src/net/ipsock_test.go index e4361983cded2..0cff727026365 100644 --- a/src/net/ipsock_test.go +++ b/src/net/ipsock_test.go @@ -267,7 +267,7 @@ func TestAddrListPartition(t *testing.T) { for i, tt := range cases { // Inverting the function's output should not affect the outcome. for _, invert := range []bool{false, true} { - primaries, fallbacks := addrs.partition(func { a | + primaries, fallbacks := addrs.partition(func { a -> ip := a.(*IPAddr).IP return (ip[len(ip)-1] == tt.lastByte) != invert }) diff --git a/src/net/listen_test.go b/src/net/listen_test.go index 263c9f1fa3b5f..d6f961df29b8d 100644 --- a/src/net/listen_test.go +++ b/src/net/listen_test.go @@ -729,7 +729,7 @@ func TestListenConfigControl(t *testing.T) { t.Skipf("not supported on %s", runtime.GOOS) } - t.Run("StreamListen", func { t | + t.Run("StreamListen", func { t -> for _, network := range []string{"tcp", "tcp4", "tcp6", "unix", "unixpacket"} { if !testableNetwork(network) { continue @@ -738,7 +738,7 @@ func TestListenConfigControl(t *testing.T) { ln.Close() } }) - t.Run("PacketListen", func { t | + t.Run("PacketListen", func { t -> for _, network := range []string{"udp", "udp4", "udp6", "unixgram"} { if !testableNetwork(network) { continue diff --git a/src/net/lookup_test.go b/src/net/lookup_test.go index 5d9802f1323c5..f5fa698c2281e 100644 --- a/src/net/lookup_test.go +++ b/src/net/lookup_test.go @@ -903,7 +903,7 @@ func TestLookupContextCancel(t *testing.T) { testHookLookupIP = func { ctx, fn, network, - host | + host -> select { case <-unblockLookup: default: @@ -1172,7 +1172,7 @@ func TestLookupIPAddrConcurrentCallsForNetworks(t *testing.T) { } calls := int32(0) waitCh := make(chan struct{}) - testHookLookupIP = func { ctx, fn, network, host | + testHookLookupIP = func { ctx, fn, network, host -> // We'll block until this is called one time for each different // expected result. This will ensure that the lookup group would wait // for the existing call if it was to be reused. @@ -1267,7 +1267,7 @@ func TestResolverLookupIP(t *testing.T) { {"go", forceGoDNS}, {"cgo", forceCgoDNS}, } { - t.Run("implementation: "+impl.name, func { t | + t.Run("implementation: "+impl.name, func { t -> fixup := impl.fn() if fixup == nil { t.Skip("not supported") @@ -1275,7 +1275,7 @@ func TestResolverLookupIP(t *testing.T) { defer fixup() for _, network := range []string{"ip", "ip4", "ip6"} { - t.Run("network: "+network, func { t | + t.Run("network: "+network, func { t -> switch { case network == "ip4" && !v4Ok: t.Skip("IPv4 is not supported") @@ -1462,7 +1462,7 @@ func testLookupNoData(t *testing.T, prefix string) { } func TestLookupPortNotFound(t *testing.T) { - allResolvers(t, func { t | + allResolvers(t, func { t -> _, err := LookupPort("udp", "_-unknown-service-") var dnsErr *DNSError if !errors.As(err, &dnsErr) || !dnsErr.IsNotFound { @@ -1482,7 +1482,7 @@ var tcpOnlyService = func() string { }() func TestLookupPortDifferentNetwork(t *testing.T) { - allResolvers(t, func { t | + allResolvers(t, func { t -> _, err := LookupPort("udp", tcpOnlyService) var dnsErr *DNSError if !errors.As(err, &dnsErr) || !dnsErr.IsNotFound { @@ -1492,7 +1492,7 @@ func TestLookupPortDifferentNetwork(t *testing.T) { } func TestLookupPortEmptyNetworkString(t *testing.T) { - allResolvers(t, func { t | + allResolvers(t, func { t -> _, err := LookupPort("", tcpOnlyService) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -1501,7 +1501,7 @@ func TestLookupPortEmptyNetworkString(t *testing.T) { } func TestLookupPortIPNetworkString(t *testing.T) { - allResolvers(t, func { t | + allResolvers(t, func { t -> _, err := LookupPort("ip", tcpOnlyService) if err != nil { t.Fatalf("unexpected error: %v", err) @@ -1592,8 +1592,8 @@ func TestLookupNoSuchHost(t *testing.T) { } for _, v := range tests { - t.Run(v.name, func { t | - allResolvers(t, func { t | + t.Run(v.name, func { t -> + allResolvers(t, func { t -> attempts := 0 for { err := v.query() diff --git a/src/net/lookup_windows_test.go b/src/net/lookup_windows_test.go index 527bcb55c4f9b..c608e578eb769 100644 --- a/src/net/lookup_windows_test.go +++ b/src/net/lookup_windows_test.go @@ -39,7 +39,7 @@ func testLookup(t *testing.T, fn func(*testing.T, *Resolver, string)) { } else { name = "go/" } - t.Run(name+server, func { t | + t.Run(name+server, func { t -> t.Parallel() r := DefaultResolver if !def { @@ -54,7 +54,7 @@ func testLookup(t *testing.T, fn func(*testing.T, *Resolver, string)) { func TestNSLookupMX(t *testing.T) { testenv.MustHaveExternalNetwork(t) - testLookup(t, func { t, r, server | + testLookup(t, func { t, r, server -> mx, err := r.LookupMX(context.Background(), server) if err != nil { t.Fatal(err) @@ -83,7 +83,7 @@ func TestNSLookupMX(t *testing.T) { func TestNSLookupCNAME(t *testing.T) { testenv.MustHaveExternalNetwork(t) - testLookup(t, func { t, r, server | + testLookup(t, func { t, r, server -> cname, err := r.LookupCNAME(context.Background(), server) if err != nil { t.Fatalf("failed %s: %s", server, err) @@ -104,7 +104,7 @@ func TestNSLookupCNAME(t *testing.T) { func TestNSLookupNS(t *testing.T) { testenv.MustHaveExternalNetwork(t) - testLookup(t, func { t, r, server | + testLookup(t, func { t, r, server -> ns, err := r.LookupNS(context.Background(), server) if err != nil { t.Fatalf("failed %s: %s", server, err) @@ -130,7 +130,7 @@ func TestNSLookupNS(t *testing.T) { func TestNSLookupTXT(t *testing.T) { testenv.MustHaveExternalNetwork(t) - testLookup(t, func { t, r, server | + testLookup(t, func { t, r, server -> txt, err := r.LookupTXT(context.Background(), server) if err != nil { t.Fatalf("failed %s: %s", server, err) diff --git a/src/net/mail/message.go b/src/net/mail/message.go index e0c9411a48248..4feb03648dc72 100644 --- a/src/net/mail/message.go +++ b/src/net/mail/message.go @@ -769,7 +769,7 @@ func (p *addrParser) consumeDisplayNameComment() (string, error) { } // TODO(stapelberg): parse quoted-string within comment - words := strings.FieldsFunc(comment, func { r | return r == ' ' || r == '\t' }) + words := strings.FieldsFunc(comment, func { r -> return r == ' ' || r == '\t' }) for idx, word := range words { decoded, isEncoded, err := p.decodeRFC2047Word(word) if err != nil { @@ -867,7 +867,7 @@ func (p *addrParser) decodeRFC2047Word(s string) (word string, isEncoded bool, e // one in rfc2047Decoder. adec := *dec charsetReaderError := false - adec.CharsetReader = func { charset, input | + adec.CharsetReader = func { charset, input -> if dec.CharsetReader == nil { charsetReaderError = true return nil, charsetError(charset) diff --git a/src/net/mail/message_test.go b/src/net/mail/message_test.go index 673df5af566df..1deb558c80762 100644 --- a/src/net/mail/message_test.go +++ b/src/net/mail/message_test.go @@ -403,7 +403,7 @@ func TestAddressParsingError(t *testing.T) { } } - t.Run("CustomWordDecoder", func { t | + t.Run("CustomWordDecoder", func { t -> p := &AddressParser{WordDecoder: &mime.WordDecoder{}} for i, tc := range mustErrTestCases { _, err := p.Parse(tc.text) diff --git a/src/net/main_conf_test.go b/src/net/main_conf_test.go index 8926953da2283..2c0dc6880639c 100644 --- a/src/net/main_conf_test.go +++ b/src/net/main_conf_test.go @@ -12,14 +12,14 @@ import ( func allResolvers(t *testing.T, f func(t *testing.T)) { t.Run("default resolver", f) - t.Run("forced go resolver", func { t | + t.Run("forced go resolver", func { t -> // On plan9 the forceGoDNS might not force the go resolver, currently // it is only forced when the Resolver.Dial field is populated. // See conf.go mustUseGoResolver. defer forceGoDNS()() f(t) }) - t.Run("forced cgo resolver", func { t | + t.Run("forced cgo resolver", func { t -> defer forceCgoDNS()() f(t) }) diff --git a/src/net/main_posix_test.go b/src/net/main_posix_test.go index ae6e9c6ce33cb..0fb45c3be76cd 100644 --- a/src/net/main_posix_test.go +++ b/src/net/main_posix_test.go @@ -18,7 +18,7 @@ func enableSocketConnect() { func disableSocketConnect(network string) { net, _, _ := strings.Cut(network, ":") - sw.Set(socktest.FilterConnect, func { so | + sw.Set(socktest.FilterConnect, func { so -> switch net { case "tcp4": if so.Cookie.Family() == syscall.AF_INET && so.Cookie.Type() == syscall.SOCK_STREAM { diff --git a/src/net/net_fake.go b/src/net/net_fake.go index 253b13dedf24d..2cd13c6d9698d 100644 --- a/src/net/net_fake.go +++ b/src/net/net_fake.go @@ -1021,7 +1021,7 @@ func (ffd *fakeNetFD) readFrom(p []byte) (n int, sa syscall.Sockaddr, err error) } func (ffd *fakeNetFD) readFromInet4(p []byte, sa *syscall.SockaddrInet4) (n int, err error) { - n, _, err = ffd.queue.recvfrom(ffd.readDeadline.Load(), p, true, func { from | + n, _, err = ffd.queue.recvfrom(ffd.readDeadline.Load(), p, true, func { from -> fromSA, err := from.sockaddr(syscall.AF_INET) if err != nil { return err @@ -1036,7 +1036,7 @@ func (ffd *fakeNetFD) readFromInet4(p []byte, sa *syscall.SockaddrInet4) (n int, } func (ffd *fakeNetFD) readFromInet6(p []byte, sa *syscall.SockaddrInet6) (n int, err error) { - n, _, err = ffd.queue.recvfrom(ffd.readDeadline.Load(), p, true, func { from | + n, _, err = ffd.queue.recvfrom(ffd.readDeadline.Load(), p, true, func { from -> fromSA, err := from.sockaddr(syscall.AF_INET6) if err != nil { return err diff --git a/src/net/net_test.go b/src/net/net_test.go index ff37ad3bd1d06..a2910ee580881 100644 --- a/src/net/net_test.go +++ b/src/net/net_test.go @@ -24,7 +24,7 @@ func TestCloseRead(t *testing.T) { for _, network := range []string{"tcp", "unix", "unixpacket"} { network := network - t.Run(network, func { t | + t.Run(network, func { t -> if !testableNetwork(network) { t.Skipf("network %s is not testable on the current platform", network) } @@ -83,7 +83,7 @@ func TestCloseWrite(t *testing.T) { for _, network := range []string{"tcp", "unix", "unixpacket"} { network := network - t.Run(network, func { t | + t.Run(network, func { t -> if !testableNetwork(network) { t.Skipf("network %s is not testable on the current platform", network) } @@ -185,7 +185,7 @@ func TestConnClose(t *testing.T) { t.Parallel() for _, network := range []string{"tcp", "unix", "unixpacket"} { network := network - t.Run(network, func { t | + t.Run(network, func { t -> if !testableNetwork(network) { t.Skipf("network %s is not testable on the current platform", network) } @@ -227,7 +227,7 @@ func TestListenerClose(t *testing.T) { t.Parallel() for _, network := range []string{"tcp", "unix", "unixpacket"} { network := network - t.Run(network, func { t | + t.Run(network, func { t -> if !testableNetwork(network) { t.Skipf("network %s is not testable on the current platform", network) } @@ -265,7 +265,7 @@ func TestPacketConnClose(t *testing.T) { t.Parallel() for _, network := range []string{"udp", "unixgram"} { network := network - t.Run(network, func { t | + t.Run(network, func { t -> if !testableNetwork(network) { t.Skipf("network %s is not testable on the current platform", network) } @@ -307,7 +307,7 @@ func TestAcceptIgnoreAbortedConnRequest(t *testing.T) { syserr <- err } }() - sw.Set(socktest.FilterAccept, func { so | + sw.Set(socktest.FilterAccept, func { so -> if err, ok := <-syserr; ok { return nil, err } @@ -349,7 +349,7 @@ func TestZeroByteRead(t *testing.T) { t.Parallel() for _, network := range []string{"tcp", "unix", "unixpacket"} { network := network - t.Run(network, func { t | + t.Run(network, func { t -> if !testableNetwork(network) { t.Skipf("network %s is not testable on the current platform", network) } diff --git a/src/net/netip/fuzz_test.go b/src/net/netip/fuzz_test.go index 11f2431b0ea31..a8ca2b564dffa 100644 --- a/src/net/netip/fuzz_test.go +++ b/src/net/netip/fuzz_test.go @@ -129,7 +129,7 @@ func FuzzParse(f *testing.F) { f.Add(seed) } - f.Fuzz(func { t, s | + f.Fuzz(func { t, s -> ip, _ := ParseAddr(s) checkStringParseRoundTrip(t, ip, ParseAddr) checkEncoding(t, ip) diff --git a/src/net/netip/inlining_test.go b/src/net/netip/inlining_test.go index 68e06316c281c..45ca7beda07df 100644 --- a/src/net/netip/inlining_test.go +++ b/src/net/netip/inlining_test.go @@ -25,7 +25,7 @@ func TestInlining(t *testing.T) { t.Fatalf("go build: %v, %s", err, out) } got := map[string]bool{} - regexp.MustCompile(` can inline (\S+)`).ReplaceAllFunc(out, func { match | + regexp.MustCompile(` can inline (\S+)`).ReplaceAllFunc(out, func { match -> got[strings.TrimPrefix(string(match), " can inline ")] = true return nil }) diff --git a/src/net/netip/netip_pkg_test.go b/src/net/netip/netip_pkg_test.go index 4bf7df8fc41d9..322eba67c3860 100644 --- a/src/net/netip/netip_pkg_test.go +++ b/src/net/netip/netip_pkg_test.go @@ -216,7 +216,7 @@ func TestParseIPError(t *testing.T) { }, } for _, test := range tests { - t.Run(test.ip, func { t | + t.Run(test.ip, func { t -> _, err := ParseAddr(test.ip) if err == nil { t.Fatal("no error") @@ -249,7 +249,7 @@ func TestParseAddrPort(t *testing.T) { {in: ":0", wantErr: true}, // if we need to parse this form, there should be a separate function that explicitly allows it } for _, test := range tests { - t.Run(test.in, func { t | + t.Run(test.in, func { t -> got, err := ParseAddrPort(test.in) if err != nil { if test.wantErr { @@ -265,7 +265,7 @@ func TestParseAddrPort(t *testing.T) { } }) - t.Run(test.in+"/AppendTo", func { t | + t.Run(test.in+"/AppendTo", func { t -> got, err := ParseAddrPort(test.in) if err == nil { testAppendToMarshal(t, got) @@ -275,7 +275,7 @@ func TestParseAddrPort(t *testing.T) { // TextMarshal and TextUnmarshal mostly behave like // ParseAddrPort and String. Divergent behavior are handled in // TestAddrPortMarshalUnmarshal. - t.Run(test.in+"/Marshal", func { t | + t.Run(test.in+"/Marshal", func { t -> var got AddrPort jsin := `"` + test.in + `"` err := json.Unmarshal([]byte(jsin), &got) @@ -308,7 +308,7 @@ func TestAddrPortMarshalUnmarshal(t *testing.T) { } for _, test := range tests { - t.Run(test.in, func { t | + t.Run(test.in, func { t -> orig := `"` + test.in + `"` var ipp AddrPort diff --git a/src/net/netip/netip_test.go b/src/net/netip/netip_test.go index 53f34f7b33690..3df2274c3c9ed 100644 --- a/src/net/netip/netip_test.go +++ b/src/net/netip/netip_test.go @@ -135,7 +135,7 @@ func TestParseAddr(t *testing.T) { } for _, test := range validIPs { - t.Run(test.in, func { t | + t.Run(test.in, func { t -> got, err := ParseAddr(test.in) if err != nil { if err.Error() == test.wantErr { @@ -280,7 +280,7 @@ func TestParseAddr(t *testing.T) { } for _, s := range invalidIPs { - t.Run(s, func { t | + t.Run(s, func { t -> got, err := ParseAddr(s) if err == nil { t.Errorf("ParseAddr(%q) = %#v, want error", s, got) @@ -567,7 +567,7 @@ func TestAddrFrom16(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> got := AddrFrom16(tt.in) if got != tt.want { t.Errorf("got %#v; want %#v", got, tt.want) @@ -780,7 +780,7 @@ func TestIPProperties(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> gu := tt.ip.IsGlobalUnicast() if gu != tt.globalUnicast { t.Errorf("IsGlobalUnicast(%v) = %v; want %v", tt.ip, gu, tt.globalUnicast) @@ -858,7 +858,7 @@ func TestAddrWellKnown(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> want := tt.std.String() got := tt.ip.String() @@ -1085,7 +1085,7 @@ func TestIPStringExpanded(t *testing.T) { } for _, tt := range tests { - t.Run(tt.ip.String(), func { t | + t.Run(tt.ip.String(), func { t -> want := tt.s got := tt.ip.StringExpanded() @@ -1199,9 +1199,9 @@ func TestPrefixMasking(t *testing.T) { } for _, tt := range tests { - t.Run(tt.family, func { t | + t.Run(tt.family, func { t -> for _, st := range tt.subtests { - t.Run(st.p.String(), func { t | + t.Run(st.p.String(), func { t -> // Ensure st.ip is not mutated. orig := st.ip.String() @@ -1241,7 +1241,7 @@ func TestPrefixMarshalUnmarshal(t *testing.T) { } for _, s := range tests { - t.Run(s, func { t | + t.Run(s, func { t -> // Ensure that JSON (and by extension, text) marshaling is // sane by entering quoted input. orig := `"` + s + `"` @@ -1351,7 +1351,7 @@ func TestPrefixMasked(t *testing.T) { }, } for _, test := range tests { - t.Run(test.prefix.String(), func { t | + t.Run(test.prefix.String(), func { t -> got := test.prefix.Masked() if got != test.masked { t.Errorf("Masked=%s, want %s", got, test.masked) @@ -1420,7 +1420,7 @@ func TestPrefix(t *testing.T) { }, } for _, test := range tests { - t.Run(test.prefix, func { t | + t.Run(test.prefix, func { t -> prefix, err := ParsePrefix(test.prefix) if err != nil { t.Fatal(err) @@ -1493,7 +1493,7 @@ func TestParsePrefixAllocs(t *testing.T) { } for _, test := range tests { prefix := test.ip + test.slash - t.Run(prefix, func { t | + t.Run(prefix, func { t -> ipAllocs := int(testing.AllocsPerRun(5, func() { ParseAddr(test.ip) })) @@ -1563,7 +1563,7 @@ func TestParsePrefixError(t *testing.T) { }, } for _, test := range tests { - t.Run(test.prefix, func { t | + t.Run(test.prefix, func { t -> _, err := ParsePrefix(test.prefix) if err == nil { t.Fatal("no error") @@ -1615,7 +1615,7 @@ func BenchmarkBinaryMarshalRoundTrip(b *testing.B) { {"ipv6+zone", "2001:db8::1%eth0"}, } for _, tc := range tests { - b.Run(tc.name, func { b | + b.Run(tc.name, func { b -> ip := mustIP(tc.ip) for i := 0; i < b.N; i++ { bt, err := ip.MarshalBinary() @@ -1740,7 +1740,7 @@ var parseBenchInputs = []struct { func BenchmarkParseAddr(b *testing.B) { sinkInternValue = unique.Make(MakeAddrDetail(true, "eth1")) // Pin to not benchmark the intern package for _, test := range parseBenchInputs { - b.Run(test.name, func { b | + b.Run(test.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sinkIP, _ = ParseAddr(test.ip) @@ -1751,7 +1751,7 @@ func BenchmarkParseAddr(b *testing.B) { func BenchmarkStdParseIP(b *testing.B) { for _, test := range parseBenchInputs { - b.Run(test.name, func { b | + b.Run(test.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sinkStdIP = net.ParseIP(test.ip) @@ -1763,7 +1763,7 @@ func BenchmarkStdParseIP(b *testing.B) { func BenchmarkAddrString(b *testing.B) { for _, test := range parseBenchInputs { ip := MustParseAddr(test.ip) - b.Run(test.name, func { b | + b.Run(test.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sinkString = ip.String() @@ -1775,7 +1775,7 @@ func BenchmarkAddrString(b *testing.B) { func BenchmarkIPStringExpanded(b *testing.B) { for _, test := range parseBenchInputs { ip := MustParseAddr(test.ip) - b.Run(test.name, func { b | + b.Run(test.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sinkString = ip.StringExpanded() @@ -1787,7 +1787,7 @@ func BenchmarkIPStringExpanded(b *testing.B) { func BenchmarkAddrMarshalText(b *testing.B) { for _, test := range parseBenchInputs { ip := MustParseAddr(test.ip) - b.Run(test.name, func { b | + b.Run(test.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sinkBytes, _ = ip.MarshalText() @@ -1800,7 +1800,7 @@ func BenchmarkAddrPortString(b *testing.B) { for _, test := range parseBenchInputs { ip := MustParseAddr(test.ip) ipp := AddrPortFrom(ip, 60000) - b.Run(test.name, func { b | + b.Run(test.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sinkString = ipp.String() @@ -1813,7 +1813,7 @@ func BenchmarkAddrPortMarshalText(b *testing.B) { for _, test := range parseBenchInputs { ip := MustParseAddr(test.ip) ipp := AddrPortFrom(ip, 60000) - b.Run(test.name, func { b | + b.Run(test.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sinkBytes, _ = ipp.MarshalText() @@ -1876,7 +1876,7 @@ func BenchmarkPrefixMasking(b *testing.B) { } for _, tt := range tests { - b.Run(tt.name, func { b | + b.Run(tt.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -1902,7 +1902,7 @@ func BenchmarkParseAddrPort(b *testing.B) { } else { ipp = fmt.Sprintf("%s:1234", test.ip) } - b.Run(test.name, func { b | + b.Run(test.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -2054,7 +2054,7 @@ func TestNoAllocs(t *testing.T) { return ipp } test := func(name string, f func()) { - t.Run(name, func { t | + t.Run(name, func { t -> n := testing.AllocsPerRun(1000, f) if n != 0 { t.Fatalf("allocs = %d; want 0", int(n)) @@ -2147,7 +2147,7 @@ func TestAddrStringAllocs(t *testing.T) { } optimizationOff := testenv.OptimizationOff() for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> if optimizationOff && strings.HasPrefix(tc.name, "ipv4-in-ipv6") { // Optimizations are required to remove some allocs. t.Skipf("skipping on %v", testenv.Builder()) diff --git a/src/net/nss.go b/src/net/nss.go index cc5663706fc37..165876d52e32d 100644 --- a/src/net/nss.go +++ b/src/net/nss.go @@ -220,7 +220,7 @@ func parseNSSConf(f *file) *nssConf { // parses "foo=bar !foo=bar" func parseCriteria(x string) (c []nssCriterion, err error) { - err = foreachField(x, func { f | + err = foreachField(x, func { f -> not := false if len(f) > 0 && f[0] == '!' { not = true diff --git a/src/net/rawconn_test.go b/src/net/rawconn_test.go index d0af26300ad6b..1d4f458516d7c 100644 --- a/src/net/rawconn_test.go +++ b/src/net/rawconn_test.go @@ -17,7 +17,7 @@ func TestRawConnReadWrite(t *testing.T) { t.Skipf("not supported on %s", runtime.GOOS) } - t.Run("TCP", func { t | + t.Run("TCP", func { t -> handler := func(ls *localServer, ln Listener) { c, err := ln.Accept() if err != nil { @@ -91,7 +91,7 @@ func TestRawConnReadWrite(t *testing.T) { t.Fatalf("got %q; want %q", b[:n], data) } }) - t.Run("Deadline", func { t | + t.Run("Deadline", func { t -> switch runtime.GOOS { case "windows": t.Skipf("not supported on %s", runtime.GOOS) @@ -171,7 +171,7 @@ func TestRawConnControl(t *testing.T) { t.Skipf("not supported on %s", runtime.GOOS) } - t.Run("TCP", func { t | + t.Run("TCP", func { t -> ln := newLocalListener(t, "tcp") defer ln.Close() diff --git a/src/net/rawconn_unix_test.go b/src/net/rawconn_unix_test.go index fe099bdc1857b..aca080f2275d0 100644 --- a/src/net/rawconn_unix_test.go +++ b/src/net/rawconn_unix_test.go @@ -14,7 +14,7 @@ import ( func readRawConn(c syscall.RawConn, b []byte) (int, error) { var operr error var n int - err := c.Read(func { s | + err := c.Read(func { s -> n, operr = syscall.Read(int(s), b) if operr == syscall.EAGAIN { return false @@ -29,7 +29,7 @@ func readRawConn(c syscall.RawConn, b []byte) (int, error) { func writeRawConn(c syscall.RawConn, b []byte) error { var operr error - err := c.Write(func { s | + err := c.Write(func { s -> _, operr = syscall.Write(int(s), b) if operr == syscall.EAGAIN { return false @@ -91,13 +91,13 @@ func controlOnConnSetup(network string, address string, c syscall.RawConn) error case "tcp", "udp", "ip": return errors.New("ambiguous network: " + network) case "unix", "unixpacket", "unixgram": - fn = func { s | _, operr = syscall.GetsockoptInt(int(s), syscall.SOL_SOCKET, syscall.SO_ERROR) } + fn = func { s -> _, operr = syscall.GetsockoptInt(int(s), syscall.SOL_SOCKET, syscall.SO_ERROR) } default: switch network[len(network)-1] { case '4': - fn = func { s | operr = syscall.SetsockoptInt(int(s), syscall.IPPROTO_IP, syscall.IP_TTL, 1) } + fn = func { s -> operr = syscall.SetsockoptInt(int(s), syscall.IPPROTO_IP, syscall.IP_TTL, 1) } case '6': - fn = func { s | operr = syscall.SetsockoptInt(int(s), syscall.IPPROTO_IPV6, syscall.IPV6_UNICAST_HOPS, 1) } + fn = func { s -> operr = syscall.SetsockoptInt(int(s), syscall.IPPROTO_IPV6, syscall.IPV6_UNICAST_HOPS, 1) } default: return errors.New("unknown network: " + network) } diff --git a/src/net/rawconn_windows_test.go b/src/net/rawconn_windows_test.go index 5c636daa5f40d..dc359d4db02d5 100644 --- a/src/net/rawconn_windows_test.go +++ b/src/net/rawconn_windows_test.go @@ -13,7 +13,7 @@ import ( func readRawConn(c syscall.RawConn, b []byte) (int, error) { var operr error var n int - err := c.Read(func { s | + err := c.Read(func { s -> var read uint32 var flags uint32 var buf syscall.WSABuf @@ -31,7 +31,7 @@ func readRawConn(c syscall.RawConn, b []byte) (int, error) { func writeRawConn(c syscall.RawConn, b []byte) error { var operr error - err := c.Write(func { s | + err := c.Write(func { s -> var written uint32 var buf syscall.WSABuf buf.Buf = &b[0] @@ -98,9 +98,9 @@ func controlOnConnSetup(network string, address string, c syscall.RawConn) error default: switch network[len(network)-1] { case '4': - fn = func { s | operr = syscall.SetsockoptInt(syscall.Handle(s), syscall.IPPROTO_IP, syscall.IP_TTL, 1) } + fn = func { s -> operr = syscall.SetsockoptInt(syscall.Handle(s), syscall.IPPROTO_IP, syscall.IP_TTL, 1) } case '6': - fn = func { s | + fn = func { s -> operr = syscall.SetsockoptInt(syscall.Handle(s), syscall.IPPROTO_IPV6, syscall.IPV6_UNICAST_HOPS, 1) } default: diff --git a/src/net/resolverdialfunc_test.go b/src/net/resolverdialfunc_test.go index cddd70ed61be9..f528db78c5f87 100644 --- a/src/net/resolverdialfunc_test.go +++ b/src/net/resolverdialfunc_test.go @@ -54,7 +54,7 @@ func TestResolverDialFunc(t *testing.T) { ctx := context.Background() const fakeDomain = "something-that-is-a-not-a-real-domain.fake-tld." - t.Run("LookupIP", func { t | + t.Run("LookupIP", func { t -> ips, err := r.LookupIP(ctx, "ip", fakeDomain) if err != nil { t.Fatal(err) @@ -64,7 +64,7 @@ func TestResolverDialFunc(t *testing.T) { } }) - t.Run("LookupSRV", func { t | + t.Run("LookupSRV", func { t -> _, got, err := r.LookupSRV(ctx, "some-service", "tcp", fakeDomain) if err != nil { t.Fatal(err) diff --git a/src/net/rpc/debug.go b/src/net/rpc/debug.go index 500e28b3149e6..016857f678f36 100644 --- a/src/net/rpc/debug.go +++ b/src/net/rpc/debug.go @@ -73,17 +73,17 @@ type debugHTTP struct { func (server debugHTTP) ServeHTTP(w http.ResponseWriter, req *http.Request) { // Build a sorted version of the data. var services serviceArray - server.serviceMap.Range(func { snamei, svci | + server.serviceMap.Range(func { snamei, svci -> svc := svci.(*service) ds := debugService{svc, snamei.(string), make([]debugMethod, 0, len(svc.method))} for mname, method := range svc.method { ds.Method = append(ds.Method, debugMethod{method, mname}) } - slices.SortFunc(ds.Method, func { a, b | return strings.Compare(a.Name, b.Name) }) + slices.SortFunc(ds.Method, func { a, b -> return strings.Compare(a.Name, b.Name) }) services = append(services, ds) return true }) - slices.SortFunc(services, func { a, b | return strings.Compare(a.Name, b.Name) }) + slices.SortFunc(services, func { a, b -> return strings.Compare(a.Name, b.Name) }) err := debug.Execute(w, services) if err != nil { fmt.Fprintln(w, "rpc: error executing template:", err.Error()) diff --git a/src/net/rpc/server_test.go b/src/net/rpc/server_test.go index 7533d683b0ff5..dfc9c413e35f1 100644 --- a/src/net/rpc/server_test.go +++ b/src/net/rpc/server_test.go @@ -757,7 +757,7 @@ func benchmarkEndToEnd(dial func() (*Client, error), b *testing.B) { args := &Args{7, 8} b.ResetTimer() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> reply := new(Reply) for pb.Next() { err := client.Call("Arith.Add", args, reply) diff --git a/src/net/sendfile_linux.go b/src/net/sendfile_linux.go index 2c316956903e2..e5e9d948c8932 100644 --- a/src/net/sendfile_linux.go +++ b/src/net/sendfile_linux.go @@ -40,7 +40,7 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) { } var werr error - err = sc.Read(func { fd | + err = sc.Read(func { fd -> written, werr, handled = poll.SendFile(&c.pfd, int(fd), remain) return true }) diff --git a/src/net/sendfile_test.go b/src/net/sendfile_test.go index 956311772e090..9a0048352dba6 100644 --- a/src/net/sendfile_test.go +++ b/src/net/sendfile_test.go @@ -47,7 +47,7 @@ func expectSendfile(t *testing.T, wantConn Conn, f func()) { gotHandled bool gotFD *poll.FD ) - poll.TestHookDidSendFile = func { dstFD, src, written, err, handled | + poll.TestHookDidSendFile = func { dstFD, src, written, err, handled -> if called { t.Error("internal/poll.SendFile called multiple times, want one call") } @@ -520,8 +520,8 @@ func BenchmarkSendFile(b *testing.B) { b.Skipf("skipping on %s", runtime.GOOS) } - b.Run("file-to-tcp", func { b | benchmarkSendFile(b, "tcp") }) - b.Run("file-to-unix", func { b | benchmarkSendFile(b, "unix") }) + b.Run("file-to-tcp", func { b -> benchmarkSendFile(b, "tcp") }) + b.Run("file-to-unix", func { b -> benchmarkSendFile(b, "unix") }) } func benchmarkSendFile(b *testing.B, proto string) { diff --git a/src/net/sendfile_unix_alt.go b/src/net/sendfile_unix_alt.go index b2ee2de43f53e..3cda849d675e1 100644 --- a/src/net/sendfile_unix_alt.go +++ b/src/net/sendfile_unix_alt.go @@ -73,7 +73,7 @@ func sendFile(c *netFD, r io.Reader) (written int64, err error, handled bool) { } var werr error - err = sc.Read(func { fd | + err = sc.Read(func { fd -> written, werr, handled = poll.SendFile(&c.pfd, int(fd), pos, remain) return true }) diff --git a/src/net/server_test.go b/src/net/server_test.go index 9fac89ca8e2e2..b24db761e8b4a 100644 --- a/src/net/server_test.go +++ b/src/net/server_test.go @@ -55,7 +55,7 @@ func TestTCPServer(t *testing.T) { const N = 3 for i, tt := range tcpServerTests { - t.Run(tt.snet+" "+tt.saddr+"<-"+tt.taddr, func { t | + t.Run(tt.snet+" "+tt.saddr+"<-"+tt.taddr, func { t -> if !testableListenArgs(tt.snet, tt.saddr, tt.taddr) { t.Skip("not testable") } @@ -251,7 +251,7 @@ var udpServerTests = []struct { func TestUDPServer(t *testing.T) { for i, tt := range udpServerTests { i, tt := i, tt - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> if !testableListenArgs(tt.snet, tt.saddr, tt.taddr) { t.Skipf("skipping %s %s<-%s test", tt.snet, tt.saddr, tt.taddr) } @@ -341,7 +341,7 @@ func TestUnixgramServer(t *testing.T) { for i, tt := range unixgramServerTests { i, tt := i, tt - t.Run(fmt.Sprint(i), func { t | + t.Run(fmt.Sprint(i), func { t -> if !testableListenArgs("unixgram", tt.saddr, "") { t.Skipf("skipping unixgram %s<-%s test", tt.saddr, tt.caddr) } diff --git a/src/net/smtp/smtp_test.go b/src/net/smtp/smtp_test.go index 94da895e9b596..3885077ba0b11 100644 --- a/src/net/smtp/smtp_test.go +++ b/src/net/smtp/smtp_test.go @@ -301,7 +301,7 @@ func TestExtensions(t *testing.T) { return c, bcmdbuf, cmdbuf } - t.Run("helo", func { t | + t.Run("helo", func { t -> const ( basicServer = `250 mx.google.com at your service 250 Sender OK @@ -335,7 +335,7 @@ QUIT } }) - t.Run("ehlo", func { t | + t.Run("ehlo", func { t -> const ( basicServer = `250-mx.google.com at your service 250 SIZE 35651584 @@ -375,7 +375,7 @@ QUIT } }) - t.Run("ehlo 8bitmime", func { t | + t.Run("ehlo 8bitmime", func { t -> const ( basicServer = `250-mx.google.com at your service 250-SIZE 35651584 @@ -416,7 +416,7 @@ QUIT } }) - t.Run("ehlo smtputf8", func { t | + t.Run("ehlo smtputf8", func { t -> const ( basicServer = `250-mx.google.com at your service 250-SIZE 35651584 @@ -457,7 +457,7 @@ QUIT } }) - t.Run("ehlo 8bitmime smtputf8", func { t | + t.Run("ehlo 8bitmime smtputf8", func { t -> const ( basicServer = `250-mx.google.com at your service 250-SIZE 35651584 @@ -1092,7 +1092,7 @@ func serverHandleTLS(c net.Conn, t *testing.T) error { func init() { testRootCAs := x509.NewCertPool() testRootCAs.AppendCertsFromPEM(localhostCert) - testHookStartTLS = func { config | config.RootCAs = testRootCAs } + testHookStartTLS = func { config -> config.RootCAs = testRootCAs } } func sendMail(hostPort string) error { diff --git a/src/net/splice_linux_test.go b/src/net/splice_linux_test.go index 2a67f932c0f27..5f70d1dcb83ce 100644 --- a/src/net/splice_linux_test.go +++ b/src/net/splice_linux_test.go @@ -17,14 +17,14 @@ import ( ) func TestSplice(t *testing.T) { - t.Run("tcp-to-tcp", func { t | testSplice(t, "tcp", "tcp") }) + t.Run("tcp-to-tcp", func { t -> testSplice(t, "tcp", "tcp") }) if !testableNetwork("unixgram") { t.Skip("skipping unix-to-tcp tests") } - t.Run("unix-to-tcp", func { t | testSplice(t, "unix", "tcp") }) - t.Run("tcp-to-unix", func { t | testSplice(t, "tcp", "unix") }) - t.Run("tcp-to-file", func { t | testSpliceToFile(t, "tcp", "file") }) - t.Run("unix-to-file", func { t | testSpliceToFile(t, "unix", "file") }) + t.Run("unix-to-tcp", func { t -> testSplice(t, "unix", "tcp") }) + t.Run("tcp-to-unix", func { t -> testSplice(t, "tcp", "unix") }) + t.Run("tcp-to-file", func { t -> testSpliceToFile(t, "tcp", "file") }) + t.Run("unix-to-file", func { t -> testSpliceToFile(t, "unix", "file") }) t.Run("no-unixpacket", testSpliceNoUnixpacket) t.Run("no-unixgram", testSpliceNoUnixgram) } @@ -45,8 +45,8 @@ func testSplice(t *testing.T, upNet, downNet string) { t.Run("honorsLimitedReader", spliceTestCase{upNet, downNet, 4096, 1 << 20, 1 << 10}.test) t.Run("updatesLimitedReaderN", spliceTestCase{upNet, downNet, 1024, 4096, 4096 + 100}.test) t.Run("limitedReaderAtLimit", spliceTestCase{upNet, downNet, 32, 128, 128}.test) - t.Run("readerAtEOF", func { t | testSpliceReaderAtEOF(t, upNet, downNet) }) - t.Run("issue25985", func { t | testSpliceIssue25985(t, upNet, downNet) }) + t.Run("readerAtEOF", func { t -> testSpliceReaderAtEOF(t, upNet, downNet) }) + t.Run("issue25985", func { t -> testSpliceIssue25985(t, upNet, downNet) }) } type spliceTestCase struct { @@ -155,7 +155,7 @@ func verifySpliceFds(t *testing.T, c Conn, hook *spliceHook, fdType string) { default: t.Fatalf("unknown fdType %q", fdType) } - if err := rc.Control(func { fd | + if err := rc.Control(func { fd -> if hook.called && hookFd != int(fd) { t.Fatalf("wrong %s file descriptor: got %d, want %d", fdType, hook.dstfd, int(fd)) } @@ -390,9 +390,9 @@ func testSpliceNoUnixgram(t *testing.T) { func BenchmarkSplice(b *testing.B) { testHookUninstaller.Do(uninstallTestHooks) - b.Run("tcp-to-tcp", func { b | benchSplice(b, "tcp", "tcp") }) - b.Run("unix-to-tcp", func { b | benchSplice(b, "unix", "tcp") }) - b.Run("tcp-to-unix", func { b | benchSplice(b, "tcp", "unix") }) + b.Run("tcp-to-tcp", func { b -> benchSplice(b, "tcp", "tcp") }) + b.Run("unix-to-tcp", func { b -> benchSplice(b, "unix", "tcp") }) + b.Run("tcp-to-unix", func { b -> benchSplice(b, "tcp", "unix") }) } func benchSplice(b *testing.B, upNet, downNet string) { @@ -450,8 +450,8 @@ func (tc spliceTestCase) bench(b *testing.B) { } func BenchmarkSpliceFile(b *testing.B) { - b.Run("tcp-to-file", func { b | benchmarkSpliceFile(b, "tcp") }) - b.Run("unix-to-file", func { b | benchmarkSpliceFile(b, "unix") }) + b.Run("tcp-to-file", func { b -> benchmarkSpliceFile(b, "tcp") }) + b.Run("unix-to-file", func { b -> benchmarkSpliceFile(b, "unix") }) } func benchmarkSpliceFile(b *testing.B, proto string) { @@ -526,7 +526,7 @@ type spliceHook struct { func (h *spliceHook) install() { h.original = pollSplice - pollSplice = func { dst, src, remain | + pollSplice = func { dst, src, remain -> h.called = true h.dstfd = dst.Sysfd h.srcfd = src.Sysfd diff --git a/src/net/tcpconn_keepalive_test.go b/src/net/tcpconn_keepalive_test.go index a36783ccdb82a..e8090cea4c9f5 100644 --- a/src/net/tcpconn_keepalive_test.go +++ b/src/net/tcpconn_keepalive_test.go @@ -21,7 +21,7 @@ func TestTCPConnKeepAliveConfigDialer(t *testing.T) { errHook error oldCfg KeepAliveConfig ) - testPreHookSetKeepAlive = func { nfd | oldCfg, errHook = getCurrentKeepAliveSettings(fdType(nfd.pfd.Sysfd)) } + testPreHookSetKeepAlive = func { nfd -> oldCfg, errHook = getCurrentKeepAliveSettings(fdType(nfd.pfd.Sysfd)) } handler := func(ls *localServer, ln Listener) { for { @@ -59,7 +59,7 @@ func TestTCPConnKeepAliveConfigDialer(t *testing.T) { if err != nil { t.Fatal(err) } - if err := sc.Control(func { fd | verifyKeepAliveSettings(t, fdType(fd), oldCfg, cfg) }); err != nil { + if err := sc.Control(func { fd -> verifyKeepAliveSettings(t, fdType(fd), oldCfg, cfg) }); err != nil { t.Fatal(err) } } @@ -75,7 +75,7 @@ func TestTCPConnKeepAliveConfigListener(t *testing.T) { errHook error oldCfg KeepAliveConfig ) - testPreHookSetKeepAlive = func { nfd | oldCfg, errHook = getCurrentKeepAliveSettings(fdType(nfd.pfd.Sysfd)) } + testPreHookSetKeepAlive = func { nfd -> oldCfg, errHook = getCurrentKeepAliveSettings(fdType(nfd.pfd.Sysfd)) } ch := make(chan Conn, 1) handler := func(ls *localServer, ln Listener) { @@ -110,7 +110,7 @@ func TestTCPConnKeepAliveConfigListener(t *testing.T) { if err != nil { t.Fatal(err) } - if err := sc.Control(func { fd | verifyKeepAliveSettings(t, fdType(fd), oldCfg, cfg) }); err != nil { + if err := sc.Control(func { fd -> verifyKeepAliveSettings(t, fdType(fd), oldCfg, cfg) }); err != nil { t.Fatal(err) } } @@ -150,7 +150,7 @@ func TestTCPConnKeepAliveConfig(t *testing.T) { errHook error oldCfg KeepAliveConfig ) - if err := sc.Control(func { fd | oldCfg, errHook = getCurrentKeepAliveSettings(fdType(fd)) }); err != nil { + if err := sc.Control(func { fd -> oldCfg, errHook = getCurrentKeepAliveSettings(fdType(fd)) }); err != nil { t.Fatal(err) } if errHook != nil { @@ -171,7 +171,7 @@ func TestTCPConnKeepAliveConfig(t *testing.T) { } } - if err := sc.Control(func { fd | verifyKeepAliveSettings(t, fdType(fd), oldCfg, cfg) }); err != nil { + if err := sc.Control(func { fd -> verifyKeepAliveSettings(t, fdType(fd), oldCfg, cfg) }); err != nil { t.Fatal(err) } } diff --git a/src/net/tcpsock_posix.go b/src/net/tcpsock_posix.go index 43e76125b1403..56fb0bc8d25c6 100644 --- a/src/net/tcpsock_posix.go +++ b/src/net/tcpsock_posix.go @@ -78,7 +78,7 @@ func (sd *sysDialer) doDialTCP(ctx context.Context, laddr, raddr *TCPAddr) (*TCP func (sd *sysDialer) doDialTCPProto(ctx context.Context, laddr, raddr *TCPAddr, proto int) (*TCPConn, error) { ctrlCtxFn := sd.Dialer.ControlContext if ctrlCtxFn == nil && sd.Dialer.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sd.Dialer.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sd.Dialer.Control(network, address, c) } } fd, err := internetSocket(ctx, sd.network, laddr, raddr, syscall.SOCK_STREAM, proto, "dial", ctrlCtxFn) @@ -180,7 +180,7 @@ func (sl *sysListener) listenTCP(ctx context.Context, laddr *TCPAddr) (*TCPListe func (sl *sysListener) listenTCPProto(ctx context.Context, laddr *TCPAddr, proto int) (*TCPListener, error) { var ctrlCtxFn func(ctx context.Context, network, address string, c syscall.RawConn) error if sl.ListenConfig.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sl.ListenConfig.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sl.ListenConfig.Control(network, address, c) } } fd, err := internetSocket(ctx, sl.network, laddr, nil, syscall.SOCK_STREAM, proto, "listen", ctrlCtxFn) if err != nil { diff --git a/src/net/tcpsock_test.go b/src/net/tcpsock_test.go index a5481f4ade649..6874a0d288483 100644 --- a/src/net/tcpsock_test.go +++ b/src/net/tcpsock_test.go @@ -625,7 +625,7 @@ func TestTCPBig(t *testing.T) { } for _, writev := range []bool{false, true} { - t.Run(fmt.Sprintf("writev=%v", writev), func { t | + t.Run(fmt.Sprintf("writev=%v", writev), func { t -> ln := newLocalListener(t, "tcp") defer ln.Close() @@ -775,7 +775,7 @@ func TestDialTCPDefaultKeepAlive(t *testing.T) { defer ln.Close() got := time.Duration(-1) - testHookSetKeepAlive = func { cfg | got = cfg.Idle } + testHookSetKeepAlive = func { cfg -> got = cfg.Idle } defer func() { testHookSetKeepAlive = func {} }() c, err := DialTCP("tcp", nil, ln.Addr().(*TCPAddr)) diff --git a/src/net/textproto/reader_test.go b/src/net/textproto/reader_test.go index d24dbcd601a20..9747842626e3b 100644 --- a/src/net/textproto/reader_test.go +++ b/src/net/textproto/reader_test.go @@ -505,7 +505,7 @@ func BenchmarkReadMIMEHeader(b *testing.B) { {"client_headers", clientHeaders}, {"server_headers", serverHeaders}, } { - b.Run(set.name, func { b | + b.Run(set.name, func { b -> var buf bytes.Buffer br := bufio.NewReader(&buf) r := NewReader(br) diff --git a/src/net/timeout_test.go b/src/net/timeout_test.go index 4f62d10df1850..25a2f8d8a918b 100644 --- a/src/net/timeout_test.go +++ b/src/net/timeout_test.go @@ -63,7 +63,7 @@ func TestDialTimeout(t *testing.T) { }() for _, tt := range dialTimeoutTests { - t.Run(fmt.Sprintf("%v/%v", tt.initialTimeout, tt.initialDelta), func { t | + t.Run(fmt.Sprintf("%v/%v", tt.initialTimeout, tt.initialDelta), func { t -> // We don't run these subtests in parallel because we don't know how big // the kernel's accept queue is, and we don't want to accidentally saturate // it with concurrent calls. (That could cause the Dial to fail with @@ -150,7 +150,7 @@ func TestDialTimeoutMaxDuration(t *testing.T) { {1<<63 - 1, 0}, {0, 1<<63 - 1}, } { - t.Run(fmt.Sprintf("timeout=%s/delta=%s", tt.timeout, tt.delta), func { t | + t.Run(fmt.Sprintf("timeout=%s/delta=%s", tt.timeout, tt.delta), func { t -> d := Dialer{Timeout: tt.timeout} if tt.delta != 0 { d.Deadline = time.Now().Add(tt.delta) @@ -181,7 +181,7 @@ func TestAcceptTimeout(t *testing.T) { for _, timeout := range timeouts { timeout := timeout - t.Run(fmt.Sprintf("%v", timeout), func { t | + t.Run(fmt.Sprintf("%v", timeout), func { t -> t.Parallel() ln := newLocalListener(t, "tcp") @@ -634,7 +634,7 @@ func TestWriteToTimeout(t *testing.T) { } for _, timeout := range timeouts { - t.Run(fmt.Sprint(timeout), func { t | + t.Run(fmt.Sprint(timeout), func { t -> c2, err := ListenPacket(c1.LocalAddr().Network(), JoinHostPort(host, "0")) if err != nil { t.Fatal(err) diff --git a/src/net/udpsock_posix.go b/src/net/udpsock_posix.go index c1f69dd07e544..c237ab606cc9d 100644 --- a/src/net/udpsock_posix.go +++ b/src/net/udpsock_posix.go @@ -205,7 +205,7 @@ func (c *UDPConn) writeMsgAddrPort(b, oob []byte, addr netip.AddrPort) (n, oobn func (sd *sysDialer) dialUDP(ctx context.Context, laddr, raddr *UDPAddr) (*UDPConn, error) { ctrlCtxFn := sd.Dialer.ControlContext if ctrlCtxFn == nil && sd.Dialer.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sd.Dialer.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sd.Dialer.Control(network, address, c) } } fd, err := internetSocket(ctx, sd.network, laddr, raddr, syscall.SOCK_DGRAM, 0, "dial", ctrlCtxFn) if err != nil { @@ -217,7 +217,7 @@ func (sd *sysDialer) dialUDP(ctx context.Context, laddr, raddr *UDPAddr) (*UDPCo func (sl *sysListener) listenUDP(ctx context.Context, laddr *UDPAddr) (*UDPConn, error) { var ctrlCtxFn func(ctx context.Context, network, address string, c syscall.RawConn) error if sl.ListenConfig.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sl.ListenConfig.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sl.ListenConfig.Control(network, address, c) } } fd, err := internetSocket(ctx, sl.network, laddr, nil, syscall.SOCK_DGRAM, 0, "listen", ctrlCtxFn) if err != nil { @@ -229,7 +229,7 @@ func (sl *sysListener) listenUDP(ctx context.Context, laddr *UDPAddr) (*UDPConn, func (sl *sysListener) listenMulticastUDP(ctx context.Context, ifi *Interface, gaddr *UDPAddr) (*UDPConn, error) { var ctrlCtxFn func(ctx context.Context, network, address string, c syscall.RawConn) error if sl.ListenConfig.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sl.ListenConfig.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sl.ListenConfig.Control(network, address, c) } } fd, err := internetSocket(ctx, sl.network, gaddr, nil, syscall.SOCK_DGRAM, 0, "listen", ctrlCtxFn) if err != nil { diff --git a/src/net/udpsock_test.go b/src/net/udpsock_test.go index 00baa5c28ed41..ef519ac372d13 100644 --- a/src/net/udpsock_test.go +++ b/src/net/udpsock_test.go @@ -224,7 +224,7 @@ func TestUDPConnLocalName(t *testing.T) { testenv.MustHaveExternalNetwork(t) for _, tt := range udpConnLocalNameTests { - t.Run(fmt.Sprint(tt.laddr), func { t | + t.Run(fmt.Sprint(tt.laddr), func { t -> if !testableNetwork(tt.net) { t.Skipf("skipping: %s not available", tt.net) } diff --git a/src/net/unixsock_posix.go b/src/net/unixsock_posix.go index fa1d03b2289d1..c1696c06da581 100644 --- a/src/net/unixsock_posix.go +++ b/src/net/unixsock_posix.go @@ -157,7 +157,7 @@ func (c *UnixConn) writeMsg(b, oob []byte, addr *UnixAddr) (n, oobn int, err err func (sd *sysDialer) dialUnix(ctx context.Context, laddr, raddr *UnixAddr) (*UnixConn, error) { ctrlCtxFn := sd.Dialer.ControlContext if ctrlCtxFn == nil && sd.Dialer.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sd.Dialer.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sd.Dialer.Control(network, address, c) } } fd, err := unixSocket(ctx, sd.network, laddr, raddr, "dial", ctrlCtxFn) if err != nil { @@ -217,7 +217,7 @@ func (l *UnixListener) SetUnlinkOnClose(unlink bool) { func (sl *sysListener) listenUnix(ctx context.Context, laddr *UnixAddr) (*UnixListener, error) { var ctrlCtxFn func(ctx context.Context, network, address string, c syscall.RawConn) error if sl.ListenConfig.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sl.ListenConfig.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sl.ListenConfig.Control(network, address, c) } } fd, err := unixSocket(ctx, sl.network, laddr, nil, "listen", ctrlCtxFn) if err != nil { @@ -229,7 +229,7 @@ func (sl *sysListener) listenUnix(ctx context.Context, laddr *UnixAddr) (*UnixLi func (sl *sysListener) listenUnixgram(ctx context.Context, laddr *UnixAddr) (*UnixConn, error) { var ctrlCtxFn func(ctx context.Context, network, address string, c syscall.RawConn) error if sl.ListenConfig.Control != nil { - ctrlCtxFn = func { ctx, network, address, c | return sl.ListenConfig.Control(network, address, c) } + ctrlCtxFn = func { ctx, network, address, c -> return sl.ListenConfig.Control(network, address, c) } } fd, err := unixSocket(ctx, sl.network, laddr, nil, "listen", ctrlCtxFn) if err != nil { diff --git a/src/net/unixsock_test.go b/src/net/unixsock_test.go index efcd30ee75a6a..a334572d26528 100644 --- a/src/net/unixsock_test.go +++ b/src/net/unixsock_test.go @@ -389,7 +389,7 @@ func TestUnixUnlink(t *testing.T) { } // Listener should remove on close. - t.Run("Listen", func { t | + t.Run("Listen", func { t -> l := listen(t) checkExists(t, "after Listen") l.Close() @@ -397,7 +397,7 @@ func TestUnixUnlink(t *testing.T) { }) // FileListener should not. - t.Run("FileListener", func { t | + t.Run("FileListener", func { t -> l := listen(t) f, _ := l.File() l1, _ := FileListener(f) @@ -411,7 +411,7 @@ func TestUnixUnlink(t *testing.T) { }) // Only first call to l.Close should remove. - t.Run("SecondClose", func { t | + t.Run("SecondClose", func { t -> l := listen(t) checkExists(t, "after Listen") l.Close() @@ -427,7 +427,7 @@ func TestUnixUnlink(t *testing.T) { // SetUnlinkOnClose should do what it says. - t.Run("Listen/SetUnlinkOnClose(true)", func { t | + t.Run("Listen/SetUnlinkOnClose(true)", func { t -> l := listen(t) checkExists(t, "after Listen") l.SetUnlinkOnClose(true) @@ -435,7 +435,7 @@ func TestUnixUnlink(t *testing.T) { checkNotExists(t, "after Listener close") }) - t.Run("Listen/SetUnlinkOnClose(false)", func { t | + t.Run("Listen/SetUnlinkOnClose(false)", func { t -> l := listen(t) checkExists(t, "after Listen") l.SetUnlinkOnClose(false) @@ -444,7 +444,7 @@ func TestUnixUnlink(t *testing.T) { os.Remove(name) }) - t.Run("FileListener/SetUnlinkOnClose(true)", func { t | + t.Run("FileListener/SetUnlinkOnClose(true)", func { t -> l := listen(t) f, _ := l.File() l1, _ := FileListener(f) @@ -457,7 +457,7 @@ func TestUnixUnlink(t *testing.T) { l.Close() }) - t.Run("FileListener/SetUnlinkOnClose(false)", func { t | + t.Run("FileListener/SetUnlinkOnClose(false)", func { t -> l := listen(t) f, _ := l.File() l1, _ := FileListener(f) diff --git a/src/net/url/url_test.go b/src/net/url/url_test.go index 68dad7566fc73..f97d4f83403d1 100644 --- a/src/net/url/url_test.go +++ b/src/net/url/url_test.go @@ -849,7 +849,7 @@ func TestURLRedacted(t *testing.T) { for _, tt := range cases { t := t - t.Run(tt.name, func { t | if g, w := tt.url.Redacted(), tt.want; g != w { + t.Run(tt.name, func { t -> if g, w := tt.url.Redacted(), tt.want; g != w { t.Fatalf("got: %q\nwant: %q", g, w) } }) } @@ -1434,7 +1434,7 @@ var parseTests = []parseTest{ func TestParseQuery(t *testing.T) { for _, test := range parseTests { - t.Run(test.query, func { t | + t.Run(test.query, func { t -> form, err := ParseQuery(test.query) if test.ok != (err == nil) { want := "" @@ -2004,7 +2004,7 @@ var escapeBenchmarks = []struct { func BenchmarkQueryEscape(b *testing.B) { for _, tc := range escapeBenchmarks { - b.Run("", func { b | + b.Run("", func { b -> b.ReportAllocs() var g string for i := 0; i < b.N; i++ { @@ -2020,7 +2020,7 @@ func BenchmarkQueryEscape(b *testing.B) { func BenchmarkPathEscape(b *testing.B) { for _, tc := range escapeBenchmarks { - b.Run("", func { b | + b.Run("", func { b -> b.ReportAllocs() var g string for i := 0; i < b.N; i++ { @@ -2036,7 +2036,7 @@ func BenchmarkPathEscape(b *testing.B) { func BenchmarkQueryUnescape(b *testing.B) { for _, tc := range escapeBenchmarks { - b.Run("", func { b | + b.Run("", func { b -> b.ReportAllocs() var g string for i := 0; i < b.N; i++ { @@ -2052,7 +2052,7 @@ func BenchmarkQueryUnescape(b *testing.B) { func BenchmarkPathUnescape(b *testing.B) { for _, tc := range escapeBenchmarks { - b.Run("", func { b | + b.Run("", func { b -> b.ReportAllocs() var g string for i := 0; i < b.N; i++ { diff --git a/src/net/writev_test.go b/src/net/writev_test.go index 7bc25d4833935..6827f17cb5fce 100644 --- a/src/net/writev_test.go +++ b/src/net/writev_test.go @@ -91,7 +91,7 @@ func TestBuffers_consume(t *testing.T) { func TestBuffers_WriteTo(t *testing.T) { for _, name := range []string{"WriteTo", "Copy"} { for _, size := range []int{0, 10, 1023, 1024, 1025} { - t.Run(fmt.Sprintf("%s/%d", name, size), func { t | testBuffer_writeTo(t, size, name == "Copy") }) + t.Run(fmt.Sprintf("%s/%d", name, size), func { t -> testBuffer_writeTo(t, size, name == "Copy") }) } } } @@ -103,7 +103,7 @@ func testBuffer_writeTo(t *testing.T, chunks int, useCopy bool) { sync.Mutex log []int } - poll.TestHookDidWritev = func { size | + poll.TestHookDidWritev = func { size -> writeLog.Lock() writeLog.log = append(writeLog.log, size) writeLog.Unlock() @@ -113,7 +113,7 @@ func testBuffer_writeTo(t *testing.T, chunks int, useCopy bool) { want.WriteByte(byte(i)) } - withTCPConnPair(t, func { c | + withTCPConnPair(t, func { c -> buffers := make(Buffers, chunks) for i := range buffers { buffers[i] = want.Bytes()[i : i+1] @@ -135,7 +135,7 @@ func testBuffer_writeTo(t *testing.T, chunks int, useCopy bool) { return fmt.Errorf("Buffers.WriteTo returned %d; want %d", n, want.Len()) } return nil - }, func { c | + }, func { c -> all, err := io.ReadAll(c) if !bytes.Equal(all, want.Bytes()) || err != nil { return fmt.Errorf("client read %q, %v; want %q, nil", all, err, want.Bytes()) diff --git a/src/os/dir.go b/src/os/dir.go index 570939afd8740..6ad45a10aa90c 100644 --- a/src/os/dir.go +++ b/src/os/dir.go @@ -123,7 +123,7 @@ func ReadDir(name string) ([]DirEntry, error) { defer f.Close() dirs, err := f.ReadDir(-1) - slices.SortFunc(dirs, func { a, b | return bytealg.CompareString(a.Name(), b.Name()) }) + slices.SortFunc(dirs, func { a, b -> return bytealg.CompareString(a.Name(), b.Name()) }) return dirs, err } @@ -145,7 +145,7 @@ func ReadDir(name string) ([]DirEntry, error) { // // Copying stops at and returns the first error encountered. func CopyFS(dir string, fsys fs.FS) error { - return fs.WalkDir(fsys, ".", func { path, d, err | + return fs.WalkDir(fsys, ".", func { path, d, err -> if err != nil { return err } diff --git a/src/os/env_test.go b/src/os/env_test.go index d553881954c3d..765a278454b83 100644 --- a/src/os/env_test.go +++ b/src/os/env_test.go @@ -69,7 +69,7 @@ func TestExpand(t *testing.T) { var global any func BenchmarkExpand(b *testing.B) { - b.Run("noop", func { b | + b.Run("noop", func { b -> var s string b.ReportAllocs() for i := 0; i < b.N; i++ { @@ -77,7 +77,7 @@ func BenchmarkExpand(b *testing.B) { } global = s }) - b.Run("multiple", func { b | + b.Run("multiple", func { b -> var s string b.ReportAllocs() for i := 0; i < b.N; i++ { diff --git a/src/os/exec/dot_test.go b/src/os/exec/dot_test.go index 9886e69bdaa34..5fc87a65668e9 100644 --- a/src/os/exec/dot_test.go +++ b/src/os/exec/dot_test.go @@ -47,10 +47,10 @@ func TestLookPath(t *testing.T) { // Add "." to PATH so that exec.LookPath looks in the current directory on all systems. // And try to trick it with "../testdir" too. for _, errdot := range []string{"1", "0"} { - t.Run("GODEBUG=execerrdot="+errdot, func { t | + t.Run("GODEBUG=execerrdot="+errdot, func { t -> t.Setenv("GODEBUG", "execerrdot="+errdot+",execwait=2") for _, dir := range []string{".", "../testdir"} { - t.Run(pathVar+"="+dir, func { t | + t.Run(pathVar+"="+dir, func { t -> t.Setenv(pathVar, dir+string(filepath.ListSeparator)+origPath) good := dir + "/execabs-test" if found, err := LookPath(good); err != nil || !strings.HasPrefix(found, good) { @@ -118,7 +118,7 @@ func TestLookPath(t *testing.T) { // Windows configured with NoDefaultCurrentDirectoryInExePath), then this // lookup should succeed regardless of the behavior for ".", so it may be // useful to run as a control case even on those platforms. - t.Run(pathVar+"=$PWD", func { t | + t.Run(pathVar+"=$PWD", func { t -> t.Setenv(pathVar, tmpDir+string(filepath.ListSeparator)+origPath) good := filepath.Join(tmpDir, "execabs-test") if found, err := LookPath(good); err != nil || !strings.HasPrefix(found, good) { @@ -135,7 +135,7 @@ func TestLookPath(t *testing.T) { } }) - t.Run(pathVar+"=$OTHER", func { t | + t.Run(pathVar+"=$OTHER", func { t -> // Control case: if the lookup returns ErrDot when PATH is empty, then we // know that PATH implicitly includes ".". If it does not, then we don't // expect to see ErrDot at all in this test (because the path will be diff --git a/src/os/exec/exec.go b/src/os/exec/exec.go index d65c7f8c3aa46..b89d3d79bd75d 100644 --- a/src/os/exec/exec.go +++ b/src/os/exec/exec.go @@ -405,7 +405,7 @@ func Command(name string, arg ...string) *Cmd { cmd.createdByStack = stack } - runtime.SetFinalizer(cmd, func { c | + runtime.SetFinalizer(cmd, func { c -> if c.Process != nil && c.ProcessState == nil { debugHint := "" if c.createdByStack == nil { diff --git a/src/os/exec/exec_posix_test.go b/src/os/exec/exec_posix_test.go index fdd4e1981dc78..60125cdcf6a44 100644 --- a/src/os/exec/exec_posix_test.go +++ b/src/os/exec/exec_posix_test.go @@ -162,7 +162,7 @@ func TestImplicitPWD(t *testing.T) { for _, tc := range cases { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() cmd := helperCommand(t, "pwd") @@ -239,7 +239,7 @@ func TestExplicitPWD(t *testing.T) { } for _, tc := range cases { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() cmd := helperCommand(t, "pwd") diff --git a/src/os/exec/exec_test.go b/src/os/exec/exec_test.go index d0269ee95dee2..e4a4eec634ea1 100644 --- a/src/os/exec/exec_test.go +++ b/src/os/exec/exec_test.go @@ -759,7 +759,7 @@ func TestExtraFiles(t *testing.T) { // Force TLS root certs to be loaded (which might involve // cgo), to make sure none of that potential C code leaks fds. - ts := httptest.NewUnstartedServer(http.HandlerFunc(func { w, r | })) + ts := httptest.NewUnstartedServer(http.HandlerFunc(func { w, r -> })) // quiet expected TLS handshake error "remote error: bad certificate" ts.Config.ErrorLog = log.New(io.Discard, "", 0) ts.StartTLS() @@ -1346,7 +1346,7 @@ func TestWaitInterrupt(t *testing.T) { // Control case: with no cancellation and no WaitDelay, we should wait for the // process to exit. - t.Run("Wait", func { t | + t.Run("Wait", func { t -> t.Parallel() cmd := startHang(t, context.Background(), 1*time.Millisecond, os.Kill, 0) err := cmd.Wait() @@ -1365,7 +1365,7 @@ func TestWaitInterrupt(t *testing.T) { // With a very long WaitDelay and no Cancel function, we should wait for the // process to exit even if the command's Context is canceled. - t.Run("WaitDelay", func { t | + t.Run("WaitDelay", func { t -> if runtime.GOOS == "windows" { t.Skipf("skipping: os.Interrupt is not implemented on Windows") } @@ -1406,7 +1406,7 @@ func TestWaitInterrupt(t *testing.T) { // the process should be terminated immediately, and its output // pipes should be closed (causing Wait to return) after WaitDelay // even if a child process is still writing to them. - t.Run("SIGKILL-hang", func { t | + t.Run("SIGKILL-hang", func { t -> t.Parallel() ctx, cancel := context.WithCancel(context.Background()) @@ -1431,7 +1431,7 @@ func TestWaitInterrupt(t *testing.T) { // closing the pipes and returning. Wait should return ErrWaitDelay // to indicate that the piped output may be incomplete even though the // command returned a “success” code. - t.Run("Exit-hang", func { t | + t.Run("Exit-hang", func { t -> t.Parallel() cmd := startHang(t, context.Background(), 1*time.Millisecond, nil, 10*time.Millisecond, "-subsleep=10m", "-probe=1ms") @@ -1451,7 +1451,7 @@ func TestWaitInterrupt(t *testing.T) { // If the Cancel function sends a signal that the process can handle, and it // handles that signal without actually exiting, then it should be terminated // after the WaitDelay. - t.Run("SIGINT-ignored", func { t | + t.Run("SIGINT-ignored", func { t -> if runtime.GOOS == "windows" { t.Skipf("skipping: os.Interrupt is not implemented on Windows") } @@ -1475,7 +1475,7 @@ func TestWaitInterrupt(t *testing.T) { // Wait should report a non-nil error (because the process had to be // interrupted), and it should be a context error (because there is no error // to report from the child process itself). - t.Run("SIGINT-handled", func { t | + t.Run("SIGINT-handled", func { t -> if runtime.GOOS == "windows" { t.Skipf("skipping: os.Interrupt is not implemented on Windows") } @@ -1501,7 +1501,7 @@ func TestWaitInterrupt(t *testing.T) { // If the Cancel function sends SIGQUIT, it should be handled in the usual // way: a Go program should dump its goroutines and exit with non-success // status. (We expect SIGQUIT to be a common pattern in real-world use.) - t.Run("SIGQUIT", func { t | + t.Run("SIGQUIT", func { t -> if quitSignal == nil { t.Skipf("skipping: SIGQUIT is not supported on %v", runtime.GOOS) } @@ -1536,7 +1536,7 @@ func TestCancelErrors(t *testing.T) { // If Cancel returns a non-ErrProcessDone error and the process // exits successfully, Wait should wrap the error from Cancel. - t.Run("success after error", func { t | + t.Run("success after error", func { t -> t.Parallel() ctx, cancel := context.WithCancel(context.Background()) @@ -1570,7 +1570,7 @@ func TestCancelErrors(t *testing.T) { // Wait should ignore that error. (ErrProcessDone indicates that the // process was already done before we tried to interrupt it — maybe we // just didn't notice because Wait hadn't been called yet.) - t.Run("success after ErrProcessDone", func { t | + t.Run("success after ErrProcessDone", func { t -> t.Parallel() ctx, cancel := context.WithCancel(context.Background()) @@ -1619,7 +1619,7 @@ func TestCancelErrors(t *testing.T) { // If Cancel returns an error and the process is killed after // WaitDelay, Wait should report the usual SIGKILL ExitError, not the // error from Cancel. - t.Run("killed after error", func { t | + t.Run("killed after error", func { t -> t.Parallel() ctx, cancel := context.WithCancel(context.Background()) @@ -1665,7 +1665,7 @@ func TestCancelErrors(t *testing.T) { // If Cancel returns ErrProcessDone but the process is not actually done // (and has to be killed), Wait should report the usual SIGKILL ExitError, // not the error from Cancel. - t.Run("killed after spurious ErrProcessDone", func { t | + t.Run("killed after spurious ErrProcessDone", func { t -> t.Parallel() ctx, cancel := context.WithCancel(context.Background()) @@ -1710,7 +1710,7 @@ func TestCancelErrors(t *testing.T) { // If Cancel returns an error and the process exits with an // unsuccessful exit code, the process error should take precedence over the // Cancel error. - t.Run("nonzero exit after error", func { t | + t.Run("nonzero exit after error", func { t -> t.Parallel() ctx, cancel := context.WithCancel(context.Background()) @@ -1864,7 +1864,7 @@ func TestAbsPathExec(t *testing.T) { // A simple exec after modifying Cmd.Path should work. // This broke on Windows. See go.dev/issue/68314. - t.Run("modified", func { t | + t.Run("modified", func { t -> if exec.Command(filepath.Join(testenv.GOROOT(t), "bin/go")).Run() == nil { // The implementation of the test case below relies on the go binary // exiting with a non-zero exit code when run without any arguments. diff --git a/src/os/exec/lp_windows_test.go b/src/os/exec/lp_windows_test.go index 070e45d441540..783e29adcfbf5 100644 --- a/src/os/exec/lp_windows_test.go +++ b/src/os/exec/lp_windows_test.go @@ -290,7 +290,7 @@ func TestLookPathWindows(t *testing.T) { } for _, tt := range lookPathTests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> if tt.want == "" && tt.wantErr == nil { t.Fatalf("test must specify either want or wantErr") } @@ -542,7 +542,7 @@ func TestCommand(t *testing.T) { maySkipHelperCommand("printpath") for _, tt := range commandTests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> if tt.PATH == nil { t.Fatalf("test must specify PATH") } diff --git a/src/os/os_test.go b/src/os/os_test.go index b8a84f926d9df..948c7a2f8ca3b 100644 --- a/src/os/os_test.go +++ b/src/os/os_test.go @@ -768,7 +768,7 @@ func TestReaddirStatFailures(t *testing.T) { } var xerr error // error to return for x - *LstatP = func { path | + *LstatP = func { path -> if xerr != nil && strings.HasSuffix(path, "x") { return nil, xerr } @@ -1149,7 +1149,7 @@ func TestRenameCaseDifference(pt *testing.T) { } for _, test := range tests { - pt.Run(test.name, func { t | + pt.Run(test.name, func { t -> defer chtmpdir(t)() if err := test.create(); err != nil { @@ -2457,7 +2457,7 @@ func TestLongPath(t *testing.T) { tmpdir += "/dir3456789" } for _, sz := range sizes { - t.Run(fmt.Sprintf("length=%d", sz), func { t | + t.Run(fmt.Sprintf("length=%d", sz), func { t -> sizedTempDir := tmpdir[:sz-1] + "x" // Ensure it does not end with a slash. // The various sized runs are for this call to trigger the boundary @@ -2550,7 +2550,7 @@ func testKillProcess(t *testing.T, processKiller func(p *Process)) { } func TestKillStartProcess(t *testing.T) { - testKillProcess(t, func { p | + testKillProcess(t, func { p -> err := p.Kill() if err != nil { t.Fatalf("Failed to kill test process: %v", err) @@ -2589,7 +2589,7 @@ func TestGetppid(t *testing.T) { } func TestKillFindProcess(t *testing.T) { - testKillProcess(t, func { p | + testKillProcess(t, func { p -> p2, err := FindProcess(p.Pid) if err != nil { t.Fatalf("Failed to find test process: %v", err) @@ -2989,7 +2989,7 @@ func forceMFTUpdateOnWindows(t *testing.T, path string) { // On Windows, we force the MFT to update by reading the actual metadata from GetFileInformationByHandle and then // explicitly setting that. Otherwise it might get out of sync with FindFirstFile. See golang.org/issues/42637. - if err := filepath.WalkDir(path, func { path, d, err | + if err := filepath.WalkDir(path, func { path, d, err -> if err != nil { t.Fatal(err) } @@ -3111,7 +3111,7 @@ func TestDirFSPathsValid(t *testing.T) { } fsys := DirFS(d) - err := fs.WalkDir(fsys, ".", func { path, e, err | + err := fs.WalkDir(fsys, ".", func { path, e, err -> if fs.ValidPath(e.Name()) { t.Logf("%q ok", e.Name()) } else { @@ -3333,7 +3333,7 @@ func TestCopyFS(t *testing.T) { if err := fstest.TestFS(tmpFsys, "a", "b", "dir/x"); err != nil { t.Fatal("TestFS:", err) } - if err := fs.WalkDir(fsys, ".", func { path, d, err | + if err := fs.WalkDir(fsys, ".", func { path, d, err -> if d.IsDir() { return nil } @@ -3379,7 +3379,7 @@ func TestCopyFS(t *testing.T) { if err := fstest.TestFS(tmpFsys, "william", "carl", "daVinci", "einstein", "dir/newton"); err != nil { t.Fatal("TestFS:", err) } - if err := fs.WalkDir(fsys, ".", func { path, d, err | + if err := fs.WalkDir(fsys, ".", func { path, d, err -> if d.IsDir() { return nil } @@ -3492,7 +3492,7 @@ func TestCopyFSWithSymlinks(t *testing.T) { if err := fstest.TestFS(tmpFsys, "file.in.txt", "out_symlinks/file.abs.out.link", "out_symlinks/file.rel.out.link", "in_symlinks/file.rel.in.link"); err != nil { t.Fatal("TestFS:", err) } - if err := fs.WalkDir(fsys, ".", func { path, d, err | + if err := fs.WalkDir(fsys, ".", func { path, d, err -> if d.IsDir() { return nil } diff --git a/src/os/os_unix_test.go b/src/os/os_unix_test.go index 35d70af55b1d2..aa67648948a6e 100644 --- a/src/os/os_unix_test.go +++ b/src/os/os_unix_test.go @@ -19,7 +19,7 @@ import ( ) func init() { - isReadonlyError = func { err | return err == syscall.EROFS } + isReadonlyError = func { err -> return err == syscall.EROFS } } // For TestRawConnReadWrite. @@ -198,7 +198,7 @@ func TestLchown(t *testing.T) { func TestReaddirRemoveRace(t *testing.T) { oldStat := *LstatP defer func() { *LstatP = oldStat }() - *LstatP = func { name | + *LstatP = func { name -> if strings.HasSuffix(name, "some-file") { // Act like it's been deleted. return nil, ErrNotExist diff --git a/src/os/os_windows_test.go b/src/os/os_windows_test.go index 86978242fc732..c4d9c2c469389 100644 --- a/src/os/os_windows_test.go +++ b/src/os/os_windows_test.go @@ -737,9 +737,9 @@ func TestReadStdin(t *testing.T) { for _, consoleSize := range []int{1, 2, 3, 10, 16, 100, 1000} { for _, readSize := range []int{1, 2, 3, 4, 5, 8, 10, 16, 20, 50, 100} { for _, s := range tests { - t.Run(fmt.Sprintf("c%d/r%d/%s", consoleSize, readSize, s), func { t | + t.Run(fmt.Sprintf("c%d/r%d/%s", consoleSize, readSize, s), func { t -> s16 := utf16.Encode([]rune(s)) - poll.ReadConsole = func { h, buf, toread, read, inputControl | + poll.ReadConsole = func { h, buf, toread, read, inputControl -> if inputControl != nil { t.Fatalf("inputControl not nil") } @@ -1300,7 +1300,7 @@ func TestReadlink(t *testing.T) { name += "_absolute" } - t.Run(name, func { t | + t.Run(name, func { t -> if !tt.relative { t.Parallel() } diff --git a/src/os/rawconn_test.go b/src/os/rawconn_test.go index 54232e6bcd6ae..bc755605b5268 100644 --- a/src/os/rawconn_test.go +++ b/src/os/rawconn_test.go @@ -34,7 +34,7 @@ func TestRawConnReadWrite(t *testing.T) { } var operr error - err = wconn.Write(func { s | + err = wconn.Write(func { s -> _, operr = syscall.Write(syscallDescriptor(s), []byte{'b'}) return operr != syscall.EAGAIN }) @@ -47,7 +47,7 @@ func TestRawConnReadWrite(t *testing.T) { var n int buf := make([]byte, 1) - err = rconn.Read(func { s | + err = rconn.Read(func { s -> n, operr = syscall.Read(syscallDescriptor(s), buf) return operr != syscall.EAGAIN }) diff --git a/src/os/readfrom_linux_test.go b/src/os/readfrom_linux_test.go index bbbeca96f874d..0dd4c847a4445 100644 --- a/src/os/readfrom_linux_test.go +++ b/src/os/readfrom_linux_test.go @@ -30,29 +30,29 @@ func TestCopyFileRange(t *testing.T) { syscall.Getpagesize() + 1, 32769, } - t.Run("Basic", func { t | + t.Run("Basic", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testCopyFileRange(t, int64(size), -1) }) + t.Run(strconv.Itoa(size), func { t -> testCopyFileRange(t, int64(size), -1) }) } }) - t.Run("Limited", func { t | - t.Run("OneLess", func { t | + t.Run("Limited", func { t -> + t.Run("OneLess", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testCopyFileRange(t, int64(size), int64(size)-1) }) + t.Run(strconv.Itoa(size), func { t -> testCopyFileRange(t, int64(size), int64(size)-1) }) } }) - t.Run("Half", func { t | + t.Run("Half", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testCopyFileRange(t, int64(size), int64(size)/2) }) + t.Run(strconv.Itoa(size), func { t -> testCopyFileRange(t, int64(size), int64(size)/2) }) } }) - t.Run("More", func { t | + t.Run("More", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testCopyFileRange(t, int64(size), int64(size)+7) }) + t.Run(strconv.Itoa(size), func { t -> testCopyFileRange(t, int64(size), int64(size)+7) }) } }) }) - t.Run("DoesntTryInAppendMode", func { t | + t.Run("DoesntTryInAppendMode", func { t -> dst, src, data, hook := newCopyFileRangeTest(t, 42) dst2, err := OpenFile(dst.Name(), O_RDWR|O_APPEND, 0755) @@ -70,7 +70,7 @@ func TestCopyFileRange(t *testing.T) { mustSeekStart(t, dst2) mustContainData(t, dst2, data) // through traditional means }) - t.Run("CopyFileItself", func { t | + t.Run("CopyFileItself", func { t -> hook := hookCopyFileRange(t) f, err := CreateTemp("", "file-readfrom-itself-test") @@ -120,8 +120,8 @@ func TestCopyFileRange(t *testing.T) { t.Fatalf("data mismatch: %s != %s", string(data), string(data2)) } }) - t.Run("NotRegular", func { t | - t.Run("BothPipes", func { t | + t.Run("NotRegular", func { t -> + t.Run("BothPipes", func { t -> hook := hookCopyFileRange(t) pr1, pw1, err := Pipe() @@ -160,7 +160,7 @@ func TestCopyFileRange(t *testing.T) { pw2.Close() mustContainData(t, pr2, data) }) - t.Run("DstPipe", func { t | + t.Run("DstPipe", func { t -> dst, src, data, hook := newCopyFileRangeTest(t, 255) dst.Close() @@ -184,7 +184,7 @@ func TestCopyFileRange(t *testing.T) { pw.Close() mustContainData(t, pr, data) }) - t.Run("SrcPipe", func { t | + t.Run("SrcPipe", func { t -> dst, src, data, hook := newCopyFileRangeTest(t, 255) src.Close() @@ -217,7 +217,7 @@ func TestCopyFileRange(t *testing.T) { mustContainData(t, dst, data) }) }) - t.Run("Nil", func { t | + t.Run("Nil", func { t -> var nilFile *File anyFile, err := CreateTemp("", "") if err != nil { @@ -256,47 +256,47 @@ func TestSpliceFile(t *testing.T) { syscall.Getpagesize() + 1, 32769, } - t.Run("Basic-TCP", func { t | + t.Run("Basic-TCP", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSpliceFile(t, "tcp", int64(size), -1) }) + t.Run(strconv.Itoa(size), func { t -> testSpliceFile(t, "tcp", int64(size), -1) }) } }) - t.Run("Basic-Unix", func { t | + t.Run("Basic-Unix", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSpliceFile(t, "unix", int64(size), -1) }) + t.Run(strconv.Itoa(size), func { t -> testSpliceFile(t, "unix", int64(size), -1) }) } }) - t.Run("TCP-To-TTY", func { t | testSpliceToTTY(t, "tcp", 32768) }) - t.Run("Unix-To-TTY", func { t | testSpliceToTTY(t, "unix", 32768) }) - t.Run("Limited", func { t | - t.Run("OneLess-TCP", func { t | + t.Run("TCP-To-TTY", func { t -> testSpliceToTTY(t, "tcp", 32768) }) + t.Run("Unix-To-TTY", func { t -> testSpliceToTTY(t, "unix", 32768) }) + t.Run("Limited", func { t -> + t.Run("OneLess-TCP", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSpliceFile(t, "tcp", int64(size), int64(size)-1) }) + t.Run(strconv.Itoa(size), func { t -> testSpliceFile(t, "tcp", int64(size), int64(size)-1) }) } }) - t.Run("OneLess-Unix", func { t | + t.Run("OneLess-Unix", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSpliceFile(t, "unix", int64(size), int64(size)-1) }) + t.Run(strconv.Itoa(size), func { t -> testSpliceFile(t, "unix", int64(size), int64(size)-1) }) } }) - t.Run("Half-TCP", func { t | + t.Run("Half-TCP", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSpliceFile(t, "tcp", int64(size), int64(size)/2) }) + t.Run(strconv.Itoa(size), func { t -> testSpliceFile(t, "tcp", int64(size), int64(size)/2) }) } }) - t.Run("Half-Unix", func { t | + t.Run("Half-Unix", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSpliceFile(t, "unix", int64(size), int64(size)/2) }) + t.Run(strconv.Itoa(size), func { t -> testSpliceFile(t, "unix", int64(size), int64(size)/2) }) } }) - t.Run("More-TCP", func { t | + t.Run("More-TCP", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSpliceFile(t, "tcp", int64(size), int64(size)+1) }) + t.Run(strconv.Itoa(size), func { t -> testSpliceFile(t, "tcp", int64(size), int64(size)+1) }) } }) - t.Run("More-Unix", func { t | + t.Run("More-Unix", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSpliceFile(t, "unix", int64(size), int64(size)+1) }) + t.Run(strconv.Itoa(size), func { t -> testSpliceFile(t, "unix", int64(size), int64(size)+1) }) } }) }) @@ -341,7 +341,7 @@ func testSpliceFile(t *testing.T, proto string, size, limit int64) { if err != nil { t.Fatalf("server Conn SyscallConn error: %v", err) } - if err = rc.Control(func { fd | + if err = rc.Control(func { fd -> if hook.called && hook.srcfd != int(fd) { t.Fatalf("wrong source file descriptor: got %d, want %d", hook.srcfd, int(fd)) } @@ -633,7 +633,7 @@ type copyFileRangeHook struct { func (h *copyFileRangeHook) install() { h.original = *PollCopyFileRangeP - *PollCopyFileRangeP = func { dst, src, remain | + *PollCopyFileRangeP = func { dst, src, remain -> h.called = true h.dstfd = dst.Sysfd h.srcfd = src.Sysfd @@ -669,7 +669,7 @@ type spliceFileHook struct { func (h *spliceFileHook) install() { h.original = *PollSpliceFile - *PollSpliceFile = func { dst, src, remain | + *PollSpliceFile = func { dst, src, remain -> h.called = true h.dstfd = dst.Sysfd h.srcfd = src.Sysfd @@ -718,8 +718,8 @@ func TestProcCopy(t *testing.T) { } func TestGetPollFDAndNetwork(t *testing.T) { - t.Run("tcp4", func { t | testGetPollFDAndNetwork(t, "tcp4") }) - t.Run("unix", func { t | testGetPollFDAndNetwork(t, "unix") }) + t.Run("tcp4", func { t -> testGetPollFDAndNetwork(t, "tcp4") }) + t.Run("unix", func { t -> testGetPollFDAndNetwork(t, "unix") }) } func testGetPollFDAndNetwork(t *testing.T, proto string) { @@ -732,7 +732,7 @@ func testGetPollFDAndNetwork(t *testing.T, proto string) { if err != nil { t.Fatalf("server SyscallConn error: %v", err) } - if err = rc.Control(func { fd | + if err = rc.Control(func { fd -> pfd, network := GetPollFDAndNetwork(server) if pfd == nil { t.Fatalf("GetPollFDAndNetwork didn't return poll.FD") diff --git a/src/os/signal/signal_test.go b/src/os/signal/signal_test.go index 23cf5874b2999..b08a55c64b630 100644 --- a/src/os/signal/signal_test.go +++ b/src/os/signal/signal_test.go @@ -348,7 +348,7 @@ func TestStop(t *testing.T) { for _, sig := range sigs { sig := sig - t.Run(fmt.Sprint(sig), func { t | + t.Run(fmt.Sprint(sig), func { t -> // When calling Notify with a specific signal, // independent signals should not interfere with each other, // and we end up needing to wait for signals to quiesce a lot. @@ -427,7 +427,7 @@ func TestNohup(t *testing.T) { // // Both should fail without nohup and succeed with nohup. - t.Run("uncaught", func { t | + t.Run("uncaught", func { t -> // Ugly: ask for SIGHUP so that child will not have no-hup set // even if test is running under nohup environment. // We have no intention of reading from c. @@ -442,7 +442,7 @@ func TestNohup(t *testing.T) { } for i := 1; i <= 2; i++ { i := i - t.Run(fmt.Sprintf("%d", i), func { t | + t.Run(fmt.Sprintf("%d", i), func { t -> t.Parallel() args := []string{ @@ -465,7 +465,7 @@ func TestNohup(t *testing.T) { } }) - t.Run("nohup", func { t | + t.Run("nohup", func { t -> // Skip the nohup test below when running in tmux on darwin, since nohup // doesn't work correctly there. See issue #5135. if runtime.GOOS == "darwin" && os.Getenv("TMUX") != "" { @@ -485,7 +485,7 @@ func TestNohup(t *testing.T) { } for i := 1; i <= 2; i++ { i := i - t.Run(fmt.Sprintf("%d", i), func { t | + t.Run(fmt.Sprintf("%d", i), func { t -> t.Parallel() // POSIX specifies that nohup writes to a file named nohup.out if standard @@ -744,7 +744,7 @@ func TestNotifyContextNotifications(t *testing.T) { } for _, tc := range testCases { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() var subTimeout time.Duration diff --git a/src/os/tempfile_test.go b/src/os/tempfile_test.go index 030e8591afcfd..444c627735039 100644 --- a/src/os/tempfile_test.go +++ b/src/os/tempfile_test.go @@ -77,7 +77,7 @@ func TestCreateTempBadPattern(t *testing.T) { {"tempfile_test*foo" + sep, true}, } for _, tt := range tests { - t.Run(tt.pattern, func { t | + t.Run(tt.pattern, func { t -> tmpfile, err := CreateTemp(tmpDir, tt.pattern) if tmpfile != nil { defer tmpfile.Close() @@ -129,7 +129,7 @@ func TestMkdirTemp(t *testing.T) { } for _, tt := range tests { - t.Run(tt.pattern, func { t | + t.Run(tt.pattern, func { t -> wantRePat := "^" + regexp.QuoteMeta(filepath.Join(dir, tt.wantPrefix)) + "[0-9]+" + regexp.QuoteMeta(tt.wantSuffix) + "$" runTestMkdirTemp(t, tt.pattern, wantRePat) }) @@ -141,7 +141,7 @@ func TestMkdirTemp(t *testing.T) { // ^[0-9]+xyz$ // yet we just want to match // "^/[0-9]+xyz" - t.Run("*xyz", func { t | + t.Run("*xyz", func { t -> wantRePat := "^" + regexp.QuoteMeta(filepath.Join(dir)) + regexp.QuoteMeta(string(filepath.Separator)) + "[0-9]+xyz$" runTestMkdirTemp(t, "*xyz", wantRePat) }) @@ -188,7 +188,7 @@ func TestMkdirTempBadPattern(t *testing.T) { {"tempfile_test*foo" + sep, true}, } for _, tt := range tests { - t.Run(tt.pattern, func { t | + t.Run(tt.pattern, func { t -> _, err := MkdirTemp(tmpDir, tt.pattern) if tt.wantErr { if err == nil { diff --git a/src/os/timeout_test.go b/src/os/timeout_test.go index 091ff71bc224c..7b7e27a28baca 100644 --- a/src/os/timeout_test.go +++ b/src/os/timeout_test.go @@ -157,7 +157,7 @@ func TestWriteTimeout(t *testing.T) { t.Parallel() for i, tt := range writeTimeoutTests { - t.Run(fmt.Sprintf("#%d", i), func { t | + t.Run(fmt.Sprintf("#%d", i), func { t -> r, w, err := os.Pipe() if err != nil { t.Fatal(err) @@ -489,7 +489,7 @@ func testVariousDeadlines(t *testing.T) { } } for run := 0; run < numRuns; run++ { - t.Run(fmt.Sprintf("%v-%d", timeout, run+1), func { t | + t.Run(fmt.Sprintf("%v-%d", timeout, run+1), func { t -> r, w, err := os.Pipe() if err != nil { t.Fatal(err) diff --git a/src/os/user/cgo_lookup_unix.go b/src/os/user/cgo_lookup_unix.go index 3edca48480be5..950ae36050434 100644 --- a/src/os/user/cgo_lookup_unix.go +++ b/src/os/user/cgo_lookup_unix.go @@ -25,7 +25,7 @@ func lookupUser(username string) (*User, error) { nameC := make([]byte, len(username)+1) copy(nameC, username) - err := retryWithBuffer(userBuffer, func { buf | + err := retryWithBuffer(userBuffer, func { buf -> var errno syscall.Errno pwd, found, errno = _C_getpwnam_r((*_C_char)(unsafe.Pointer(&nameC[0])), (*_C_char)(unsafe.Pointer(&buf[0])), _C_size_t(len(buf))) @@ -52,7 +52,7 @@ func lookupUnixUid(uid int) (*User, error) { var pwd _C_struct_passwd var found bool - err := retryWithBuffer(userBuffer, func { buf | + err := retryWithBuffer(userBuffer, func { buf -> var errno syscall.Errno pwd, found, errno = _C_getpwuid_r(_C_uid_t(uid), (*_C_char)(unsafe.Pointer(&buf[0])), _C_size_t(len(buf))) @@ -90,7 +90,7 @@ func lookupGroup(groupname string) (*Group, error) { cname := make([]byte, len(groupname)+1) copy(cname, groupname) - err := retryWithBuffer(groupBuffer, func { buf | + err := retryWithBuffer(groupBuffer, func { buf -> var errno syscall.Errno grp, found, errno = _C_getgrnam_r((*_C_char)(unsafe.Pointer(&cname[0])), (*_C_char)(unsafe.Pointer(&buf[0])), _C_size_t(len(buf))) @@ -117,7 +117,7 @@ func lookupUnixGid(gid int) (*Group, error) { var grp _C_struct_group var found bool - err := retryWithBuffer(groupBuffer, func { buf | + err := retryWithBuffer(groupBuffer, func { buf -> var errno syscall.Errno grp, found, errno = _C_getgrgid_r(_C_gid_t(gid), (*_C_char)(unsafe.Pointer(&buf[0])), _C_size_t(len(buf))) diff --git a/src/os/writeto_linux_test.go b/src/os/writeto_linux_test.go index 31df4086caf4f..b040683b0563d 100644 --- a/src/os/writeto_linux_test.go +++ b/src/os/writeto_linux_test.go @@ -25,14 +25,14 @@ func TestSendFile(t *testing.T) { syscall.Getpagesize() + 1, 32769, } - t.Run("sendfile-to-unix", func { t | + t.Run("sendfile-to-unix", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSendFile(t, "unix", int64(size)) }) + t.Run(strconv.Itoa(size), func { t -> testSendFile(t, "unix", int64(size)) }) } }) - t.Run("sendfile-to-tcp", func { t | + t.Run("sendfile-to-tcp", func { t -> for _, size := range sizes { - t.Run(strconv.Itoa(size), func { t | testSendFile(t, "tcp", int64(size)) }) + t.Run(strconv.Itoa(size), func { t -> testSendFile(t, "tcp", int64(size)) }) } }) } @@ -61,7 +61,7 @@ func testSendFile(t *testing.T, proto string, size int64) { if err != nil { t.Fatalf("destination SyscallConn error: %v", err) } - if err = rc.Control(func { fd | + if err = rc.Control(func { fd -> if hook.called && hook.dstfd != int(fd) { t.Fatalf("wrong destination file descriptor: got %d, want %d", hook.dstfd, int(fd)) } @@ -109,7 +109,7 @@ func hookSendFile(t *testing.T) *sendFileHook { t.Cleanup(func() { poll.TestHookDidSendFile = orig }) - poll.TestHookDidSendFile = func { dstFD, src, written, err, handled | + poll.TestHookDidSendFile = func { dstFD, src, written, err, handled -> h.called = true h.dstfd = dstFD.Sysfd h.srcfd = src diff --git a/src/path/filepath/example_unix_walk_test.go b/src/path/filepath/example_unix_walk_test.go index c889da0ef4d81..158aab5064ec3 100644 --- a/src/path/filepath/example_unix_walk_test.go +++ b/src/path/filepath/example_unix_walk_test.go @@ -40,7 +40,7 @@ func ExampleWalk() { subDirToSkip := "skip" fmt.Println("On Unix:") - err = filepath.Walk(".", func { path, info, err | + err = filepath.Walk(".", func { path, info, err -> if err != nil { fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", path, err) return err diff --git a/src/path/filepath/path_test.go b/src/path/filepath/path_test.go index 6c5255d81ea1f..75519c35f4221 100644 --- a/src/path/filepath/path_test.go +++ b/src/path/filepath/path_test.go @@ -552,7 +552,7 @@ func walkTree(n *Node, path string, f func(path string, n *Node)) { } func makeTree(t *testing.T) { - walkTree(tree, tree.name, func { path, n | + walkTree(tree, tree.name, func { path, n -> if n.entries == nil { fd, err := os.Create(path) if err != nil { @@ -566,10 +566,10 @@ func makeTree(t *testing.T) { }) } -func markTree(n *Node) { walkTree(n, "", func { path, n | n.mark++ }) } +func markTree(n *Node) { walkTree(n, "", func { path, n -> n.mark++ }) } func checkMarks(t *testing.T, report bool) { - walkTree(tree, tree.name, func { path, n | + walkTree(tree, tree.name, func { path, n -> if n.mark != 1 && report { t.Errorf("node %s mark = %d; expected 1", path, n.mark) } @@ -582,7 +582,7 @@ func checkMarks(t *testing.T, report bool) { // are always accumulated, though. func mark(d fs.DirEntry, err error, errors *[]error, clear bool) error { name := d.Name() - walkTree(tree, tree.name, func { path, n | if n.name == name { + walkTree(tree, tree.name, func { path, n -> if n.name == name { n.mark++ } }) if err != nil { @@ -649,7 +649,7 @@ func tempDirCanonical(t *testing.T) string { func TestWalk(t *testing.T) { walk := func(root string, fn fs.WalkDirFunc) error { - return filepath.Walk(root, func { path, info, err | return fn(path, fs.FileInfoToDirEntry(info), err) }) + return filepath.Walk(root, func { path, info, err -> return fn(path, fs.FileInfoToDirEntry(info), err) }) } testWalk(t, walk, 1) } @@ -692,7 +692,7 @@ func testWalk(t *testing.T, walk func(string, fs.WalkDirFunc) error, errVisit in checkMarks(t, true) errors = errors[0:0] - t.Run("PermErr", func { t | + t.Run("PermErr", func { t -> // Test permission errors. Only possible if we're not root // and only on some file systems (AFS, FAT). To avoid errors during // all.bash on those file systems, skip during go test -short. @@ -798,12 +798,12 @@ func TestWalkSkipDirOnFile(t *testing.T) { } } - t.Run("Walk", func { t | + t.Run("Walk", func { t -> Walk := func(root string) error { return filepath.Walk(td, walkFn) } check(t, Walk, td) check(t, Walk, filepath.Join(td, "dir")) }) - t.Run("WalkDir", func { t | + t.Run("WalkDir", func { t -> WalkDir := func(root string) error { return filepath.WalkDir(td, walkDirFn) } check(t, WalkDir, td) check(t, WalkDir, filepath.Join(td, "dir")) @@ -856,12 +856,12 @@ func TestWalkSkipAllOnFile(t *testing.T) { } } - t.Run("Walk", func { t | + t.Run("Walk", func { t -> Walk := func(_ string) error { return filepath.Walk(td, walkFn) } check(t, Walk, td) check(t, Walk, filepath.Join(td, "dir")) }) - t.Run("WalkDir", func { t | + t.Run("WalkDir", func { t -> WalkDir := func(_ string) error { return filepath.WalkDir(td, walkDirFn) } check(t, WalkDir, td) check(t, WalkDir, filepath.Join(td, "dir")) @@ -883,14 +883,14 @@ func TestWalkFileError(t *testing.T) { *filepath.LstatP = os.Lstat }() statErr := errors.New("some stat error") - *filepath.LstatP = func { path | + *filepath.LstatP = func { path -> if strings.HasSuffix(path, "stat-error") { return nil, statErr } return os.Lstat(path) } got := map[string]error{} - err := filepath.Walk(td, func { path, fi, err | + err := filepath.Walk(td, func { path, fi, err -> rel, _ := filepath.Rel(td, path) got[filepath.ToSlash(rel)] = err return nil @@ -986,9 +986,9 @@ func TestWalkSymlinkRoot(t *testing.T) { }, } { tt := tt - t.Run(tt.desc, func { t | + t.Run(tt.desc, func { t -> var walked []string - err := filepath.Walk(tt.root, func { path, info, err | + err := filepath.Walk(tt.root, func { path, info, err -> if err != nil { return err } @@ -1726,7 +1726,7 @@ func TestBug3486(t *testing.T) { // https://golang.org/issue/3486 utf8 := filepath.Join(root, "utf8") seenUTF16 := false seenUTF8 := false - err := filepath.Walk(root, func { pth, info, err | + err := filepath.Walk(root, func { pth, info, err -> if err != nil { t.Fatal(err) } @@ -1771,7 +1771,7 @@ func testWalkSymlink(t *testing.T, mklink func(target, link string) error) { } var visited []string - err = filepath.Walk(tmpdir, func { path, info, err | + err = filepath.Walk(tmpdir, func { path, info, err -> if err != nil { t.Fatal(err) } @@ -1929,7 +1929,7 @@ func TestIssue51617(t *testing.T) { } defer os.Chmod(bad, 0700) // avoid errors on cleanup var saw []string - err := filepath.WalkDir(dir, func { path, d, err | + err := filepath.WalkDir(dir, func { path, d, err -> if err != nil { return filepath.SkipDir } diff --git a/src/path/filepath/path_windows_test.go b/src/path/filepath/path_windows_test.go index 53cd1650c5202..6104f78cd66f1 100644 --- a/src/path/filepath/path_windows_test.go +++ b/src/path/filepath/path_windows_test.go @@ -468,7 +468,7 @@ func testWalkMklink(t *testing.T, linktype string) { if !strings.Contains(string(output), fmt.Sprintf(" /%s ", linktype)) { t.Skipf(`skipping test; mklink does not supports /%s parameter`, linktype) } - testWalkSymlink(t, func { target, link | + testWalkSymlink(t, func { target, link -> output, err := exec.Command("cmd", "/c", "mklink", "/"+linktype, link, target).CombinedOutput() if err != nil { return fmt.Errorf(`"mklink /%s %v %v" command failed: %v\n%v`, linktype, link, target, err, string(output)) diff --git a/src/reflect/abi_test.go b/src/reflect/abi_test.go index f95ff0e22be81..c52815e11c1e3 100644 --- a/src/reflect/abi_test.go +++ b/src/reflect/abi_test.go @@ -166,7 +166,7 @@ func TestReflectCallABI(t *testing.T) { r := rand.New(rand.NewSource(genValueRandSeed)) for _, fn := range abiCallTestCases { fn := reflect.ValueOf(fn) - t.Run(runtime.FuncForPC(fn.Pointer()).Name(), func { t | + t.Run(runtime.FuncForPC(fn.Pointer()).Name(), func { t -> typ := fn.Type() if typ.Kind() != reflect.Func { t.Fatalf("test case is not a function, has type: %s", typ.String()) @@ -211,7 +211,7 @@ func TestReflectMakeFuncCallABI(t *testing.T) { fnTyp := reflect.TypeOf(callFn).In(0) fn := reflect.MakeFunc(fnTyp, makeFuncHandler) callFn := reflect.ValueOf(callFn) - t.Run(runtime.FuncForPC(callFn.Pointer()).Name(), func { t | + t.Run(runtime.FuncForPC(callFn.Pointer()).Name(), func { t -> args := []reflect.Value{fn} for i := 0; i < fnTyp.NumIn()-1; /* last one is magic type */i++ { args = append(args, genValue(t, fnTyp.In(i), r)) @@ -226,7 +226,7 @@ func TestReflectMakeFuncCallABI(t *testing.T) { } }) } - t.Run("OnlyPointerInRegisterGC", func { t | + t.Run("OnlyPointerInRegisterGC", func { t -> // This test attempts to induce a failure wherein // the last pointer to an object is passed via registers. // If makeFuncStub doesn't successfully store the pointer @@ -234,7 +234,7 @@ func TestReflectMakeFuncCallABI(t *testing.T) { // freed and then the next GC should notice that an object // was inexplicably revived. var f func(b *uint64, _ MagicLastTypeNameForTestingRegisterABI) *uint64 - mkfn := reflect.MakeFunc(reflect.TypeOf(f), func { args | + mkfn := reflect.MakeFunc(reflect.TypeOf(f), func { args -> *(args[0].Interface().(*uint64)) = 5 return args[:1] }) @@ -965,7 +965,7 @@ func genValue(t *testing.T, typ reflect.Type, r *rand.Rand) reflect.Value { } func TestSignalingNaNArgument(t *testing.T) { - v := reflect.ValueOf(func { x | + v := reflect.ValueOf(func { x -> // make sure x is a signaling NaN. u := math.Float32bits(x) if u != snan { diff --git a/src/reflect/all_test.go b/src/reflect/all_test.go index c0ae6dda4d736..54983a90ddb48 100644 --- a/src/reflect/all_test.go +++ b/src/reflect/all_test.go @@ -556,7 +556,7 @@ func TestCanSetField(t *testing.T) { }} for _, tt := range tests { - t.Run(tt.val.Type().Name(), func { t | + t.Run(tt.val.Type().Name(), func { t -> for _, tc := range tt.cases { f := tt.val for _, i := range tc.index { @@ -761,7 +761,7 @@ func TestGrow(t *testing.T) { t.Errorf("noop v.Grow should not change pointers") } - t.Run("Append", func { t | + t.Run("Append", func { t -> var got, want []T v := ValueOf(&got).Elem() appendValue := func(vt T) { @@ -779,7 +779,7 @@ func TestGrow(t *testing.T) { } }) - t.Run("Rate", func { t | + t.Run("Rate", func { t -> var b []byte v := ValueOf(new([]byte)).Elem() for i := 0; i < 10; i++ { @@ -792,7 +792,7 @@ func TestGrow(t *testing.T) { } }) - t.Run("ZeroCapacity", func { t | + t.Run("ZeroCapacity", func { t -> for i := 0; i < 10; i++ { v := ValueOf(new([]byte)).Elem() v.Grow(61) @@ -923,7 +923,7 @@ func TestCopy(t *testing.T) { } func TestCopyString(t *testing.T) { - t.Run("Slice", func { t | + t.Run("Slice", func { t -> s := bytes.Repeat([]byte{'_'}, 8) val := ValueOf(s) @@ -942,7 +942,7 @@ func TestCopyString(t *testing.T) { t.Errorf("got n = %d, s = %s, expecting n = 8, s = %s", n, s, expecting) } }) - t.Run("Array", func { t | + t.Run("Array", func { t -> s := [...]byte{'_', '_', '_', '_', '_', '_', '_', '_'} val := ValueOf(&s).Elem() @@ -1274,7 +1274,7 @@ var deepEqualPerfTests = []struct { func TestDeepEqualAllocs(t *testing.T) { for _, tt := range deepEqualPerfTests { - t.Run(ValueOf(tt.x).Type().String(), func { t | + t.Run(ValueOf(tt.x).Type().String(), func { t -> got := testing.AllocsPerRun(100, func() { if !DeepEqual(tt.x, tt.y) { t.Errorf("DeepEqual(%v, %v)=false", tt.x, tt.y) @@ -2179,7 +2179,7 @@ func TestFunc(t *testing.T) { func TestCallConvert(t *testing.T) { v := ValueOf(new(io.ReadWriter)).Elem() - f := ValueOf(func { r | return r }) + f := ValueOf(func { r -> return r }) out := f.Call([]Value{v}) if len(out) != 1 || out[0].Type() != TypeOf(new(io.Reader)).Elem() || !out[0].IsNil() { t.Errorf("expected [nil], got %v", out) @@ -2252,7 +2252,7 @@ func TestCallReturnsEmpty(t *testing.T) { func TestMakeFunc(t *testing.T) { f := dummy - fv := MakeFunc(TypeOf(f), func { in | return in }) + fv := MakeFunc(TypeOf(f), func { in -> return in }) ValueOf(&f).Elem().Set(fv) // Call g with small arguments so that there is @@ -2289,7 +2289,7 @@ func TestMakeFuncInterface(t *testing.T) { func TestMakeFuncVariadic(t *testing.T) { // Test that variadic arguments are packed into a slice and passed as last arg fn := func(_ int, is ...int) []int { return nil } - fv := MakeFunc(TypeOf(fn), func { in | return in[1:2] }) + fv := MakeFunc(TypeOf(fn), func { in -> return in[1:2] }) ValueOf(&fn).Elem().Set(fv) r := fn(1, 2, 3) @@ -3495,7 +3495,7 @@ func noAlloc(t *testing.T, n int, f func(int)) { } func TestAllocations(t *testing.T) { - noAlloc(t, 100, func { j | + noAlloc(t, 100, func { j -> var i any var v Value @@ -3505,7 +3505,7 @@ func TestAllocations(t *testing.T) { panic("wrong int") } }) - noAlloc(t, 100, func { j | + noAlloc(t, 100, func { j -> var i any var v Value i = [3]int{j, j, j} @@ -3514,10 +3514,10 @@ func TestAllocations(t *testing.T) { panic("wrong length") } }) - noAlloc(t, 100, func { j | + noAlloc(t, 100, func { j -> var i any var v Value - i = func { j | return j } + i = func { j -> return j } v = ValueOf(i) if v.Interface().(func(int) int)(j) != j { panic("wrong result") @@ -6744,7 +6744,7 @@ func TestCallArgLive(t *testing.T) { *CallGC = true x := new(string) - runtime.SetFinalizer(x, func { p | if *p != "ok" { + runtime.SetFinalizer(x, func { p -> if *p != "ok" { t.Errorf("x dead prematurely") } }) v := T{x, nil} @@ -6868,9 +6868,9 @@ func TestCallGC(t *testing.T) { func TestKeepFuncLive(t *testing.T) { // Test that we keep makeFuncImpl live as long as it is // referenced on the stack. - typ := TypeOf(func { i | }) + typ := TypeOf(func { i -> }) var f, g func(in []Value) []Value - f = func { in | + f = func { in -> clobber() i := int(in[0].Int()) if i > 0 { @@ -6888,7 +6888,7 @@ func TestKeepFuncLive(t *testing.T) { } return nil } - g = func { in | + g = func { in -> clobber() i := int(in[0].Int()) MakeFunc(typ, f).Interface().(func(i int))(i) @@ -6974,7 +6974,7 @@ func TestFuncLayout(t *testing.T) { } tests := []test{ { - typ: ValueOf(func { a, b | return "" }).Type(), + typ: ValueOf(func { a, b -> return "" }).Type(), size: 6 * goarch.PtrSize, argsize: 4 * goarch.PtrSize, retOffset: 4 * goarch.PtrSize, @@ -6982,7 +6982,7 @@ func TestFuncLayout(t *testing.T) { gc: []byte{1, 0, 1, 0, 1}, }, { - typ: ValueOf(func { a, b, c, p, d | }).Type(), + typ: ValueOf(func { a, b, c, p, d -> }).Type(), size: align(align(3*4) + goarch.PtrSize + 2), argsize: align(3*4) + goarch.PtrSize + 2, retOffset: align(align(3*4) + goarch.PtrSize + 2), @@ -6990,7 +6990,7 @@ func TestFuncLayout(t *testing.T) { gc: r, }, { - typ: ValueOf(func { a, b, c | }).Type(), + typ: ValueOf(func { a, b, c -> }).Type(), size: 4 * goarch.PtrSize, argsize: 4 * goarch.PtrSize, retOffset: 4 * goarch.PtrSize, @@ -6998,7 +6998,7 @@ func TestFuncLayout(t *testing.T) { gc: []byte{1, 0, 1, 1}, }, { - typ: ValueOf(func { a | }).Type(), + typ: ValueOf(func { a -> }).Type(), size: 4 * goarch.PtrSize, argsize: 4 * goarch.PtrSize, retOffset: 4 * goarch.PtrSize, @@ -7007,7 +7007,7 @@ func TestFuncLayout(t *testing.T) { }, { rcvr: ValueOf((*byte)(nil)).Type(), - typ: ValueOf(func { a, b | }).Type(), + typ: ValueOf(func { a, b -> }).Type(), size: 3 * goarch.PtrSize, argsize: 3 * goarch.PtrSize, retOffset: 3 * goarch.PtrSize, @@ -7015,7 +7015,7 @@ func TestFuncLayout(t *testing.T) { gc: []byte{1, 0, 1}, }, { - typ: ValueOf(func { a | }).Type(), + typ: ValueOf(func { a -> }).Type(), size: goarch.PtrSize, argsize: goarch.PtrSize, retOffset: goarch.PtrSize, @@ -7032,7 +7032,7 @@ func TestFuncLayout(t *testing.T) { }, { rcvr: ValueOf(uintptr(0)).Type(), - typ: ValueOf(func { a | }).Type(), + typ: ValueOf(func { a -> }).Type(), size: 2 * goarch.PtrSize, argsize: 2 * goarch.PtrSize, retOffset: 2 * goarch.PtrSize, @@ -7049,7 +7049,7 @@ func TestFuncLayout(t *testing.T) { if lt.rcvr != nil { name = lt.rcvr.String() + "." + name } - t.Run(name, func { t | + t.Run(name, func { t -> defer SetArgRegs(SetArgRegs(lt.intRegs, lt.floatRegs, lt.floatRegSize)) typ, argsize, retOffset, stack, gc, inRegs, outRegs, ptrs := FuncLayout(lt.typ, lt.rcvr) @@ -8506,7 +8506,7 @@ func TestClear(t *testing.T) { for _, tc := range tests { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Parallel() if !tc.testFunc(tc.value) { t.Errorf("unexpected result for value.Clear(): %v", tc.value) @@ -8540,7 +8540,7 @@ func TestValuePointerAndUnsafePointer(t *testing.T) { for _, tc := range tests { tc := tc - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> if got := tc.val.Pointer(); got != uintptr(tc.wantUnsafePointer) { t.Errorf("unexpected uintptr result, got %#x, want %#x", got, uintptr(tc.wantUnsafePointer)) } diff --git a/src/reflect/benchmark_test.go b/src/reflect/benchmark_test.go index 089d2c1411b86..11fc9620294f3 100644 --- a/src/reflect/benchmark_test.go +++ b/src/reflect/benchmark_test.go @@ -98,7 +98,7 @@ func BenchmarkSliceCap(b *testing.B) { func BenchmarkDeepEqual(b *testing.B) { for _, bb := range deepEqualPerfTests { - b.Run(ValueOf(bb.x).Type().String(), func { b | + b.Run(ValueOf(bb.x).Type().String(), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { sink = DeepEqual(bb.x, bb.y) @@ -148,7 +148,7 @@ func BenchmarkIsZero(b *testing.B) { for i := 0; i < source.NumField(); i++ { name := source.Type().Field(i).Name value := source.Field(i) - b.Run(name, func { b | for i := 0; i < b.N; i++ { + b.Run(name, func { b -> for i := 0; i < b.N; i++ { sink = value.IsZero() } }) } @@ -176,13 +176,13 @@ func BenchmarkSetZero(b *testing.B) { name := source.Type().Field(i).Name value := source.Field(i) zero := Zero(value.Type()) - b.Run(name+"/Direct", func { b | for i := 0; i < b.N; i++ { + b.Run(name+"/Direct", func { b -> for i := 0; i < b.N; i++ { value.SetZero() } }) - b.Run(name+"/CachedZero", func { b | for i := 0; i < b.N; i++ { + b.Run(name+"/CachedZero", func { b -> for i := 0; i < b.N; i++ { value.Set(zero) } }) - b.Run(name+"/NewZero", func { b | for i := 0; i < b.N; i++ { + b.Run(name+"/NewZero", func { b -> for i := 0; i < b.N; i++ { value.Set(Zero(value.Type())) } }) } @@ -199,7 +199,7 @@ func BenchmarkSelect(b *testing.B) { }) } for _, numCases := range []int{1, 4, 8} { - b.Run(strconv.Itoa(numCases), func { b | + b.Run(strconv.Itoa(numCases), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { _, _, _ = Select(cases[:numCases]) @@ -209,9 +209,9 @@ func BenchmarkSelect(b *testing.B) { } func BenchmarkCall(b *testing.B) { - fv := ValueOf(func { a, b | }) + fv := ValueOf(func { a, b -> }) b.ReportAllocs() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> args := []Value{ValueOf("a"), ValueOf("b")} for pb.Next() { fv.Call(args) @@ -243,18 +243,18 @@ func BenchmarkCallArgCopy(b *testing.B) { fv Value arg Value }{ - {ValueOf(func { a | }), byteArray(128)}, - {ValueOf(func { a | }), byteArray(256)}, - {ValueOf(func { a | }), byteArray(1024)}, - {ValueOf(func { a | }), byteArray(4096)}, - {ValueOf(func { a | }), byteArray(65536)}, + {ValueOf(func { a -> }), byteArray(128)}, + {ValueOf(func { a -> }), byteArray(256)}, + {ValueOf(func { a -> }), byteArray(1024)}, + {ValueOf(func { a -> }), byteArray(4096)}, + {ValueOf(func { a -> }), byteArray(65536)}, } for _, size := range sizes { bench := func(b *testing.B) { args := []Value{size.arg} b.SetBytes(int64(size.arg.Len())) b.ResetTimer() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { size.fv.Call(args) } }) } @@ -279,7 +279,7 @@ func BenchmarkPtrTo(b *testing.B) { // Now benchmark calling PointerTo on it: we'll have to hit the ptrMap cache on // every call. - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { PointerTo(t) } }) } @@ -292,21 +292,21 @@ type B1 struct { func BenchmarkFieldByName1(b *testing.B) { t := TypeOf(B1{}) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { t.FieldByName("Z") } }) } func BenchmarkFieldByName2(b *testing.B) { t := TypeOf(S3{}) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { t.FieldByName("B") } }) } func BenchmarkFieldByName3(b *testing.B) { t := TypeOf(R0{}) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { t.FieldByName("X") } }) } @@ -318,7 +318,7 @@ type S struct { func BenchmarkInterfaceBig(b *testing.B) { v := ValueOf(S{}) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { v.Interface() } }) b.StopTimer() @@ -326,14 +326,14 @@ func BenchmarkInterfaceBig(b *testing.B) { func BenchmarkInterfaceSmall(b *testing.B) { v := ValueOf(int64(0)) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { v.Interface() } }) } func BenchmarkNew(b *testing.B) { v := TypeOf(XM{}) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { New(v) } }) } @@ -372,8 +372,8 @@ func BenchmarkMap(b *testing.B) { } for _, tt := range tests { - b.Run(tt.label, func { b | - b.Run("MapIndex", func { b | + b.Run(tt.label, func { b -> + b.Run("MapIndex", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { for j := tt.keys.Len() - 1; j >= 0; j-- { @@ -381,7 +381,7 @@ func BenchmarkMap(b *testing.B) { } } }) - b.Run("SetMapIndex", func { b | + b.Run("SetMapIndex", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { for j := tt.keys.Len() - 1; j >= 0; j-- { diff --git a/src/reflect/iter.go b/src/reflect/iter.go index f7dc12c39707c..b02540e30d0f7 100644 --- a/src/reflect/iter.go +++ b/src/reflect/iter.go @@ -29,7 +29,7 @@ func rangeNum[T int8 | int16 | int32 | int64 | int | func (v Value) Seq() iter.Seq[Value] { if canRangeFunc(v.typ()) { return func(yield func(Value) bool) { - rf := MakeFunc(v.Type().In(0), func { in | return []Value{ValueOf(yield(in[0]))} }) + rf := MakeFunc(v.Type().In(0), func { in -> return []Value{ValueOf(yield(in[0]))} }) v.Call([]Value{rf}) } } @@ -113,7 +113,7 @@ func (v Value) Seq() iter.Seq[Value] { func (v Value) Seq2() iter.Seq2[Value, Value] { if canRangeFunc2(v.typ()) { return func(yield func(Value, Value) bool) { - rf := MakeFunc(v.Type().In(0), func { in | return []Value{ValueOf(yield(in[0], in[1]))} }) + rf := MakeFunc(v.Type().In(0), func { in -> return []Value{ValueOf(yield(in[0], in[1]))} }) v.Call([]Value{rf}) } } diff --git a/src/reflect/iter_test.go b/src/reflect/iter_test.go index db2674e0d326c..7130246fd4d03 100644 --- a/src/reflect/iter_test.go +++ b/src/reflect/iter_test.go @@ -157,7 +157,7 @@ func TestValueSeq(t *testing.T) { t.Fatalf("should loop three times") } }}, - {"func", ValueOf(func { yield | for i := range 4 { + {"func", ValueOf(func { yield -> for i := range 4 { if !yield(i) { return } @@ -275,7 +275,7 @@ func TestValueSeq2(t *testing.T) { t.Fatalf("should loop four times") } }}, - {"func", ValueOf(func { f | for i := range 4 { + {"func", ValueOf(func { f -> for i := range 4 { f(i, i+1) } }), func(t *testing.T, s iter.Seq2[Value, Value]) { i := int64(0) diff --git a/src/reflect/type.go b/src/reflect/type.go index 15eb032658641..8c48a3e7ecd76 100644 --- a/src/reflect/type.go +++ b/src/reflect/type.go @@ -1288,7 +1288,7 @@ func (t *structType) FieldByName(name string) (f StructField, present bool) { if !hasEmbeds { return } - return t.FieldByNameFunc(func { s | return s == name }) + return t.FieldByNameFunc(func { s -> return s == name }) } // TypeOf returns the reflection [Type] that represents the dynamic type of i. @@ -1842,7 +1842,7 @@ func MapOf(key, elem Type) Type { mt.Key = ktyp mt.Elem = etyp mt.Bucket = bucketOf(ktyp, etyp) - mt.Hasher = func { p, seed | return typehash(ktyp, p, seed) } + mt.Hasher = func { p, seed -> return typehash(ktyp, p, seed) } mt.Flags = 0 if ktyp.Size_ > abi.MapMaxKeyBytes { mt.KeySize = uint8(goarch.PtrSize) @@ -2693,7 +2693,7 @@ func StructOf(fields []StructField) Type { } typ.Equal = nil if comparable { - typ.Equal = func { p, q | + typ.Equal = func { p, q -> for _, ft := range typ.Fields { pi := add(p, ft.Offset, "&x.field safe") qi := add(q, ft.Offset, "&x.field safe") @@ -2887,7 +2887,7 @@ func ArrayOf(length int, elem Type) Type { array.Equal = nil if eequal := etyp.Equal; eequal != nil { - array.Equal = func { p, q | + array.Equal = func { p, q -> for i := 0; i < length; i++ { pi := arrayAt(p, i, esize, "i < length") qi := arrayAt(q, i, esize, "i < length") diff --git a/src/reflect/type_test.go b/src/reflect/type_test.go index c61d505ed5dfc..7102e7e2d88e4 100644 --- a/src/reflect/type_test.go +++ b/src/reflect/type_test.go @@ -96,7 +96,7 @@ func TestIsRegularMemory(t *testing.T) { {"struct {_ int32 }", args{reflect.TypeOf(struct{ _ int32 }{})}, false}, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> if got := reflect.IsRegularMemory(tt.args.t); got != tt.want { t.Errorf("isRegularMemory() = %v, want %v", got, tt.want) } @@ -135,7 +135,7 @@ func TestType_CanSeq(t *testing.T) { {"[]int", reflect.TypeOf([]int{}), true}, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> if got := tt.tr.CanSeq(); got != tt.want { t.Errorf("Type.CanSeq() = %v, want %v", got, tt.want) } @@ -160,7 +160,7 @@ func TestType_CanSeq2(t *testing.T) { {"[]int", reflect.TypeOf([]int{}), true}, } for _, tt := range tests { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> if got := tt.tr.CanSeq2(); got != tt.want { t.Errorf("Type.CanSeq2() = %v, want %v", got, tt.want) } diff --git a/src/reflect/visiblefields_test.go b/src/reflect/visiblefields_test.go index 2a00060972cc7..ebb17b888a8cd 100644 --- a/src/reflect/visiblefields_test.go +++ b/src/reflect/visiblefields_test.go @@ -293,7 +293,7 @@ type Rec2 struct { func TestFields(t *testing.T) { for _, test := range fieldsTests { test := test - t.Run(test.testName, func { t | + t.Run(test.testName, func { t -> typ := TypeOf(test.val) fields := VisibleFields(typ) if got, want := len(fields), len(test.expect); got != want { diff --git a/src/regexp/all_test.go b/src/regexp/all_test.go index 864fbd50a4f4f..6e2d98c4e6fff 100644 --- a/src/regexp/all_test.go +++ b/src/regexp/all_test.go @@ -341,7 +341,7 @@ func TestReplaceAllFunc(t *testing.T) { tc.pattern, tc.input, actual, tc.output) } // now try bytes - actual = string(re.ReplaceAllFunc([]byte(tc.input), func { s | return []byte(tc.replacement(string(s))) })) + actual = string(re.ReplaceAllFunc([]byte(tc.input), func { s -> return []byte(tc.replacement(string(s))) })) if actual != tc.output { t.Errorf("%q.ReplaceFunc(%q,fn) = %q; want %q", tc.pattern, tc.input, actual, tc.output) @@ -834,7 +834,7 @@ func BenchmarkMatchParallelShared(b *testing.B) { x := []byte("this is a long line that contains foo bar baz") re := MustCompile("foo (ba+r)? baz") b.ResetTimer() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { re.Match(x) } }) } @@ -843,7 +843,7 @@ func BenchmarkMatchParallelCopied(b *testing.B) { x := []byte("this is a long line that contains foo bar baz") re := MustCompile("foo (ba+r)? baz") b.ResetTimer() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> re := re.Copy() for pb.Next() { re.Match(x) @@ -885,7 +885,7 @@ var compileBenchData = []struct{ name, re string }{ func BenchmarkCompile(b *testing.B) { for _, data := range compileBenchData { - b.Run(data.name, func { b | + b.Run(data.name, func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { if _, err := Compile(data.re); err != nil { @@ -964,7 +964,7 @@ func TestUnmarshalText(t *testing.T) { t.Errorf("UnmarshalText returned unexpected value: %s", unmarshaled.String()) } } - t.Run("invalid pattern", func { t | + t.Run("invalid pattern", func { t -> re := new(Regexp) err := re.UnmarshalText([]byte(`\`)) if err == nil { diff --git a/src/regexp/exec_test.go b/src/regexp/exec_test.go index 676edfa319cce..98f3448ed8c95 100644 --- a/src/regexp/exec_test.go +++ b/src/regexp/exec_test.go @@ -653,7 +653,7 @@ func BenchmarkMatch(b *testing.B) { continue } t := makeText(size.n) - b.Run(data.name+"/"+size.name, func { b | + b.Run(data.name+"/"+size.name, func { b -> b.SetBytes(int64(size.n)) for i := 0; i < b.N; i++ { if r.Match(t) { @@ -676,7 +676,7 @@ func BenchmarkMatch_onepass_regex(b *testing.B) { continue } t := makeText(size.n) - b.Run(size.name, func { b | + b.Run(size.name, func { b -> b.SetBytes(int64(size.n)) b.ReportAllocs() for i := 0; i < b.N; i++ { diff --git a/src/regexp/regexp.go b/src/regexp/regexp.go index d2a52c26d268b..33990ba16b0b2 100644 --- a/src/regexp/regexp.go +++ b/src/regexp/regexp.go @@ -574,7 +574,7 @@ func (re *Regexp) ReplaceAllString(src, repl string) string { if strings.Contains(repl, "$") { n = 2 * (re.numSubexp + 1) } - b := re.replaceAll(nil, src, n, func { dst, match | return re.expand(dst, repl, nil, src, match) }) + b := re.replaceAll(nil, src, n, func { dst, match -> return re.expand(dst, repl, nil, src, match) }) return string(b) } @@ -582,7 +582,7 @@ func (re *Regexp) ReplaceAllString(src, repl string) string { // with the replacement string repl. The replacement repl is substituted directly, // without using [Regexp.Expand]. func (re *Regexp) ReplaceAllLiteralString(src, repl string) string { - return string(re.replaceAll(nil, src, 2, func { dst, match | return append(dst, repl...) })) + return string(re.replaceAll(nil, src, 2, func { dst, match -> return append(dst, repl...) })) } // ReplaceAllStringFunc returns a copy of src in which all matches of the @@ -590,7 +590,7 @@ func (re *Regexp) ReplaceAllLiteralString(src, repl string) string { // to the matched substring. The replacement returned by repl is substituted // directly, without using [Regexp.Expand]. func (re *Regexp) ReplaceAllStringFunc(src string, repl func(string) string) string { - b := re.replaceAll(nil, src, 2, func { dst, match | return append(dst, repl(src[match[0]:match[1]])...) }) + b := re.replaceAll(nil, src, 2, func { dst, match -> return append(dst, repl(src[match[0]:match[1]])...) }) return string(b) } @@ -668,7 +668,7 @@ func (re *Regexp) ReplaceAll(src, repl []byte) []byte { n = 2 * (re.numSubexp + 1) } srepl := "" - b := re.replaceAll(src, "", n, func { dst, match | + b := re.replaceAll(src, "", n, func { dst, match -> if len(srepl) != len(repl) { srepl = string(repl) } @@ -681,7 +681,7 @@ func (re *Regexp) ReplaceAll(src, repl []byte) []byte { // with the replacement bytes repl. The replacement repl is substituted directly, // without using [Regexp.Expand]. func (re *Regexp) ReplaceAllLiteral(src, repl []byte) []byte { - return re.replaceAll(src, "", 2, func { dst, match | return append(dst, repl...) }) + return re.replaceAll(src, "", 2, func { dst, match -> return append(dst, repl...) }) } // ReplaceAllFunc returns a copy of src in which all matches of the @@ -689,7 +689,7 @@ func (re *Regexp) ReplaceAllLiteral(src, repl []byte) []byte { // to the matched byte slice. The replacement returned by repl is substituted // directly, without using [Regexp.Expand]. func (re *Regexp) ReplaceAllFunc(src []byte, repl func([]byte) []byte) []byte { - return re.replaceAll(src, "", 2, func { dst, match | return append(dst, repl(src[match[0]:match[1]])...) }) + return re.replaceAll(src, "", 2, func { dst, match -> return append(dst, repl(src[match[0]:match[1]])...) }) } // Bitmap used by func special to check whether a character needs to be escaped. @@ -1069,7 +1069,7 @@ func (re *Regexp) FindAll(b []byte, n int) [][]byte { n = len(b) + 1 } var result [][]byte - re.allMatches("", b, n, func { match | + re.allMatches("", b, n, func { match -> if result == nil { result = make([][]byte, 0, startSize) } @@ -1087,7 +1087,7 @@ func (re *Regexp) FindAllIndex(b []byte, n int) [][]int { n = len(b) + 1 } var result [][]int - re.allMatches("", b, n, func { match | + re.allMatches("", b, n, func { match -> if result == nil { result = make([][]int, 0, startSize) } @@ -1105,7 +1105,7 @@ func (re *Regexp) FindAllString(s string, n int) []string { n = len(s) + 1 } var result []string - re.allMatches(s, nil, n, func { match | + re.allMatches(s, nil, n, func { match -> if result == nil { result = make([]string, 0, startSize) } @@ -1123,7 +1123,7 @@ func (re *Regexp) FindAllStringIndex(s string, n int) [][]int { n = len(s) + 1 } var result [][]int - re.allMatches(s, nil, n, func { match | + re.allMatches(s, nil, n, func { match -> if result == nil { result = make([][]int, 0, startSize) } @@ -1141,7 +1141,7 @@ func (re *Regexp) FindAllSubmatch(b []byte, n int) [][][]byte { n = len(b) + 1 } var result [][][]byte - re.allMatches("", b, n, func { match | + re.allMatches("", b, n, func { match -> if result == nil { result = make([][][]byte, 0, startSize) } @@ -1165,7 +1165,7 @@ func (re *Regexp) FindAllSubmatchIndex(b []byte, n int) [][]int { n = len(b) + 1 } var result [][]int - re.allMatches("", b, n, func { match | + re.allMatches("", b, n, func { match -> if result == nil { result = make([][]int, 0, startSize) } @@ -1183,7 +1183,7 @@ func (re *Regexp) FindAllStringSubmatch(s string, n int) [][]string { n = len(s) + 1 } var result [][]string - re.allMatches(s, nil, n, func { match | + re.allMatches(s, nil, n, func { match -> if result == nil { result = make([][]string, 0, startSize) } @@ -1208,7 +1208,7 @@ func (re *Regexp) FindAllStringSubmatchIndex(s string, n int) [][]int { n = len(s) + 1 } var result [][]int - re.allMatches(s, nil, n, func { match | + re.allMatches(s, nil, n, func { match -> if result == nil { result = make([][]int, 0, startSize) } diff --git a/src/regexp/syntax/parse.go b/src/regexp/syntax/parse.go index 0d620d4af4c53..38c68a7c2a149 100644 --- a/src/regexp/syntax/parse.go +++ b/src/regexp/syntax/parse.go @@ -1860,7 +1860,7 @@ func cleanClass(rp *[]rune) []rune { // inCharClass reports whether r is in the class. // It assumes the class has been cleaned by cleanClass. func inCharClass(r rune, class []rune) bool { - _, ok := sort.Find(len(class)/2, func { i | + _, ok := sort.Find(len(class)/2, func { i -> lo, hi := class[2*i], class[2*i+1] if r > hi { return +1 diff --git a/src/runtime/abi_test.go b/src/runtime/abi_test.go index 3c034290dd9fc..174081f604c39 100644 --- a/src/runtime/abi_test.go +++ b/src/runtime/abi_test.go @@ -95,7 +95,7 @@ func TestFinalizerRegisterABI(t *testing.T) { } for i := range tests { test := &tests[i] - t.Run(test.name, func { t | + t.Run(test.name, func { t -> x := &TintPointer{p: new(Tint)} *x.p = (Tint)(test.confirmValue) runtime.SetFinalizer(x, test.fin) diff --git a/src/runtime/arena.go b/src/runtime/arena.go index a23b7af0f8f88..6afff41a24e8a 100644 --- a/src/runtime/arena.go +++ b/src/runtime/arena.go @@ -261,7 +261,7 @@ type userArena struct { // newUserArena creates a new userArena ready to be used. func newUserArena() *userArena { a := new(userArena) - SetFinalizer(a, func { a | + SetFinalizer(a, func { a -> // If arena handle is dropped without being freed, then call // free on the arena, so the arena chunks are never reclaimed // by the garbage collector. diff --git a/src/runtime/arena_test.go b/src/runtime/arena_test.go index fcb6cfe8ee3fd..058e3a75cc71d 100644 --- a/src/runtime/arena_test.go +++ b/src/runtime/arena_test.go @@ -41,7 +41,7 @@ func TestUserArena(t *testing.T) { defer GOMAXPROCS(GOMAXPROCS(2)) // Start a subtest so that we can clean up after any parallel tests within. - t.Run("Alloc", func { t | + t.Run("Alloc", func { t -> ss := &smallScalar{5} runSubTestUserArenaNew(t, ss, true) @@ -109,7 +109,7 @@ func TestUserArena(t *testing.T) { runSubTestUserArenaSlice(t, sps, false) // Test zero-sized types. - t.Run("struct{}", func { t | + t.Run("struct{}", func { t -> arena := NewUserArena() var x any x = (*struct{})(nil) @@ -119,7 +119,7 @@ func TestUserArena(t *testing.T) { } arena.Free() }) - t.Run("[]struct{}", func { t | + t.Run("[]struct{}", func { t -> arena := NewUserArena() var sl []struct{} arena.Slice(&sl, 10) @@ -128,7 +128,7 @@ func TestUserArena(t *testing.T) { } arena.Free() }) - t.Run("[]int (cap 0)", func { t | + t.Run("[]int (cap 0)", func { t -> arena := NewUserArena() var sl []int arena.Slice(&sl, 0) @@ -148,7 +148,7 @@ func TestUserArena(t *testing.T) { } func runSubTestUserArenaNew[S comparable](t *testing.T, value *S, parallel bool) { - t.Run(reflect.TypeOf(value).Elem().Name(), func { t | + t.Run(reflect.TypeOf(value).Elem().Name(), func { t -> if parallel { t.Parallel() } @@ -187,7 +187,7 @@ func runSubTestUserArenaNew[S comparable](t *testing.T, value *S, parallel bool) } func runSubTestUserArenaSlice[S comparable](t *testing.T, value []S, parallel bool) { - t.Run("[]"+reflect.TypeOf(value).Elem().Name(), func { t | + t.Run("[]"+reflect.TypeOf(value).Elem().Name(), func { t -> if parallel { t.Parallel() } @@ -228,8 +228,8 @@ func runSubTestUserArenaSlice[S comparable](t *testing.T, value []S, parallel bo } func TestUserArenaLiveness(t *testing.T) { - t.Run("Free", func { t | testUserArenaLiveness(t, false) }) - t.Run("Finalizer", func { t | testUserArenaLiveness(t, true) }) + t.Run("Free", func { t -> testUserArenaLiveness(t, false) }) + t.Run("Finalizer", func { t -> testUserArenaLiveness(t, true) }) } func testUserArenaLiveness(t *testing.T, useArenaFinalizer bool) { @@ -259,7 +259,7 @@ func testUserArenaLiveness(t *testing.T, useArenaFinalizer bool) { var safeToFinalize atomic.Bool var finalized atomic.Bool v.C = new(smallPointer) - SetFinalizer(v.C, func { _ | + SetFinalizer(v.C, func { _ -> if !safeToFinalize.Load() { t.Error("finalized arena-referenced object unexpectedly") } @@ -324,7 +324,7 @@ func TestUserArenaClearsPointerBits(t *testing.T) { x := new([8 << 20]byte) xp := uintptr(unsafe.Pointer(&x[124])) var finalized atomic.Bool - SetFinalizer(x, func { _ | finalized.Store(true) }) + SetFinalizer(x, func { _ -> finalized.Store(true) }) // Write three chunks worth of pointer data. Three gives us a // high likelihood that when we write 2 later, we'll get the behavior diff --git a/src/runtime/callers_test.go b/src/runtime/callers_test.go index 69486d489ae8d..37c7c2d25ba9d 100644 --- a/src/runtime/callers_test.go +++ b/src/runtime/callers_test.go @@ -341,13 +341,13 @@ func callerLine(t *testing.T, skip int) int { } func BenchmarkCallers(b *testing.B) { - b.Run("cached", func { b | + b.Run("cached", func { b -> // Very pcvalueCache-friendly, no inlining. callersCached(b, 100) }) - b.Run("inlined", func { b | + b.Run("inlined", func { b -> // Some inlining, still pretty cache-friendly. callersInlined(b, 100) }) - b.Run("no-cache", func { b | + b.Run("no-cache", func { b -> // Cache-hostile callersNoCache(b, 100) }) } @@ -429,7 +429,7 @@ func callersNoCache(b *testing.B, n int) int { } func BenchmarkFPCallers(b *testing.B) { - b.Run("cached", func { b | + b.Run("cached", func { b -> // Very pcvalueCache-friendly, no inlining. fpCallersCached(b, 100) }) } diff --git a/src/runtime/cgo/handle_test.go b/src/runtime/cgo/handle_test.go index f2436b7072077..5d25b608685c6 100644 --- a/src/runtime/cgo/handle_test.go +++ b/src/runtime/cgo/handle_test.go @@ -44,7 +44,7 @@ func TestHandle(t *testing.T) { } siz := 0 - handles.Range(func { k, v | + handles.Range(func { k, v -> siz++ return true }) @@ -54,7 +54,7 @@ func TestHandle(t *testing.T) { } func TestInvalidHandle(t *testing.T) { - t.Run("zero", func { t | + t.Run("zero", func { t -> h := Handle(0) defer func() { @@ -67,7 +67,7 @@ func TestInvalidHandle(t *testing.T) { h.Delete() }) - t.Run("invalid", func { t | + t.Run("invalid", func { t -> h := NewHandle(42) defer func() { @@ -83,13 +83,13 @@ func TestInvalidHandle(t *testing.T) { } func BenchmarkHandle(b *testing.B) { - b.Run("non-concurrent", func { b | for i := 0; i < b.N; i++ { + b.Run("non-concurrent", func { b -> for i := 0; i < b.N; i++ { h := NewHandle(i) _ = h.Value() h.Delete() } }) - b.Run("concurrent", func { b | - b.RunParallel(func { pb | + b.Run("concurrent", func { b -> + b.RunParallel(func { pb -> var v int for pb.Next() { h := NewHandle(v) diff --git a/src/runtime/chan_test.go b/src/runtime/chan_test.go index 3b6756b0662c2..af24ad50761fa 100644 --- a/src/runtime/chan_test.go +++ b/src/runtime/chan_test.go @@ -786,43 +786,43 @@ func TestSelectStackAdjust(t *testing.T) { type struct0 struct{} func BenchmarkMakeChan(b *testing.B) { - b.Run("Byte", func { b | + b.Run("Byte", func { b -> var x chan byte for i := 0; i < b.N; i++ { x = make(chan byte, 8) } close(x) }) - b.Run("Int", func { b | + b.Run("Int", func { b -> var x chan int for i := 0; i < b.N; i++ { x = make(chan int, 8) } close(x) }) - b.Run("Ptr", func { b | + b.Run("Ptr", func { b -> var x chan *byte for i := 0; i < b.N; i++ { x = make(chan *byte, 8) } close(x) }) - b.Run("Struct", func { b | - b.Run("0", func { b | + b.Run("Struct", func { b -> + b.Run("0", func { b -> var x chan struct0 for i := 0; i < b.N; i++ { x = make(chan struct0, 8) } close(x) }) - b.Run("32", func { b | + b.Run("32", func { b -> var x chan struct32 for i := 0; i < b.N; i++ { x = make(chan struct32, 8) } close(x) }) - b.Run("40", func { b | + b.Run("40", func { b -> var x chan struct40 for i := 0; i < b.N; i++ { x = make(chan struct40, 8) @@ -834,7 +834,7 @@ func BenchmarkMakeChan(b *testing.B) { func BenchmarkChanNonblocking(b *testing.B) { myc := make(chan int) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { select { case <-myc: default: @@ -843,7 +843,7 @@ func BenchmarkChanNonblocking(b *testing.B) { } func BenchmarkSelectUncontended(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> myc1 := make(chan int, 1) myc2 := make(chan int, 1) myc1 <- 0 @@ -863,7 +863,7 @@ func BenchmarkSelectSyncContended(b *testing.B) { myc2 := make(chan int) myc3 := make(chan int) done := make(chan int) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> go func() { for { select { @@ -890,7 +890,7 @@ func BenchmarkSelectAsyncContended(b *testing.B) { procs := runtime.GOMAXPROCS(0) myc1 := make(chan int, procs) myc2 := make(chan int, procs) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> myc1 <- 0 for pb.Next() { select { @@ -908,7 +908,7 @@ func BenchmarkSelectNonblock(b *testing.B) { myc2 := make(chan int) myc3 := make(chan int, 1) myc4 := make(chan int, 1) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { select { case <-myc1: @@ -932,7 +932,7 @@ func BenchmarkSelectNonblock(b *testing.B) { func BenchmarkChanUncontended(b *testing.B) { const C = 100 - b.RunParallel(func { pb | + b.RunParallel(func { pb -> myc := make(chan int, C) for pb.Next() { for i := 0; i < C; i++ { @@ -948,7 +948,7 @@ func BenchmarkChanUncontended(b *testing.B) { func BenchmarkChanContended(b *testing.B) { const C = 100 myc := make(chan int, C*runtime.GOMAXPROCS(0)) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { for i := 0; i < C; i++ { myc <- 0 @@ -1143,7 +1143,7 @@ func BenchmarkReceiveDataFromClosedChan(b *testing.B) { } func BenchmarkChanCreation(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { myc := make(chan int, 1) myc <- 0 <-myc @@ -1153,7 +1153,7 @@ func BenchmarkChanCreation(b *testing.B) { func BenchmarkChanSem(b *testing.B) { type Empty struct{} myc := make(chan Empty, runtime.GOMAXPROCS(0)) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { myc <- Empty{} <-myc } }) @@ -1189,7 +1189,7 @@ func BenchmarkChanPopular(b *testing.B) { func BenchmarkChanClosed(b *testing.B) { c := make(chan struct{}) close(c) - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { select { case <-c: default: diff --git a/src/runtime/checkptr_test.go b/src/runtime/checkptr_test.go index f5518a64c4643..07a016d34ddbc 100644 --- a/src/runtime/checkptr_test.go +++ b/src/runtime/checkptr_test.go @@ -45,7 +45,7 @@ func TestCheckPtr(t *testing.T) { for _, tc := range testCases { tc := tc - t.Run(tc.cmd, func { t | + t.Run(tc.cmd, func { t -> t.Parallel() got, err := testenv.CleanCmdEnv(exec.Command(exe, tc.cmd)).CombinedOutput() if err != nil { @@ -88,7 +88,7 @@ func TestCheckPtr2(t *testing.T) { for _, tc := range testCases { tc := tc - t.Run(tc.cmd, func { t | + t.Run(tc.cmd, func { t -> t.Parallel() got, err := testenv.CleanCmdEnv(exec.Command(exe, tc.cmd)).CombinedOutput() if err != nil { diff --git a/src/runtime/coro_test.go b/src/runtime/coro_test.go index e2b0c437d7652..d9a5890018de1 100644 --- a/src/runtime/coro_test.go +++ b/src/runtime/coro_test.go @@ -24,7 +24,7 @@ func TestCoroLockOSThread(t *testing.T) { "CoroLockOSThreadStopLocked", "CoroLockOSThreadStopLockedIterNested", } { - t.Run(test, func { t | checkCoroTestProgOutput(t, runTestProg(t, "testprog", test)) }) + t.Run(test, func { t -> checkCoroTestProgOutput(t, runTestProg(t, "testprog", test)) }) } } @@ -44,7 +44,7 @@ func TestCoroCgoCallback(t *testing.T) { "CoroCgoStopCallback", "CoroCgoStopCallbackIterNested", } { - t.Run(test, func { t | checkCoroTestProgOutput(t, runTestProg(t, "testprogcgo", test)) }) + t.Run(test, func { t -> checkCoroTestProgOutput(t, runTestProg(t, "testprogcgo", test)) }) } } diff --git a/src/runtime/crash_cgo_test.go b/src/runtime/crash_cgo_test.go index 0276601158918..1ac5b009829f7 100644 --- a/src/runtime/crash_cgo_test.go +++ b/src/runtime/crash_cgo_test.go @@ -642,7 +642,7 @@ func TestSegv(t *testing.T) { continue } - t.Run(test, func { t | + t.Run(test, func { t -> if test == "SegvInCgo" && runtime.GOOS == "ios" { testenv.SkipFlaky(t, 59947) // Don't even try, in case it times out. } diff --git a/src/runtime/crash_unix_test.go b/src/runtime/crash_unix_test.go index 0b2b84a4da570..bee669df3556b 100644 --- a/src/runtime/crash_unix_test.go +++ b/src/runtime/crash_unix_test.go @@ -305,7 +305,7 @@ func TestSignalM(t *testing.T) { wg.Add(1) go func() { runtime.LockOSThread() - want, got = runtime.WaitForSigusr1(r, w, func { mp | ready <- mp }) + want, got = runtime.WaitForSigusr1(r, w, func { mp -> ready <- mp }) runtime.UnlockOSThread() wg.Done() }() diff --git a/src/runtime/debug/mod.go b/src/runtime/debug/mod.go index a03d6f389c01a..bb3a78ccadf75 100644 --- a/src/runtime/debug/mod.go +++ b/src/runtime/debug/mod.go @@ -110,7 +110,7 @@ func (bi *BuildInfo) String() string { fmt.Fprintf(buf, "path\t%s\n", bi.Path) } var formatMod func(string, Module) - formatMod = func { word, m | + formatMod = func { word, m -> buf.WriteString(word) buf.WriteByte('\t') buf.WriteString(m.Path) diff --git a/src/runtime/debug/mod_test.go b/src/runtime/debug/mod_test.go index 89fdf02f36b9f..ec452e10df958 100644 --- a/src/runtime/debug/mod_test.go +++ b/src/runtime/debug/mod_test.go @@ -52,7 +52,7 @@ func FuzzParseBuildInfoRoundTrip(f *testing.F) { build CRAZY_ENV="requires\nescaping" `)) - f.Fuzz(func { t, s | + f.Fuzz(func { t, s -> bi, err := debug.ParseBuildInfo(s) if err != nil { // Not a round-trippable BuildInfo string. diff --git a/src/runtime/debugcall.go b/src/runtime/debugcall.go index c035ce99d0319..63b82a54e4749 100644 --- a/src/runtime/debugcall.go +++ b/src/runtime/debugcall.go @@ -160,7 +160,7 @@ func debugCallWrap(dispatch uintptr) { }) // Switch to the new goroutine. - mcall(func { gp | + mcall(func { gp -> // Get newg. newg := gp.schedlink.ptr() gp.schedlink = 0 @@ -218,7 +218,7 @@ func debugCallWrap1() { // Resume the caller goroutine. getg().schedlink.set(callingG) - mcall(func { gp | + mcall(func { gp -> callingG := gp.schedlink.ptr() gp.schedlink = 0 diff --git a/src/runtime/env_plan9.go b/src/runtime/env_plan9.go index a84c30281ee31..54e18efaff9d5 100644 --- a/src/runtime/env_plan9.go +++ b/src/runtime/env_plan9.go @@ -35,7 +35,7 @@ func goenvs() { return } defer closefd(dirfd) - dofiles(dirfd, func { name | + dofiles(dirfd, func { name -> name = append(name, 0) buf = buf[:len(envDir)] copy(buf, envDir) diff --git a/src/runtime/gc_test.go b/src/runtime/gc_test.go index b36984a79b7b0..3290c3742b2e7 100644 --- a/src/runtime/gc_test.go +++ b/src/runtime/gc_test.go @@ -490,7 +490,7 @@ func applyGCLoad(b *testing.B) func() { children [16]*node } var buildTree func(depth int) *node - buildTree = func { depth | + buildTree = func { depth -> tree := new(node) if depth != 0 { for i := range tree.children { @@ -619,7 +619,7 @@ func BenchmarkWriteBarrier(b *testing.B) { } var wbRoots []*node var mkTree func(level int) *node - mkTree = func { level | + mkTree = func { level -> if level == 0 { return nil } @@ -733,7 +733,7 @@ func BenchmarkMSpanCountAlloc(b *testing.B) { // n must always be a multiple of 8, since gcBits is // always rounded up 8 bytes. for _, n := range []int{8, 16, 32, 64, 128} { - b.Run(fmt.Sprintf("bits=%d", n*8), func { b | + b.Run(fmt.Sprintf("bits=%d", n*8), func { b -> // Initialize a new byte slice with pseduo-random data. bits := make([]byte, n) rand.Read(bits) diff --git a/src/runtime/heapdump.go b/src/runtime/heapdump.go index 3c825a928d9c8..a15efbbb39702 100644 --- a/src/runtime/heapdump.go +++ b/src/runtime/heapdump.go @@ -408,7 +408,7 @@ func dumpgs() { assertWorldStopped() // goroutines & stacks - forEachG(func { gp | + forEachG(func { gp -> status := readgstatus(gp) // The world is stopped so gp will not be in a scan state. switch status { default: diff --git a/src/runtime/iface_test.go b/src/runtime/iface_test.go index 780dcf2839629..87cf1eb807c8c 100644 --- a/src/runtime/iface_test.go +++ b/src/runtime/iface_test.go @@ -96,10 +96,10 @@ func BenchmarkNeIfaceConcrete(b *testing.B) { } func BenchmarkConvT2EByteSized(b *testing.B) { - b.Run("bool", func { b | for i := 0; i < b.N; i++ { + b.Run("bool", func { b -> for i := 0; i < b.N; i++ { e = yes } }) - b.Run("uint8", func { b | for i := 0; i < b.N; i++ { + b.Run("uint8", func { b -> for i := 0; i < b.N; i++ { e = eight8 } }) } @@ -307,7 +307,7 @@ func TestZeroConvT2x(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> n := testing.AllocsPerRun(1000, test.fn) if n != 0 { t.Errorf("want zero allocs, got %v", n) @@ -349,56 +349,56 @@ var ( ) func BenchmarkConvT2Ezero(b *testing.B) { - b.Run("zero", func { b | - b.Run("16", func { b | for i := 0; i < b.N; i++ { + b.Run("zero", func { b -> + b.Run("16", func { b -> for i := 0; i < b.N; i++ { e = zero16 } }) - b.Run("32", func { b | for i := 0; i < b.N; i++ { + b.Run("32", func { b -> for i := 0; i < b.N; i++ { e = zero32 } }) - b.Run("64", func { b | for i := 0; i < b.N; i++ { + b.Run("64", func { b -> for i := 0; i < b.N; i++ { e = zero64 } }) - b.Run("str", func { b | for i := 0; i < b.N; i++ { + b.Run("str", func { b -> for i := 0; i < b.N; i++ { e = zerostr } }) - b.Run("slice", func { b | for i := 0; i < b.N; i++ { + b.Run("slice", func { b -> for i := 0; i < b.N; i++ { e = zeroslice } }) - b.Run("big", func { b | for i := 0; i < b.N; i++ { + b.Run("big", func { b -> for i := 0; i < b.N; i++ { e = zerobig } }) }) - b.Run("nonzero", func { b | - b.Run("str", func { b | for i := 0; i < b.N; i++ { + b.Run("nonzero", func { b -> + b.Run("str", func { b -> for i := 0; i < b.N; i++ { e = nzstr } }) - b.Run("slice", func { b | for i := 0; i < b.N; i++ { + b.Run("slice", func { b -> for i := 0; i < b.N; i++ { e = nzslice } }) - b.Run("big", func { b | for i := 0; i < b.N; i++ { + b.Run("big", func { b -> for i := 0; i < b.N; i++ { e = nzbig } }) }) - b.Run("smallint", func { b | - b.Run("16", func { b | for i := 0; i < b.N; i++ { + b.Run("smallint", func { b -> + b.Run("16", func { b -> for i := 0; i < b.N; i++ { e = one16 } }) - b.Run("32", func { b | for i := 0; i < b.N; i++ { + b.Run("32", func { b -> for i := 0; i < b.N; i++ { e = one32 } }) - b.Run("64", func { b | for i := 0; i < b.N; i++ { + b.Run("64", func { b -> for i := 0; i < b.N; i++ { e = one64 } }) }) - b.Run("largeint", func { b | - b.Run("16", func { b | for i := 0; i < b.N; i++ { + b.Run("largeint", func { b -> + b.Run("16", func { b -> for i := 0; i < b.N; i++ { e = thousand16 } }) - b.Run("32", func { b | for i := 0; i < b.N; i++ { + b.Run("32", func { b -> for i := 0; i < b.N; i++ { e = thousand32 } }) - b.Run("64", func { b | for i := 0; i < b.N; i++ { + b.Run("64", func { b -> for i := 0; i < b.N; i++ { e = thousand64 } }) }) diff --git a/src/runtime/internal/math/math_test.go b/src/runtime/internal/math/math_test.go index 79162a8a55e1f..044b92461af49 100644 --- a/src/runtime/internal/math/math_test.go +++ b/src/runtime/internal/math/math_test.go @@ -57,7 +57,7 @@ var x, y uintptr func BenchmarkMulUintptr(b *testing.B) { x, y = 1, 2 - b.Run("small", func { b | + b.Run("small", func { b -> for i := 0; i < b.N; i++ { var overflow bool SinkUintptr, overflow = MulUintptr(x, y) @@ -67,7 +67,7 @@ func BenchmarkMulUintptr(b *testing.B) { } }) x, y = MaxUintptr, MaxUintptr-1 - b.Run("large", func { b | + b.Run("large", func { b -> for i := 0; i < b.N; i++ { var overflow bool SinkUintptr, overflow = MulUintptr(x, y) diff --git a/src/runtime/internal/wasitest/nonblock_test.go b/src/runtime/internal/wasitest/nonblock_test.go index 70dbfab944673..5ec25658e66ff 100644 --- a/src/runtime/internal/wasitest/nonblock_test.go +++ b/src/runtime/internal/wasitest/nonblock_test.go @@ -42,7 +42,7 @@ func TestNonblock(t *testing.T) { } for _, mode := range []string{"os.OpenFile", "os.NewFile"} { - t.Run(mode, func { t | + t.Run(mode, func { t -> args := []string{"run", "./testdata/nonblock.go", mode} fifos := make([]*fifo, 8) diff --git a/src/runtime/map_benchmark_test.go b/src/runtime/map_benchmark_test.go index 114a668281efd..f3fc8a165082d 100644 --- a/src/runtime/map_benchmark_test.go +++ b/src/runtime/map_benchmark_test.go @@ -219,7 +219,7 @@ func BenchmarkIntMap(b *testing.B) { func BenchmarkMapFirst(b *testing.B) { for n := 1; n <= 16; n++ { - b.Run(fmt.Sprintf("%d", n), func { b | + b.Run(fmt.Sprintf("%d", n), func { b -> m := make(map[int]bool) for i := 0; i < n; i++ { m[i] = true @@ -233,7 +233,7 @@ func BenchmarkMapFirst(b *testing.B) { } func BenchmarkMapMid(b *testing.B) { for n := 1; n <= 16; n++ { - b.Run(fmt.Sprintf("%d", n), func { b | + b.Run(fmt.Sprintf("%d", n), func { b -> m := make(map[int]bool) for i := 0; i < n; i++ { m[i] = true @@ -247,7 +247,7 @@ func BenchmarkMapMid(b *testing.B) { } func BenchmarkMapLast(b *testing.B) { for n := 1; n <= 16; n++ { - b.Run(fmt.Sprintf("%d", n), func { b | + b.Run(fmt.Sprintf("%d", n), func { b -> m := make(map[int]bool) for i := 0; i < n; i++ { m[i] = true @@ -301,14 +301,14 @@ func BenchmarkRepeatedLookupStrMapKey32(b *testing.B) { benchmarkRepeatedLookup( func BenchmarkRepeatedLookupStrMapKey1M(b *testing.B) { benchmarkRepeatedLookup(b, 1<<20) } func BenchmarkMakeMap(b *testing.B) { - b.Run("[Byte]Byte", func { b | + b.Run("[Byte]Byte", func { b -> var m map[byte]byte for i := 0; i < b.N; i++ { m = make(map[byte]byte, 10) } hugeSink = m }) - b.Run("[Int]Int", func { b | + b.Run("[Int]Int", func { b -> var m map[int]int for i := 0; i < b.N; i++ { m = make(map[int]int, 10) @@ -400,7 +400,7 @@ func BenchmarkSmallKeyMap(b *testing.B) { func BenchmarkMapPopulate(b *testing.B) { for size := 1; size < 1000000; size *= 10 { - b.Run(strconv.Itoa(size), func { b | + b.Run(strconv.Itoa(size), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { m := make(map[int]bool) @@ -432,9 +432,9 @@ func BenchmarkComplexAlgMap(b *testing.B) { } func BenchmarkGoMapClear(b *testing.B) { - b.Run("Reflexive", func { b | + b.Run("Reflexive", func { b -> for size := 1; size < 100000; size *= 10 { - b.Run(strconv.Itoa(size), func { b | + b.Run(strconv.Itoa(size), func { b -> m := make(map[int]int, size) for i := 0; i < b.N; i++ { m[0] = size // Add one element so len(m) != 0 avoiding fast paths. @@ -443,9 +443,9 @@ func BenchmarkGoMapClear(b *testing.B) { }) } }) - b.Run("NonReflexive", func { b | + b.Run("NonReflexive", func { b -> for size := 1; size < 100000; size *= 10 { - b.Run(strconv.Itoa(size), func { b | + b.Run(strconv.Itoa(size), func { b -> m := make(map[float64]int, size) for i := 0; i < b.N; i++ { m[1.0] = size // Add one element so len(m) != 0 avoiding fast paths. @@ -458,9 +458,9 @@ func BenchmarkGoMapClear(b *testing.B) { func BenchmarkMapStringConversion(b *testing.B) { for _, length := range []int{32, 64} { - b.Run(strconv.Itoa(length), func { b | + b.Run(strconv.Itoa(length), func { b -> bytes := make([]byte, length) - b.Run("simple", func { b | + b.Run("simple", func { b -> b.ReportAllocs() m := make(map[string]int) m[string(bytes)] = 0 @@ -468,7 +468,7 @@ func BenchmarkMapStringConversion(b *testing.B) { _ = m[string(bytes)] } }) - b.Run("struct", func { b | + b.Run("struct", func { b -> b.ReportAllocs() type stringstruct struct{ s string } m := make(map[stringstruct]int) @@ -477,7 +477,7 @@ func BenchmarkMapStringConversion(b *testing.B) { _ = m[stringstruct{string(bytes)}] } }) - b.Run("array", func { b | + b.Run("array", func { b -> b.ReportAllocs() type stringarray [1]string m := make(map[stringarray]int) diff --git a/src/runtime/map_test.go b/src/runtime/map_test.go index f43e10519d4fb..bf225a801ca76 100644 --- a/src/runtime/map_test.go +++ b/src/runtime/map_test.go @@ -721,7 +721,7 @@ func TestMapBuckets(t *testing.T) { // on the stack. Escaping maps start with a non-nil bucket pointer if // hint size is above bucketCnt and thereby have more than one bucket. // These tests depend on bucketCnt and loadFactor* in map.go. - t.Run("mapliteral", func { t | + t.Run("mapliteral", func { t -> for _, tt := range mapBucketTests { localMap := map[int]int{} if runtime.MapBucketsPointerIsNil(localMap) { @@ -745,7 +745,7 @@ func TestMapBuckets(t *testing.T) { } } }) - t.Run("nohint", func { t | + t.Run("nohint", func { t -> for _, tt := range mapBucketTests { localMap := make(map[int]int) if runtime.MapBucketsPointerIsNil(localMap) { @@ -769,7 +769,7 @@ func TestMapBuckets(t *testing.T) { } } }) - t.Run("makemap", func { t | + t.Run("makemap", func { t -> for _, tt := range mapBucketTests { localMap := make(map[int]int, tt.n) if runtime.MapBucketsPointerIsNil(localMap) { @@ -793,7 +793,7 @@ func TestMapBuckets(t *testing.T) { } } }) - t.Run("makemap64", func { t | + t.Run("makemap64", func { t -> for _, tt := range mapBucketTests { localMap := make(map[int]int, int64(tt.n)) if runtime.MapBucketsPointerIsNil(localMap) { @@ -1037,7 +1037,7 @@ func benchmarkMapDeletePointer(b *testing.B, n int) { func runWith(f func(*testing.B, int), v ...int) func(*testing.B) { return func(b *testing.B) { for _, n := range v { - b.Run(strconv.Itoa(n), func { b | f(b, n) }) + b.Run(strconv.Itoa(n), func { b -> f(b, n) }) } } } @@ -1509,7 +1509,7 @@ func TestMemHashGlobalSeed(t *testing.T) { // aeshash and memhashFallback use separate per-process seeds, so test // both. - t.Run("aes", func { t | + t.Run("aes", func { t -> if !*runtime.UseAeshash { t.Skip("No AES") } @@ -1526,7 +1526,7 @@ func TestMemHashGlobalSeed(t *testing.T) { } }) - t.Run("noaes", func { t | + t.Run("noaes", func { t -> env := "" if *runtime.UseAeshash { env = "GODEBUG=cpu.aes=off" diff --git a/src/runtime/memmove_test.go b/src/runtime/memmove_test.go index cec77ec576ae1..38866ee8bc177 100644 --- a/src/runtime/memmove_test.go +++ b/src/runtime/memmove_test.go @@ -229,7 +229,7 @@ func TestMemmoveAtomicity(t *testing.T) { } else { name += "-forward" } - t.Run(name, func { t | + t.Run(name, func { t -> // Use overlapping src and dst to force forward/backward copy. var s [100]*int src := s[n-1 : 2*n-1] @@ -273,7 +273,7 @@ func TestMemmoveAtomicity(t *testing.T) { func benchmarkSizes(b *testing.B, sizes []int, fn func(b *testing.B, n int)) { for _, n := range sizes { - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n)) fn(b, n) }) @@ -289,7 +289,7 @@ var bufSizesOverlap = []int{ } func BenchmarkMemmove(b *testing.B) { - benchmarkSizes(b, bufSizes, func { b, n | + benchmarkSizes(b, bufSizes, func { b, n -> x := make([]byte, n) y := make([]byte, n) for i := 0; i < b.N; i++ { @@ -299,7 +299,7 @@ func BenchmarkMemmove(b *testing.B) { } func BenchmarkMemmoveOverlap(b *testing.B) { - benchmarkSizes(b, bufSizesOverlap, func { b, n | + benchmarkSizes(b, bufSizesOverlap, func { b, n -> x := make([]byte, n+16) for i := 0; i < b.N; i++ { copy(x[16:n+16], x[:n]) @@ -308,7 +308,7 @@ func BenchmarkMemmoveOverlap(b *testing.B) { } func BenchmarkMemmoveUnalignedDst(b *testing.B) { - benchmarkSizes(b, bufSizes, func { b, n | + benchmarkSizes(b, bufSizes, func { b, n -> x := make([]byte, n+1) y := make([]byte, n) for i := 0; i < b.N; i++ { @@ -318,7 +318,7 @@ func BenchmarkMemmoveUnalignedDst(b *testing.B) { } func BenchmarkMemmoveUnalignedDstOverlap(b *testing.B) { - benchmarkSizes(b, bufSizesOverlap, func { b, n | + benchmarkSizes(b, bufSizesOverlap, func { b, n -> x := make([]byte, n+16) for i := 0; i < b.N; i++ { copy(x[16:n+16], x[1:n+1]) @@ -327,7 +327,7 @@ func BenchmarkMemmoveUnalignedDstOverlap(b *testing.B) { } func BenchmarkMemmoveUnalignedSrc(b *testing.B) { - benchmarkSizes(b, bufSizes, func { b, n | + benchmarkSizes(b, bufSizes, func { b, n -> x := make([]byte, n) y := make([]byte, n+1) for i := 0; i < b.N; i++ { @@ -342,14 +342,14 @@ func BenchmarkMemmoveUnalignedSrcDst(b *testing.B) { x := buf[:len(buf)/2] y := buf[len(buf)/2:] for _, off := range []int{0, 1, 4, 7} { - b.Run(fmt.Sprint("f_", n, off), func { b | + b.Run(fmt.Sprint("f_", n, off), func { b -> b.SetBytes(int64(n)) for i := 0; i < b.N; i++ { copy(x[off:n+off], y[off:n+off]) } }) - b.Run(fmt.Sprint("b_", n, off), func { b | + b.Run(fmt.Sprint("b_", n, off), func { b -> b.SetBytes(int64(n)) for i := 0; i < b.N; i++ { copy(y[off:n+off], x[off:n+off]) @@ -360,7 +360,7 @@ func BenchmarkMemmoveUnalignedSrcDst(b *testing.B) { } func BenchmarkMemmoveUnalignedSrcOverlap(b *testing.B) { - benchmarkSizes(b, bufSizesOverlap, func { b, n | + benchmarkSizes(b, bufSizesOverlap, func { b, n -> x := make([]byte, n+1) for i := 0; i < b.N; i++ { copy(x[1:n+1], x[:n]) @@ -403,7 +403,7 @@ func TestMemclr(t *testing.T) { func BenchmarkMemclr(b *testing.B) { for _, n := range []int{5, 16, 64, 256, 4096, 65536} { x := make([]byte, n) - b.Run(fmt.Sprint(n), func { b | + b.Run(fmt.Sprint(n), func { b -> b.SetBytes(int64(n)) for i := 0; i < b.N; i++ { MemclrBytes(x) @@ -412,7 +412,7 @@ func BenchmarkMemclr(b *testing.B) { } for _, m := range []int{1, 4, 8, 16, 64} { x := make([]byte, m<<20) - b.Run(fmt.Sprint(m, "M"), func { b | + b.Run(fmt.Sprint(m, "M"), func { b -> b.SetBytes(int64(m << 20)) for i := 0; i < b.N; i++ { MemclrBytes(x) @@ -425,7 +425,7 @@ func BenchmarkMemclrUnaligned(b *testing.B) { for _, off := range []int{0, 1, 4, 7} { for _, n := range []int{5, 16, 64, 256, 4096, 65536} { x := make([]byte, n+off) - b.Run(fmt.Sprint(off, n), func { b | + b.Run(fmt.Sprint(off, n), func { b -> b.SetBytes(int64(n)) for i := 0; i < b.N; i++ { MemclrBytes(x[off:]) @@ -437,7 +437,7 @@ func BenchmarkMemclrUnaligned(b *testing.B) { for _, off := range []int{0, 1, 4, 7} { for _, m := range []int{1, 4, 8, 16, 64} { x := make([]byte, (m<<20)+off) - b.Run(fmt.Sprint(off, m, "M"), func { b | + b.Run(fmt.Sprint(off, m, "M"), func { b -> b.SetBytes(int64(m << 20)) for i := 0; i < b.N; i++ { MemclrBytes(x[off:]) @@ -448,7 +448,7 @@ func BenchmarkMemclrUnaligned(b *testing.B) { } func BenchmarkGoMemclr(b *testing.B) { - benchmarkSizes(b, []int{5, 16, 64, 256}, func { b, n | + benchmarkSizes(b, []int{5, 16, 64, 256}, func { b, n -> x := make([]byte, n) for i := 0; i < b.N; i++ { clear(x) @@ -500,7 +500,7 @@ func BenchmarkMemclrRange(b *testing.B) { } else { text = fmt.Sprint(minLen, " ", maxLen) } - b.Run(text, func { b | + b.Run(text, func { b -> b.SetBytes(int64(total)) for i := 0; i < b.N; i++ { for _, clrLen := range t.data { @@ -907,7 +907,7 @@ func BenchmarkIssue18740(b *testing.B) { var g [4096]byte for _, bm := range benchmarks { buf := make([]byte, bm.nbyte) - b.Run(bm.name, func { b | + b.Run(bm.name, func { b -> for j := 0; j < b.N; j++ { for i := 0; i < 4096; i += bm.nbyte { copy(buf[:], g[i:]) diff --git a/src/runtime/metrics_test.go b/src/runtime/metrics_test.go index 41dc90c419ed8..32145b81b378d 100644 --- a/src/runtime/metrics_test.go +++ b/src/runtime/metrics_test.go @@ -464,7 +464,7 @@ func BenchmarkReadMetricsLatency(b *testing.B) { b.ReportMetric(0, "allocs/op") // Sort latencies then report percentiles. - sort.Slice(latencies, func { i, j | return latencies[i] < latencies[j] }) + sort.Slice(latencies, func { i, j -> return latencies[i] < latencies[j] }) b.ReportMetric(float64(latencies[len(latencies)*50/100]), "p50-ns") b.ReportMetric(float64(latencies[len(latencies)*90/100]), "p90-ns") b.ReportMetric(float64(latencies[len(latencies)*99/100]), "p99-ns") @@ -570,7 +570,7 @@ func TestMutexWaitTimeMetric(t *testing.T) { new(rwmutexWriteRead), } for _, lock := range locks { - t.Run(reflect.TypeOf(lock).Elem().Name(), func { t | + t.Run(reflect.TypeOf(lock).Elem().Name(), func { t -> metrics.Read(sample[:]) before := time.Duration(sample[0].Value.Float64() * 1e9) @@ -940,7 +940,7 @@ func TestSchedPauseMetrics(t *testing.T) { runtime.GC() for _, tc := range tests { - t.Run(tc.name, func { t | testSchedPauseMetrics(t, tc.fn, tc.isGC) }) + t.Run(tc.name, func { t -> testSchedPauseMetrics(t, tc.fn, tc.isGC) }) } } @@ -1064,7 +1064,7 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) { acceptStacks = append([][]string(nil), acceptStacks...) for i, stk := range acceptStacks { if goexperiment.StaticLockRanking { - if !slices.ContainsFunc(stk, func { s | return s == "runtime.systemstack" || s == "runtime.mcall" || s == "runtime.mstart" }) { + if !slices.ContainsFunc(stk, func { s -> return s == "runtime.systemstack" || s == "runtime.mcall" || s == "runtime.mstart" }) { // stk is a call stack that is still on the user stack when // it calls runtime.unlock. Add the extra function that // we'll see, when the static lock ranking implementation of @@ -1113,7 +1113,7 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) { name := t.Name() - t.Run("runtime.lock", func { t | + t.Run("runtime.lock", func { t -> mus := make([]runtime.Mutex, 200) var needContention atomic.Int64 delay := 100 * time.Microsecond // large relative to system noise, for comparison between clocks @@ -1162,14 +1162,14 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) { "runtime_test.(*contentionWorker).run", }} - t.Run("sample-1", func { t | + t.Run("sample-1", func { t -> old := runtime.SetMutexProfileFraction(1) defer runtime.SetMutexProfileFraction(old) needContention.Store(int64(len(mus) - 1)) metricGrowth, profileGrowth, n, _ := testcase(true, stks, workers, fn)(t) - t.Run("metric", func { t | + t.Run("metric", func { t -> // The runtime/metrics view may be sampled at 1 per // gTrackingPeriod, so we don't have a hard lower bound here. testenv.SkipFlaky(t, 64253) @@ -1187,7 +1187,7 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) { } const slop = 1.5 // account for nanotime vs cputicks - t.Run("compare timers", func { t | + t.Run("compare timers", func { t -> testenv.SkipFlaky(t, 64253) if profileGrowth > slop*metricGrowth || metricGrowth > slop*profileGrowth { t.Errorf("views differ by more than %fx", slop) @@ -1195,7 +1195,7 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) { }) }) - t.Run("sample-2", func { t | + t.Run("sample-2", func { t -> testenv.SkipFlaky(t, 64253) old := runtime.SetMutexProfileFraction(2) @@ -1228,7 +1228,7 @@ func TestRuntimeLockMetricsAndProfile(t *testing.T) { }) }) - t.Run("runtime.semrelease", func { t | + t.Run("runtime.semrelease", func { t -> testenv.SkipFlaky(t, 64253) old := runtime.SetMutexProfileFraction(1) diff --git a/src/runtime/mfinal_test.go b/src/runtime/mfinal_test.go index caa04eadad984..e2217776f365b 100644 --- a/src/runtime/mfinal_test.go +++ b/src/runtime/mfinal_test.go @@ -83,7 +83,7 @@ func TestFinalizerInterfaceBig(t *testing.T) { go func() { v := &bigValue{0xDEADBEEFDEADBEEF, true, "It matters not how strait the gate"} old := *v - runtime.SetFinalizer(v, func { v | + runtime.SetFinalizer(v, func { v -> i, ok := v.(*bigValue) if !ok { t.Errorf("finalizer called with type %T, want *bigValue", v) @@ -113,7 +113,7 @@ func TestFinalizerZeroSizedStruct(t *testing.T) { func BenchmarkFinalizer(b *testing.B) { const Batch = 1000 - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var data [Batch]*int for i := 0; i < Batch; i++ { data[i] = new(int) @@ -130,7 +130,7 @@ func BenchmarkFinalizer(b *testing.B) { } func BenchmarkFinalizerRun(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { v := new(int) runtime.SetFinalizer(v, fin) } }) @@ -169,7 +169,7 @@ func TestEmptySlice(t *testing.T) { xs := x[objsize:] // change objsize to objsize-1 and the test passes fin := make(chan bool, 1) - runtime.SetFinalizer(y, func { z | fin <- true }) + runtime.SetFinalizer(y, func { z -> fin <- true }) runtime.GC() <-fin xsglobal = xs // keep empty slice alive until here @@ -197,7 +197,7 @@ func TestEmptyString(t *testing.T) { ss := x[objsize:] // change objsize to objsize-1 and the test passes fin := make(chan bool, 1) // set finalizer on string contents of y - runtime.SetFinalizer(y, func { z | fin <- true }) + runtime.SetFinalizer(y, func { z -> fin <- true }) runtime.GC() <-fin ssglobal = ss // keep 0-length string live until here @@ -207,8 +207,8 @@ var ssglobal string // Test for issue 7656. func TestFinalizerOnGlobal(t *testing.T) { - runtime.SetFinalizer(Foo1, func { p | }) - runtime.SetFinalizer(Foo2, func { p | }) + runtime.SetFinalizer(Foo1, func { p -> }) + runtime.SetFinalizer(Foo2, func { p -> }) runtime.SetFinalizer(Foo1, nil) runtime.SetFinalizer(Foo2, nil) } @@ -236,7 +236,7 @@ func TestDeferKeepAlive(t *testing.T) { type T *int // needs to be a pointer base type to avoid tinyalloc and its never-finalized behavior. x := new(T) finRun := false - runtime.SetFinalizer(x, func { x | finRun = true }) + runtime.SetFinalizer(x, func { x -> finRun = true }) defer runtime.KeepAlive(x) runtime.GC() time.Sleep(time.Second) diff --git a/src/runtime/mgc.go b/src/runtime/mgc.go index 544bd07d5f702..5b488a1653f62 100644 --- a/src/runtime/mgc.go +++ b/src/runtime/mgc.go @@ -844,7 +844,7 @@ top: // Flush all local buffers and collect flushedWork flags. gcMarkDoneFlushed = 0 - forEachP(waitReasonGCMarkTermination, func { pp | + forEachP(waitReasonGCMarkTermination, func { pp -> // Flush the write barrier buffer, since this may add // work to the gcWork. wbBufFlush1(pp) @@ -1150,7 +1150,7 @@ func gcMarkTermination(stw worldStop) { // // Also, flush the pinner cache, to avoid leaking that memory // indefinitely. - forEachP(waitReasonFlushProcCaches, func { pp | + forEachP(waitReasonFlushProcCaches, func { pp -> pp.mcache.prepareForSweep() if pp.status == _Pidle { systemstack(func() { @@ -1360,7 +1360,7 @@ func gcBgMarkWorker(ready chan struct{}) { for { // Go to sleep until woken by // gcController.findRunnableGCWorker. - gopark(func { g, nodep | + gopark(func { g, nodep -> node := (*gcBgMarkWorkerNode)(nodep) if mp := node.m.ptr(); mp != nil { @@ -1679,7 +1679,7 @@ func gcSweep(mode gcMode) bool { func gcResetMarkState() { // This may be called during a concurrent phase, so lock to make sure // allgs doesn't change. - forEachG(func { gp | + forEachG(func { gp -> gp.gcscandone = false // set to true in gcphasework gp.gcAssistBytes = 0 }) diff --git a/src/runtime/mgcmark.go b/src/runtime/mgcmark.go index 2709573b98226..328e7e8a2820a 100644 --- a/src/runtime/mgcmark.go +++ b/src/runtime/mgcmark.go @@ -128,7 +128,7 @@ func gcMarkRootCheck() { // Since we don't care about newer Gs (see comment in // gcMarkRootPrepare), no locking is required. i := 0 - forEachGRace(func { gp | + forEachGRace(func { gp -> if i >= work.nStackRoots { return } @@ -1482,7 +1482,7 @@ func scanConservative(b, n uintptr, ptrmask *uint8, gcw *gcWork, state *stackSca if debugScanConservative { printlock() print("conservatively scanning [", hex(b), ",", hex(b+n), ")\n") - hexdumpWords(b, b+n, func { p | + hexdumpWords(b, b+n, func { p -> if ptrmask != nil { word := (p - b) / goarch.PtrSize bits := *addb(ptrmask, word/8) diff --git a/src/runtime/mgcpacer_test.go b/src/runtime/mgcpacer_test.go index 51b9bf8516547..b4331c28a2373 100644 --- a/src/runtime/mgcpacer_test.go +++ b/src/runtime/mgcpacer_test.go @@ -604,7 +604,7 @@ func TestGcPacer(t *testing.T) { // happens between calls to revise; the framework just doesn't support this yet. } { e := e - t.Run(e.name, func { t | + t.Run(e.name, func { t -> t.Parallel() c := NewGCController(e.gcPercent, e.memoryLimit) diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go index da809a27d37c4..186c0aa4f71a4 100644 --- a/src/runtime/mgcscavenge.go +++ b/src/runtime/mgcscavenge.go @@ -390,7 +390,7 @@ func (s *scavengerState) init() { // Install real functions if stubs aren't present. if s.scavenge == nil { - s.scavenge = func { n | + s.scavenge = func { n -> start := nanotime() r := mheap_.pages.scavenge(n, nil, false) end := nanotime() diff --git a/src/runtime/mgcscavenge_test.go b/src/runtime/mgcscavenge_test.go index a8bc0c4d42fd1..0e4a8a2ebe13e 100644 --- a/src/runtime/mgcscavenge_test.go +++ b/src/runtime/mgcscavenge_test.go @@ -274,7 +274,7 @@ func TestPallocDataFindScavengeCandidate(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := makePallocData(v.alloc, v.scavenged) start, size := b.FindScavengeCandidate(PallocChunkPages-1, v.min, v.max) got := BitRange{start, size} @@ -436,7 +436,7 @@ func TestPageAllocScavenge(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := NewPageAlloc(v.beforeAlloc, v.beforeScav) defer FreePageAlloc(b) @@ -469,11 +469,11 @@ func TestScavenger(t *testing.T) { // Set up the scavenger. var s Scavenger - s.Sleep = func { ns | + s.Sleep = func { ns -> totalSlept.Add(ns) return ns } - s.Scavenge = func { bytes | + s.Scavenge = func { bytes -> avail := availableWork.Load() if uint64(bytes) > avail { bytes = uintptr(avail) @@ -604,13 +604,13 @@ func TestScavengeIndex(t *testing.T) { si.ResetSearchAddrs() // Create and return test functions. - mark = func { base, limit | + mark = func { base, limit -> t.Helper() si.AllocRange(base, limit) si.FreeRange(base, limit) } - find = func { want, wantOffset | + find = func { want, wantOffset -> t.Helper() got, gotOffset := si.Find(force) @@ -793,7 +793,7 @@ func TestScavengeIndex(t *testing.T) { }, } { test := test - t.Run("Bg/"+test.name, func { t | + t.Run("Bg/"+test.name, func { t -> mark, find, nextGen := setup(t, false) test.mark(mark) find(0, 0) // Make sure we find nothing at this point. @@ -801,14 +801,14 @@ func TestScavengeIndex(t *testing.T) { test.find(find) // Now we should be able to find things. find(0, 0) // The test should always fully exhaust the index. }) - t.Run("Force/"+test.name, func { t | + t.Run("Force/"+test.name, func { t -> mark, find, _ := setup(t, true) test.mark(mark) test.find(find) // Finding should always work when forced. find(0, 0) // The test should always fully exhaust the index. }) } - t.Run("Bg/MarkInterleaved", func { t | + t.Run("Bg/MarkInterleaved", func { t -> mark, find, nextGen := setup(t, false) for i := BaseChunkIdx; i < BaseChunkIdx+32; i++ { mark(PageBase(i, 0), PageBase(i+1, 0)) @@ -817,7 +817,7 @@ func TestScavengeIndex(t *testing.T) { } find(0, 0) }) - t.Run("Force/MarkInterleaved", func { t | + t.Run("Force/MarkInterleaved", func { t -> mark, find, _ := setup(t, true) for i := BaseChunkIdx; i < BaseChunkIdx+32; i++ { mark(PageBase(i, 0), PageBase(i+1, 0)) @@ -848,7 +848,7 @@ func FuzzPIController(f *testing.F) { // reasonable seed inputs. f.Add(0.3375, 3.2e6, 1e9, 0.001, 1000.0, 0.01) f.Add(0.9, 4.0, 1000.0, -1000.0, 1000.0, 0.84) - f.Fuzz(func { t, kp, ti, tt, min, max, setPoint | + f.Fuzz(func { t, kp, ti, tt, min, max, setPoint -> // Ignore uninteresting invalid parameters. These parameters // are constant, so in practice surprising values will be documented // or will be other otherwise immediately visible. diff --git a/src/runtime/mpagealloc_test.go b/src/runtime/mpagealloc_test.go index 22adde2b227e9..4e1ce1d6ec82e 100644 --- a/src/runtime/mpagealloc_test.go +++ b/src/runtime/mpagealloc_test.go @@ -182,7 +182,7 @@ func TestPageAllocGrow(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> // By creating a new pageAlloc, we will // grow it for each chunk defined in x. x := make(map[ChunkIdx][]BitRange) @@ -677,7 +677,7 @@ func TestPageAllocAlloc(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := NewPageAlloc(v.before, v.scav) defer FreePageAlloc(b) @@ -704,7 +704,7 @@ func TestPageAllocExhaust(t *testing.T) { } for _, npages := range []uintptr{1, 2, 3, 4, 5, 8, 16, 64, 1024, 1025, 2048, 2049} { npages := npages - t.Run(fmt.Sprintf("%d", npages), func { t | + t.Run(fmt.Sprintf("%d", npages), func { t -> // Construct b. bDesc := make(map[ChunkIdx][]BitRange) for i := ChunkIdx(0); i < 4; i++ { @@ -967,7 +967,7 @@ func TestPageAllocFree(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := NewPageAlloc(v.before, nil) defer FreePageAlloc(b) @@ -1022,7 +1022,7 @@ func TestPageAllocAllocAndFree(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := NewPageAlloc(v.init, nil) defer FreePageAlloc(b) diff --git a/src/runtime/mpagecache_test.go b/src/runtime/mpagecache_test.go index 48af4558a1226..3fce797e2fcb6 100644 --- a/src/runtime/mpagecache_test.go +++ b/src/runtime/mpagecache_test.go @@ -165,7 +165,7 @@ func TestPageCacheAlloc(t *testing.T) { } for name, test := range tests { test := test - t.Run(name, func { t | + t.Run(name, func { t -> c := test.cache for i, h := range test.hits { b, s := c.Alloc(h.npages) @@ -405,7 +405,7 @@ func TestPageAllocAllocToCache(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := NewPageAlloc(v.beforeAlloc, v.beforeScav) defer FreePageAlloc(b) diff --git a/src/runtime/mpallocbits_test.go b/src/runtime/mpallocbits_test.go index 5a19197df38f9..6d82db62d973b 100644 --- a/src/runtime/mpallocbits_test.go +++ b/src/runtime/mpallocbits_test.go @@ -44,28 +44,28 @@ func TestPallocBitsAllocRange(t *testing.T) { test := func(t *testing.T, i, n uint, want *PallocBits) { checkPallocBits(t, makePallocBits([]BitRange{{i, n}}), want) } - t.Run("OneLow", func { t | + t.Run("OneLow", func { t -> want := new(PallocBits) want[0] = 0x1 test(t, 0, 1, want) }) - t.Run("OneHigh", func { t | + t.Run("OneHigh", func { t -> want := new(PallocBits) want[PallocChunkPages/64-1] = 1 << 63 test(t, PallocChunkPages-1, 1, want) }) - t.Run("Inner", func { t | + t.Run("Inner", func { t -> want := new(PallocBits) want[2] = 0x3e test(t, 129, 5, want) }) - t.Run("Aligned", func { t | + t.Run("Aligned", func { t -> want := new(PallocBits) want[2] = ^uint64(0) want[3] = ^uint64(0) test(t, 128, 128, want) }) - t.Run("Begin", func { t | + t.Run("Begin", func { t -> want := new(PallocBits) want[0] = ^uint64(0) want[1] = ^uint64(0) @@ -75,7 +75,7 @@ func TestPallocBitsAllocRange(t *testing.T) { want[5] = 0x1 test(t, 0, 321, want) }) - t.Run("End", func { t | + t.Run("End", func { t -> want := new(PallocBits) want[PallocChunkPages/64-1] = ^uint64(0) want[PallocChunkPages/64-2] = ^uint64(0) @@ -83,7 +83,7 @@ func TestPallocBitsAllocRange(t *testing.T) { want[PallocChunkPages/64-4] = 1 << 63 test(t, PallocChunkPages-(64*3+1), 64*3+1, want) }) - t.Run("All", func { t | + t.Run("All", func { t -> want := new(PallocBits) for i := range want { want[i] = ^uint64(0) @@ -194,7 +194,7 @@ func TestMallocBitsPopcntRange(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := makePallocBits(v.init) for _, h := range v.tests { if got := b.PopcntRange(h.i, h.n); got != h.want { @@ -283,7 +283,7 @@ func TestPallocBitsSummarize(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := makePallocBits(v.free) // In the PallocBits we create 1's represent free spots, but in our actual // PallocBits 1 means not free, so invert. @@ -318,7 +318,7 @@ func BenchmarkPallocBitsSummarize(b *testing.B) { for i := 0; i < len(buf); i++ { buf[i] = p } - b.Run(fmt.Sprintf("Unpacked%02X", p), func { b | + b.Run(fmt.Sprintf("Unpacked%02X", p), func { b -> checkPallocSum(b, buf.Summarize(), SummarizeSlow(buf)) for i := 0; i < b.N; i++ { buf.Summarize() @@ -423,7 +423,7 @@ func TestPallocBitsAlloc(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := makePallocBits(v.before) for iter, i := range v.hits { a, _ := b.Find(v.npages, 0) @@ -482,7 +482,7 @@ func TestPallocBitsFree(t *testing.T) { } for name, v := range tests { v := v - t.Run(name, func { t | + t.Run(name, func { t -> b := makePallocBits(v.beforeInv) invertPallocBits(b) for _, i := range v.frees { @@ -541,7 +541,7 @@ func BenchmarkFindBitRange64(b *testing.B) { } for _, pattern := range patterns { for _, size := range sizes { - b.Run(fmt.Sprintf("Pattern%02XSize%d", pattern, size), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("Pattern%02XSize%d", pattern, size), func { b -> for i := 0; i < b.N; i++ { FindBitRange64(pattern, size) } }) } diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go index 87a5d3c43cc7f..777e4bb8b58b6 100644 --- a/src/runtime/mprof.go +++ b/src/runtime/mprof.go @@ -992,7 +992,7 @@ func (r *MemProfileRecord) Stack() []uintptr { // the testing package's -test.memprofile flag instead // of calling MemProfile directly. func MemProfile(p []MemProfileRecord, inuseZero bool) (n int, ok bool) { - return memProfileInternal(len(p), inuseZero, func { r | + return memProfileInternal(len(p), inuseZero, func { r -> copyMemProfileRecord(&p[0], r) p = p[1:] }) @@ -1088,7 +1088,7 @@ func copyMemProfileRecord(dst *MemProfileRecord, src profilerecord.MemProfileRec //go:linkname pprof_memProfileInternal func pprof_memProfileInternal(p []profilerecord.MemProfileRecord, inuseZero bool) (n int, ok bool) { - return memProfileInternal(len(p), inuseZero, func { r | + return memProfileInternal(len(p), inuseZero, func { r -> p[0] = r p = p[1:] }) @@ -1121,7 +1121,7 @@ type BlockProfileRecord struct { // of calling BlockProfile directly. func BlockProfile(p []BlockProfileRecord) (n int, ok bool) { var m int - n, ok = blockProfileInternal(len(p), func { r | + n, ok = blockProfileInternal(len(p), func { r -> copyBlockProfileRecord(&p[m], r) m++ }) @@ -1206,7 +1206,7 @@ func copyBlockProfileRecord(dst *BlockProfileRecord, src profilerecord.BlockProf //go:linkname pprof_blockProfileInternal func pprof_blockProfileInternal(p []profilerecord.BlockProfileRecord) (n int, ok bool) { - return blockProfileInternal(len(p), func { r | + return blockProfileInternal(len(p), func { r -> p[0] = r p = p[1:] }) @@ -1220,7 +1220,7 @@ func pprof_blockProfileInternal(p []profilerecord.BlockProfileRecord) (n int, ok // instead of calling MutexProfile directly. func MutexProfile(p []BlockProfileRecord) (n int, ok bool) { var m int - n, ok = mutexProfileInternal(len(p), func { r | + n, ok = mutexProfileInternal(len(p), func { r -> copyBlockProfileRecord(&p[m], r) m++ }) @@ -1257,7 +1257,7 @@ func mutexProfileInternal(size int, copyFn func(profilerecord.BlockProfileRecord //go:linkname pprof_mutexProfileInternal func pprof_mutexProfileInternal(p []profilerecord.BlockProfileRecord) (n int, ok bool) { - return mutexProfileInternal(len(p), func { r | + return mutexProfileInternal(len(p), func { r -> p[0] = r p = p[1:] }) @@ -1270,7 +1270,7 @@ func pprof_mutexProfileInternal(p []profilerecord.BlockProfileRecord) (n int, ok // Most clients should use the runtime/pprof package instead // of calling ThreadCreateProfile directly. func ThreadCreateProfile(p []StackRecord) (n int, ok bool) { - return threadCreateProfileInternal(len(p), func { r | + return threadCreateProfileInternal(len(p), func { r -> i := copy(p[0].Stack0[:], r.Stack) clear(p[0].Stack0[i:]) p = p[1:] @@ -1297,7 +1297,7 @@ func threadCreateProfileInternal(size int, copyFn func(profilerecord.StackRecord //go:linkname pprof_threadCreateInternal func pprof_threadCreateInternal(p []profilerecord.StackRecord) (n int, ok bool) { - return threadCreateProfileInternal(len(p), func { r | + return threadCreateProfileInternal(len(p), func { r -> p[0] = r p = p[1:] }) @@ -1438,7 +1438,7 @@ func goroutineProfileWithLabelsConcurrent(p []profilerecord.StackRecord, labels // Any goroutine that the scheduler tries to execute concurrently with this // call will start by adding itself to the profile (before the act of // executing can cause any changes in its stack). - forEachGRace(func { gp1 | tryRecordGoroutineProfile(gp1, pcbuf, Gosched) }) + forEachGRace(func { gp1 -> tryRecordGoroutineProfile(gp1, pcbuf, Gosched) }) stw = stopTheWorld(stwGoroutineProfileCleanup) endOffset := goroutineProfile.offset.Swap(0) @@ -1449,7 +1449,7 @@ func goroutineProfileWithLabelsConcurrent(p []profilerecord.StackRecord, labels // Restore the invariant that every goroutine struct in allgs has its // goroutineProfiled field cleared. - forEachGRace(func { gp1 | gp1.goroutineProfiled.Store(goroutineProfileAbsent) }) + forEachGRace(func { gp1 -> gp1.goroutineProfiled.Store(goroutineProfileAbsent) }) if raceenabled { raceacquire(unsafe.Pointer(&labelSync)) @@ -1578,7 +1578,7 @@ func goroutineProfileWithLabelsSync(p []profilerecord.StackRecord, labels []unsa // World is stopped, no locking required. n = 1 - forEachGRace(func { gp1 | if isOK(gp1) { + forEachGRace(func { gp1 -> if isOK(gp1) { n++ } }) @@ -1601,7 +1601,7 @@ func goroutineProfileWithLabelsSync(p []profilerecord.StackRecord, labels []unsa } // Save other goroutines. - forEachGRace(func { gp1 | + forEachGRace(func { gp1 -> if !isOK(gp1) { return } diff --git a/src/runtime/mranges_test.go b/src/runtime/mranges_test.go index 3d5afa68ea67c..af20d28518e6f 100644 --- a/src/runtime/mranges_test.go +++ b/src/runtime/mranges_test.go @@ -264,7 +264,7 @@ func TestAddrRangesFindSucc(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> a := MakeAddrRanges(test.ranges...) i := a.FindSucc(test.base) if i != test.expect { diff --git a/src/runtime/norace_test.go b/src/runtime/norace_test.go index 3c4ea75bce8fe..21969feeb60b8 100644 --- a/src/runtime/norace_test.go +++ b/src/runtime/norace_test.go @@ -32,7 +32,7 @@ func BenchmarkSyscallExcessWork(b *testing.B) { func benchmarkSyscall(b *testing.B, work, excess int) { b.SetParallelism(excess) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> foo := 42 for pb.Next() { runtime.Entersyscall() diff --git a/src/runtime/panic_test.go b/src/runtime/panic_test.go index d864ee9460caa..b67c8f15a52eb 100644 --- a/src/runtime/panic_test.go +++ b/src/runtime/panic_test.go @@ -38,7 +38,7 @@ func TestPanicWithDirectlyPrintableCustomTypes(t *testing.T) { for _, tt := range tests { t := t - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> output := runTestProg(t, "testprog", tt.name) if !strings.HasPrefix(output, tt.wantPanicPrefix) { t.Fatalf("%q\nis not present in\n%s", tt.wantPanicPrefix, output) diff --git a/src/runtime/panicnil_test.go b/src/runtime/panicnil_test.go index f9c4ad66d550d..3899baf775a72 100644 --- a/src/runtime/panicnil_test.go +++ b/src/runtime/panicnil_test.go @@ -12,12 +12,12 @@ import ( ) func TestPanicNil(t *testing.T) { - t.Run("default", func { t | checkPanicNil(t, new(runtime.PanicNilError)) }) - t.Run("GODEBUG=panicnil=0", func { t | + t.Run("default", func { t -> checkPanicNil(t, new(runtime.PanicNilError)) }) + t.Run("GODEBUG=panicnil=0", func { t -> t.Setenv("GODEBUG", "panicnil=0") checkPanicNil(t, new(runtime.PanicNilError)) }) - t.Run("GODEBUG=panicnil=1", func { t | + t.Run("GODEBUG=panicnil=1", func { t -> t.Setenv("GODEBUG", "panicnil=1") checkPanicNil(t, nil) }) diff --git a/src/runtime/pinner.go b/src/runtime/pinner.go index 276321de479b7..53ccb18000bf5 100644 --- a/src/runtime/pinner.go +++ b/src/runtime/pinner.go @@ -48,7 +48,7 @@ func (p *Pinner) Pin(pointer any) { // when reusing from the cache. The finalizer however has to be // resilient to an empty pinner being finalized, which is done // by checking p.refs' length. - SetFinalizer(p.pinner, func { i | + SetFinalizer(p.pinner, func { i -> if len(i.refs) != 0 { i.unpin() // only required to make the test idempotent pinnerLeakPanic() diff --git a/src/runtime/pinner_test.go b/src/runtime/pinner_test.go index e32fa2d1ff3d0..5e5cbfccd7c1a 100644 --- a/src/runtime/pinner_test.go +++ b/src/runtime/pinner_test.go @@ -446,7 +446,7 @@ func BenchmarkPinnerPinUnpinDouble(b *testing.B) { } func BenchmarkPinnerPinUnpinParallel(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> p := new(obj) for pb.Next() { var pinner runtime.Pinner @@ -457,7 +457,7 @@ func BenchmarkPinnerPinUnpinParallel(b *testing.B) { } func BenchmarkPinnerPinUnpinParallelTiny(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> p := new(bool) for pb.Next() { var pinner runtime.Pinner @@ -468,7 +468,7 @@ func BenchmarkPinnerPinUnpinParallelTiny(b *testing.B) { } func BenchmarkPinnerPinUnpinParallelDouble(b *testing.B) { - b.RunParallel(func { pb | + b.RunParallel(func { pb -> p := new(obj) for pb.Next() { var pinner runtime.Pinner @@ -503,7 +503,7 @@ func BenchmarkPinnerIsPinnedOnPinnedParallel(b *testing.B) { ptr := new(obj) pinner.Pin(ptr) b.ResetTimer() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { runtime.IsPinned(unsafe.Pointer(ptr)) } }) pinner.Unpin() @@ -512,7 +512,7 @@ func BenchmarkPinnerIsPinnedOnPinnedParallel(b *testing.B) { func BenchmarkPinnerIsPinnedOnUnpinnedParallel(b *testing.B) { ptr := new(obj) b.ResetTimer() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { runtime.IsPinned(unsafe.Pointer(ptr)) } }) } diff --git a/src/runtime/pprof/label_test.go b/src/runtime/pprof/label_test.go index 194f097820856..b0bd92a210db1 100644 --- a/src/runtime/pprof/label_test.go +++ b/src/runtime/pprof/label_test.go @@ -13,7 +13,7 @@ import ( func labelsSorted(ctx context.Context) []label { ls := []label{} - ForLabels(ctx, func { key, value | + ForLabels(ctx, func { key, value -> ls = append(ls, label{key, value}) return true }) diff --git a/src/runtime/pprof/mprof_test.go b/src/runtime/pprof/mprof_test.go index 083fe13406cdd..e96a5b0d527cd 100644 --- a/src/runtime/pprof/mprof_test.go +++ b/src/runtime/pprof/mprof_test.go @@ -121,7 +121,7 @@ func TestMemoryProfiler(t *testing.T) { `, memoryProfilerRun, (2<<20)*memoryProfilerRun), }} - t.Run("debug=1", func { t | + t.Run("debug=1", func { t -> var buf bytes.Buffer if err := Lookup("heap").WriteTo(&buf, 1); err != nil { t.Fatalf("failed to write heap profile: %v", err) @@ -134,7 +134,7 @@ func TestMemoryProfiler(t *testing.T) { } }) - t.Run("proto", func { t | + t.Run("proto", func { t -> var buf bytes.Buffer if err := Lookup("heap").WriteTo(&buf, 0); err != nil { t.Fatalf("failed to write heap profile: %v", err) diff --git a/src/runtime/pprof/pprof.go b/src/runtime/pprof/pprof.go index 4a3ffdf6a58b9..72975469c6ff0 100644 --- a/src/runtime/pprof/pprof.go +++ b/src/runtime/pprof/pprof.go @@ -281,7 +281,7 @@ func Profiles() []*Profile { all = append(all, p) } - slices.SortFunc(all, func { a, b | return strings.Compare(a.name, b.name) }) + slices.SortFunc(all, func { a, b -> return strings.Compare(a.name, b.name) }) return all } @@ -629,7 +629,7 @@ func writeHeapInternal(w io.Writer, debug int, defaultSampleType string) error { return writeHeapProto(w, p, int64(runtime.MemProfileRate), defaultSampleType) } - slices.SortFunc(p, func { a, b | return cmp.Compare(a.InUseBytes(), b.InUseBytes()) }) + slices.SortFunc(p, func { a, b -> return cmp.Compare(a.InUseBytes(), b.InUseBytes()) }) b := bufio.NewWriter(w) tw := tabwriter.NewWriter(b, 1, 8, 1, '\t', 0) @@ -929,7 +929,7 @@ func writeProfileInternal(w io.Writer, debug int, name string, runtimeProfile fu } } - slices.SortFunc(p, func { a, b | return cmp.Compare(b.Cycles, a.Cycles) }) + slices.SortFunc(p, func { a, b -> return cmp.Compare(b.Cycles, a.Cycles) }) if debug <= 0 { return printCountCycleProfile(w, "contentions", "delay", p) diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go index a3c7b23f6ef81..2fa70a0d563e7 100644 --- a/src/runtime/pprof/pprof_test.go +++ b/src/runtime/pprof/pprof_test.go @@ -92,13 +92,13 @@ func avoidFunctions() []string { func TestCPUProfile(t *testing.T) { matches := matchAndAvoidStacks(stackContains, []string{"runtime/pprof.cpuHog1"}, avoidFunctions()) - testCPUProfile(t, matches, func { dur | cpuHogger(cpuHog1, &salt1, dur) }) + testCPUProfile(t, matches, func { dur -> cpuHogger(cpuHog1, &salt1, dur) }) } func TestCPUProfileMultithreaded(t *testing.T) { defer runtime.GOMAXPROCS(runtime.GOMAXPROCS(2)) matches := matchAndAvoidStacks(stackContains, []string{"runtime/pprof.cpuHog1", "runtime/pprof.cpuHog2"}, avoidFunctions()) - testCPUProfile(t, matches, func { dur | + testCPUProfile(t, matches, func { dur -> c := make(chan int) go func() { cpuHogger(cpuHog1, &salt1, dur) @@ -182,7 +182,7 @@ func TestCPUProfileMultithreadMagnitude(t *testing.T) { }, } { // check that the OS's perspective matches what the Go runtime measures. - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> t.Logf("Running with %d workers", tc.workers) var userTime, systemTime time.Duration @@ -220,7 +220,7 @@ func TestCPUProfileMultithreadMagnitude(t *testing.T) { return ok } - testCPUProfile(t, acceptProfile, func { dur | + testCPUProfile(t, acceptProfile, func { dur -> userTime, systemTime = diffCPUTime(t, func() { var wg sync.WaitGroup var once sync.Once @@ -283,7 +283,7 @@ func TestCPUProfileInlining(t *testing.T) { } matches := matchAndAvoidStacks(stackContains, []string{"runtime/pprof.inlinedCallee", "runtime/pprof.inlinedCaller"}, avoidFunctions()) - p := testCPUProfile(t, matches, func { dur | cpuHogger(inlinedCaller, &salt1, dur) }) + p := testCPUProfile(t, matches, func { dur -> cpuHogger(inlinedCaller, &salt1, dur) }) // Check if inlined function locations are encoded correctly. The inlinedCalee and inlinedCaller should be in one location. for _, loc := range p.Location { @@ -349,7 +349,7 @@ func inlinedWrapperCallerDump(pcs []uintptr) { func TestCPUProfileRecursion(t *testing.T) { matches := matchAndAvoidStacks(stackContains, []string{"runtime/pprof.inlinedCallee", "runtime/pprof.recursionCallee", "runtime/pprof.recursionCaller"}, avoidFunctions()) - p := testCPUProfile(t, matches, func { dur | cpuHogger(recursionCaller, &salt1, dur) }) + p := testCPUProfile(t, matches, func { dur -> cpuHogger(recursionCaller, &salt1, dur) }) // check the Location encoding was not confused by recursive calls. for i, loc := range p.Location { @@ -543,7 +543,7 @@ func profileOk(t *testing.T, matches profileMatchFunc, prof bytes.Buffer, durati var samples uintptr var buf strings.Builder - p := parseProfile(t, prof.Bytes(), func { count, stk, labels | + p := parseProfile(t, prof.Bytes(), func { count, stk, labels -> fmt.Fprintf(&buf, "%d:", count) fprintStack(&buf, stk) fmt.Fprintf(&buf, " labels: %v\n", labels) @@ -717,7 +717,7 @@ func TestGoroutineSwitch(t *testing.T) { // "runtime.gogo" is OK, because that's the part of the context switch // before the actual switch begins. But we should not see "gogo", // aka "gogo<>(SB)", which does the actual switch and is marked SPWRITE. - parseProfile(t, prof.Bytes(), func { count, stk, _ | + parseProfile(t, prof.Bytes(), func { count, stk, _ -> // An entry with two frames with 'System' in its top frame // exists to record a PC without a traceback. Those are okay. if len(stk) == 2 { @@ -764,7 +764,7 @@ func fprintStack(w io.Writer, stk []*profile.Location) { // Test that profiling of division operations is okay, especially on ARM. See issue 6681. func TestMathBigDivide(t *testing.T) { - testCPUProfile(t, nil, func { duration | + testCPUProfile(t, nil, func { duration -> t := time.After(duration) pi := new(big.Int) for { @@ -794,7 +794,7 @@ func stackContainsAll(spec string, count uintptr, stk []*profile.Location, label func TestMorestack(t *testing.T) { matches := matchAndAvoidStacks(stackContainsAll, []string{"runtime.newstack,runtime/pprof.growstack"}, avoidFunctions()) - testCPUProfile(t, matches, func { duration | + testCPUProfile(t, matches, func { duration -> t := time.After(duration) c := make(chan bool) for { @@ -943,7 +943,7 @@ func TestBlockProfile(t *testing.T) { test.f(t) } - t.Run("debug=1", func { t | + t.Run("debug=1", func { t -> var w strings.Builder Lookup("block").WriteTo(&w, 1) prof := w.String() @@ -963,7 +963,7 @@ func TestBlockProfile(t *testing.T) { } }) - t.Run("proto", func { t | + t.Run("proto", func { t -> // proto format var w bytes.Buffer Lookup("block").WriteTo(&w, 0) @@ -1261,7 +1261,7 @@ func TestMutexProfile(t *testing.T) { blockMutexN(t, N, D) blockMutexNTime := time.Since(start) - t.Run("debug=1", func { t | + t.Run("debug=1", func { t -> var w strings.Builder Lookup("mutex").WriteTo(&w, 1) prof := w.String() @@ -1286,7 +1286,7 @@ func TestMutexProfile(t *testing.T) { } t.Log(prof) }) - t.Run("proto", func { t | + t.Run("proto", func { t -> // proto format var w bytes.Buffer Lookup("mutex").WriteTo(&w, 0) @@ -1340,7 +1340,7 @@ func TestMutexProfile(t *testing.T) { } }) - t.Run("records", func { t | + t.Run("records", func { t -> // Record a mutex profile using the structured record API. var records []runtime.BlockProfileRecord for { @@ -1465,8 +1465,8 @@ func TestGoroutineCounts(t *testing.T) { garbage := new(*int) fingReady := make(chan struct{}) - runtime.SetFinalizer(garbage, func { v | - Do(context.Background(), Labels("fing-label", "fing-value"), func { ctx | + runtime.SetFinalizer(garbage, func { v -> + Do(context.Background(), Labels("fing-label", "fing-value"), func { ctx -> close(fingReady) <-c }) @@ -1606,7 +1606,7 @@ func TestGoroutineProfileConcurrency(t *testing.T) { // Concurrent calls to the goroutine profiler should not trigger data races // or corruption. - t.Run("overlapping profile requests", func { t | + t.Run("overlapping profile requests", func { t -> ctx := context.Background() ctx, cancel := context.WithTimeout(ctx, 10*time.Second) defer cancel() @@ -1635,7 +1635,7 @@ func TestGoroutineProfileConcurrency(t *testing.T) { // The finalizer goroutine should not show up in most profiles, since it's // marked as a system goroutine when idle. - t.Run("finalizer not present", func { t | + t.Run("finalizer not present", func { t -> var w strings.Builder goroutineProf.WriteTo(&w, 1) prof := w.String() @@ -1645,7 +1645,7 @@ func TestGoroutineProfileConcurrency(t *testing.T) { }) // The finalizer goroutine should show up when it's running user code. - t.Run("finalizer present", func { t | + t.Run("finalizer present", func { t -> // T is a pointer type so it won't be allocated by the tiny // allocator, which can lead to its finalizer not being called // during this test @@ -1653,7 +1653,7 @@ func TestGoroutineProfileConcurrency(t *testing.T) { obj := new(T) ch1, ch2 := make(chan int), make(chan int) defer close(ch2) - runtime.SetFinalizer(obj, func { _ | + runtime.SetFinalizer(obj, func { _ -> close(ch1) <-ch2 }) @@ -1726,7 +1726,7 @@ func TestGoroutineProfileConcurrency(t *testing.T) { // we can test directly, but does help to shake out data races. ready.Add(1) var churn func(i int) - churn = func { i | + churn = func { i -> SetGoroutineLabels(WithLabels(ctx, Labels(t.Name()+"-churn-i", fmt.Sprint(i)))) if i == 0 { ready.Done() @@ -1796,7 +1796,7 @@ func TestGoroutineProfileCoro(t *testing.T) { // Set up a goroutine to just create and run coroutine goroutines all day. iterFunc := func() { p, stop := iter.Pull2( - func { yield | for i := 0; i < 10000; i++ { + func { yield -> for i := 0; i < 10000; i++ { if !yield(i, i) { return } @@ -1868,7 +1868,7 @@ func BenchmarkGoroutine(b *testing.B) { ready.Add(1) var count int64 var churn func(i int) - churn = func { i | + churn = func { i -> SetGoroutineLabels(WithLabels(ctx, Labels("churn-i", fmt.Sprint(i)))) atomic.AddInt64(&count, 1) if i == 0 { @@ -1960,7 +1960,7 @@ func stackContainsLabeled(spec string, count uintptr, stk []*profile.Location, l func TestCPUProfileLabel(t *testing.T) { matches := matchAndAvoidStacks(stackContainsLabeled, []string{"runtime/pprof.cpuHogger;key=value"}, avoidFunctions()) - testCPUProfile(t, matches, func { dur | + testCPUProfile(t, matches, func { dur -> Do(context.Background(), Labels("key", "value"), func { cpuHogger(cpuHog1, &salt1, dur) }) }) } @@ -1971,7 +1971,7 @@ func TestLabelRace(t *testing.T) { // between setting labels and consuming them from the // profile. matches := matchAndAvoidStacks(stackContainsLabeled, []string{"runtime/pprof.cpuHogger;key=value"}, nil) - testCPUProfile(t, matches, func { dur | + testCPUProfile(t, matches, func { dur -> start := time.Now() var wg sync.WaitGroup for time.Since(start) < dur { @@ -1994,7 +1994,7 @@ func TestGoroutineProfileLabelRace(t *testing.T) { // between setting labels and consuming them from the // goroutine profile. See issue #50292. - t.Run("reset", func { t | + t.Run("reset", func { t -> ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -2012,11 +2012,11 @@ func TestGoroutineProfileLabelRace(t *testing.T) { }() for i := 0; ctx.Err() == nil; i++ { - Do(ctx, Labels("loop-i", fmt.Sprint(i)), func { ctx | }) + Do(ctx, Labels("loop-i", fmt.Sprint(i)), func { ctx -> }) } }) - t.Run("churn", func { t | + t.Run("churn", func { t -> ctx := context.Background() ctx, cancel := context.WithCancel(ctx) defer cancel() @@ -2024,7 +2024,7 @@ func TestGoroutineProfileLabelRace(t *testing.T) { var ready sync.WaitGroup ready.Add(1) var churn func(i int) - churn = func { i | + churn = func { i -> SetGoroutineLabels(WithLabels(ctx, Labels("churn-i", fmt.Sprint(i)))) if i == 0 { ready.Done() @@ -2054,8 +2054,8 @@ func TestLabelSystemstack(t *testing.T) { debug.SetGCPercent(gogc) matches := matchAndAvoidStacks(stackContainsLabeled, []string{"runtime.systemstack;key=value"}, avoidFunctions()) - p := testCPUProfile(t, matches, func { dur | - Do(context.Background(), Labels("key", "value"), func { ctx | parallelLabelHog(ctx, dur, gogc) }) + p := testCPUProfile(t, matches, func { dur -> + Do(context.Background(), Labels("key", "value"), func { ctx -> parallelLabelHog(ctx, dur, gogc) }) }) // Two conditions to check: @@ -2437,7 +2437,7 @@ func TestTryAdd(t *testing.T) { }} for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> p, err := translateCPUProfile(tc.input, tc.count) if err != nil { t.Fatalf("translating profile: %v", err) @@ -2482,7 +2482,7 @@ func TestTimeVDSO(t *testing.T) { } matches := matchAndAvoidStacks(stackContains, []string{"time.now"}, avoidFunctions()) - p := testCPUProfile(t, matches, func { dur | + p := testCPUProfile(t, matches, func { dur -> t0 := time.Now() for { t := time.Now() @@ -2526,7 +2526,7 @@ func TestProfilerStackDepth(t *testing.T) { } for _, test := range tests { - t.Run(test.profiler, func { t | + t.Run(test.profiler, func { t -> var buf bytes.Buffer if err := Lookup(test.profiler).WriteTo(&buf, 0); err != nil { t.Fatalf("failed to write heap profile: %v", err) @@ -2725,8 +2725,8 @@ func TestMutexBlockFullAggregation(t *testing.T) { t.Errorf("did not see any samples in %s profile for this test", name) } } - t.Run("mutex", func { t | assertNoDuplicates("mutex", runtime.MutexProfile) }) - t.Run("block", func { t | assertNoDuplicates("block", runtime.BlockProfile) }) + t.Run("mutex", func { t -> assertNoDuplicates("mutex", runtime.MutexProfile) }) + t.Run("block", func { t -> assertNoDuplicates("block", runtime.BlockProfile) }) } func inlineA(mu *sync.Mutex, wg *sync.WaitGroup) { inlineB(mu, wg) } @@ -2784,7 +2784,7 @@ runtime/pprof.inlineA`, } for _, tc := range tcs { - t.Run(tc.Name, func { t | + t.Run(tc.Name, func { t -> stacks := getProfileStacks(tc.Collect, false) for _, s := range stacks { if strings.Contains(s, tc.SubStack) { @@ -2810,8 +2810,8 @@ func TestProfileRecordNullPadding(t *testing.T) { testProfileRecordNullPadding(t, "MutexProfile", runtime.MutexProfile) testProfileRecordNullPadding(t, "GoroutineProfile", runtime.GoroutineProfile) testProfileRecordNullPadding(t, "BlockProfile", runtime.BlockProfile) - testProfileRecordNullPadding(t, "MemProfile/inUseZero=true", func { p | return runtime.MemProfile(p, true) }) - testProfileRecordNullPadding(t, "MemProfile/inUseZero=false", func { p | return runtime.MemProfile(p, false) }) + testProfileRecordNullPadding(t, "MemProfile/inUseZero=true", func { p -> return runtime.MemProfile(p, true) }) + testProfileRecordNullPadding(t, "MemProfile/inUseZero=false", func { p -> return runtime.MemProfile(p, false) }) // Not testing ThreadCreateProfile because it is broken, see issue 6104. } @@ -2829,7 +2829,7 @@ func testProfileRecordNullPadding[T runtime.StackRecord | runtime.MemProfileReco } } - t.Run(name, func { t | + t.Run(name, func { t -> var p []T for { n, ok := fn(p) diff --git a/src/runtime/pprof/proto_darwin.go b/src/runtime/pprof/proto_darwin.go index 6477419c38f92..56130efbb7ead 100644 --- a/src/runtime/pprof/proto_darwin.go +++ b/src/runtime/pprof/proto_darwin.go @@ -20,7 +20,7 @@ func (b *profileBuilder) readMapping() { func readMainModuleMapping() (start, end uint64, exe, buildID string, err error) { first := true - ok := machVMInfo(func { lo, hi, off, file, build | + ok := machVMInfo(func { lo, hi, off, file, build -> if first { start, end = lo, hi exe, buildID = file, build diff --git a/src/runtime/pprof/proto_test.go b/src/runtime/pprof/proto_test.go index 0643c4ff5ba40..34367c0ef6ede 100644 --- a/src/runtime/pprof/proto_test.go +++ b/src/runtime/pprof/proto_test.go @@ -88,7 +88,7 @@ func testPCs(t *testing.T) (addr1, addr2 uint64, map1, map2 *profile.Mapping) { } var mappings []*profile.Mapping id := uint64(1) - parseProcSelfMaps(mmap, func { lo, hi, offset, file, buildID | + parseProcSelfMaps(mmap, func { lo, hi, offset, file, buildID -> mappings = append(mappings, &profile.Mapping{ ID: id, Start: lo, @@ -318,16 +318,16 @@ func TestProcSelfMaps(t *testing.T) { out += "\n" } var buf strings.Builder - parseProcSelfMaps([]byte(in), func { lo, hi, offset, file, buildID | fmt.Fprintf(&buf, "%08x %08x %08x %s\n", lo, hi, offset, file) }) + parseProcSelfMaps([]byte(in), func { lo, hi, offset, file, buildID -> fmt.Fprintf(&buf, "%08x %08x %08x %s\n", lo, hi, offset, file) }) if buf.String() != out { t.Errorf("#%d: have:\n%s\nwant:\n%s\n%q\n%q", tx, buf.String(), out, buf.String(), out) } } } - t.Run("Normal", func { t | f(t, profSelfMapsTests) }) + t.Run("Normal", func { t -> f(t, profSelfMapsTests) }) - t.Run("WithDeletedFile", func { t | f(t, profSelfMapsTestsWithDeleted) }) + t.Run("WithDeletedFile", func { t -> f(t, profSelfMapsTestsWithDeleted) }) } // TestMapping checks the mapping section of CPU profiles @@ -346,7 +346,7 @@ func TestMapping(t *testing.T) { // GoOnly includes only Go symbols that runtime will symbolize. // Go+C includes C symbols that runtime will not symbolize. for _, traceback := range []string{"GoOnly", "Go+C"} { - t.Run("traceback"+traceback, func { t | + t.Run("traceback"+traceback, func { t -> cmd := exec.Command(testenv.GoToolPath(t), "run", prog) if traceback != "GoOnly" { cmd.Env = append(os.Environ(), "SETCGOTRACEBACK=1") diff --git a/src/runtime/pprof/protomem_test.go b/src/runtime/pprof/protomem_test.go index 3149e79ac4fb0..14c10f41d371b 100644 --- a/src/runtime/pprof/protomem_test.go +++ b/src/runtime/pprof/protomem_test.go @@ -72,7 +72,7 @@ func TestConvertMemProfile(t *testing.T) { {"heap", ""}, {"allocs", "alloc_space"}, } { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> var buf bytes.Buffer if err := writeHeapProto(&buf, rec, rate, tc.defaultSampleType); err != nil { t.Fatalf("writing profile: %v", err) diff --git a/src/runtime/pprof/runtime_test.go b/src/runtime/pprof/runtime_test.go index 975d8ac025f09..73223d32b49bc 100644 --- a/src/runtime/pprof/runtime_test.go +++ b/src/runtime/pprof/runtime_test.go @@ -61,7 +61,7 @@ func TestDo(t *testing.T) { t.Errorf("Expected parent goroutine's profile labels to be empty before Do, got %v", gotLabels) } - Do(context.Background(), Labels("key1", "value1", "key2", "value2"), func { ctx | + Do(context.Background(), Labels("key1", "value1", "key2", "value2"), func { ctx -> wantLabels := map[string]string{"key1": "value1", "key2": "value2"} if gotLabels := getProfLabel(); !reflect.DeepEqual(gotLabels, wantLabels) { t.Errorf("parent goroutine's profile labels: got %v, want %v", gotLabels, wantLabels) diff --git a/src/runtime/pprof/vminfo_darwin_test.go b/src/runtime/pprof/vminfo_darwin_test.go index 1dc02afdad43b..6d1f2260d5593 100644 --- a/src/runtime/pprof/vminfo_darwin_test.go +++ b/src/runtime/pprof/vminfo_darwin_test.go @@ -23,7 +23,7 @@ func TestVMInfo(t *testing.T) { var begin, end, offset uint64 var filename string first := true - machVMInfo(func { lo, hi, off, file, buildID | + machVMInfo(func { lo, hi, off, file, buildID -> if first { begin = lo end = hi diff --git a/src/runtime/proc.go b/src/runtime/proc.go index 2a26ffa74311b..fd8768be4bfd1 100644 --- a/src/runtime/proc.go +++ b/src/runtime/proc.go @@ -5957,7 +5957,7 @@ func checkdead() { } grunning := 0 - forEachG(func { gp | + forEachG(func { gp -> if isSystemGoroutine(gp, false) { return } @@ -6398,7 +6398,7 @@ func schedtrace(detailed bool) { print("\n") } - forEachG(func { gp | + forEachG(func { gp -> print(" G", gp.goid, ": status=", readgstatus(gp), "(", gp.waitreason.String(), ") m=") if gp.m != nil { print(gp.m.id) diff --git a/src/runtime/proc_test.go b/src/runtime/proc_test.go index a7f791cc79248..f711b88683ef4 100644 --- a/src/runtime/proc_test.go +++ b/src/runtime/proc_test.go @@ -648,7 +648,7 @@ func TestSchedLocalQueueEmpty(t *testing.T) { } func benchmarkStackGrowth(b *testing.B, rec int) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { stackGrowthRecursive(rec) } }) } @@ -672,7 +672,7 @@ func BenchmarkCreateGoroutinesParallel(b *testing.B) { func benchmarkCreateGoroutines(b *testing.B, procs int) { c := make(chan bool) var f func(n int) - f = func { n | + f = func { n -> if n == 0 { c <- true return @@ -783,7 +783,7 @@ func benchmarkWakeupParallel(b *testing.B, spin func(time.Duration)) { 50 * time.Microsecond, 100 * time.Microsecond, } { - b.Run(delay.String(), func { b | + b.Run(delay.String(), func { b -> if b.N == 0 { return } @@ -854,7 +854,7 @@ func benchmarkWakeupParallel(b *testing.B, spin func(time.Duration)) { } func BenchmarkWakeupParallelSpinning(b *testing.B) { - benchmarkWakeupParallel(b, func { d | + benchmarkWakeupParallel(b, func { d -> end := time.Now().Add(d) for time.Now().Before(end) { // do nothing @@ -872,7 +872,7 @@ func BenchmarkWakeupParallelSyscall(b *testing.B) { if sysNanosleep == nil { b.Skipf("skipping on %v; sysNanosleep not defined", runtime.GOOS) } - benchmarkWakeupParallel(b, func { d | sysNanosleep(d) }) + benchmarkWakeupParallel(b, func { d -> sysNanosleep(d) }) } type Matrix [][]float64 @@ -1087,7 +1087,7 @@ func TestPreemptionAfterSyscall(t *testing.T) { for _, i := range []time.Duration{10, 100, 1000} { d := i * time.Microsecond - t.Run(fmt.Sprint(d), func { t | testPreemptionAfterSyscall(t, d) }) + t.Run(fmt.Sprint(d), func { t -> testPreemptionAfterSyscall(t, d) }) } } diff --git a/src/runtime/profbuf_test.go b/src/runtime/profbuf_test.go index 08527076be2da..07a2e91153bc7 100644 --- a/src/runtime/profbuf_test.go +++ b/src/runtime/profbuf_test.go @@ -55,7 +55,7 @@ func TestProfBuf(t *testing.T) { myTags := make([]byte, 100) t.Logf("myTags is %p", &myTags[0]) - t.Run("BasicWriteRead", func { t | + t.Run("BasicWriteRead", func { t -> b := NewProfBuf(2, 11, 1) write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) read(t, b, []uint64{10, 1, 2, 3, 4, 5, 6, 7, 8, 9}, []unsafe.Pointer{unsafe.Pointer(&myTags[0])}) @@ -64,7 +64,7 @@ func TestProfBuf(t *testing.T) { read(t, b, []uint64{8, 99, 101, 102, 201, 202, 203, 204}, []unsafe.Pointer{unsafe.Pointer(&myTags[2])}) }) - t.Run("ReadMany", func { t | + t.Run("ReadMany", func { t -> b := NewProfBuf(2, 50, 50) write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) write(t, b, unsafe.Pointer(&myTags[2]), 99, []uint64{101, 102}, []uintptr{201, 202, 203, 204}) @@ -72,21 +72,21 @@ func TestProfBuf(t *testing.T) { read(t, b, []uint64{10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 99, 101, 102, 201, 202, 203, 204, 5, 500, 502, 504, 506}, []unsafe.Pointer{unsafe.Pointer(&myTags[0]), unsafe.Pointer(&myTags[2]), unsafe.Pointer(&myTags[1])}) }) - t.Run("ReadManyShortData", func { t | + t.Run("ReadManyShortData", func { t -> b := NewProfBuf(2, 50, 50) write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) write(t, b, unsafe.Pointer(&myTags[2]), 99, []uint64{101, 102}, []uintptr{201, 202, 203, 204}) read(t, b, []uint64{10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 99, 101, 102, 201, 202, 203, 204}, []unsafe.Pointer{unsafe.Pointer(&myTags[0]), unsafe.Pointer(&myTags[2])}) }) - t.Run("ReadManyShortTags", func { t | + t.Run("ReadManyShortTags", func { t -> b := NewProfBuf(2, 50, 50) write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) write(t, b, unsafe.Pointer(&myTags[2]), 99, []uint64{101, 102}, []uintptr{201, 202, 203, 204}) read(t, b, []uint64{10, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 99, 101, 102, 201, 202, 203, 204}, []unsafe.Pointer{unsafe.Pointer(&myTags[0]), unsafe.Pointer(&myTags[2])}) }) - t.Run("ReadAfterOverflow1", func { t | + t.Run("ReadAfterOverflow1", func { t -> // overflow record synthesized by write b := NewProfBuf(2, 16, 5) write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) // uses 10 @@ -102,7 +102,7 @@ func TestProfBuf(t *testing.T) { read(t, b, []uint64{5, 99, 0, 0, 300, 5, 500, 502, 504, 506}, []unsafe.Pointer{nil, unsafe.Pointer(&myTags[1])}) }) - t.Run("ReadAfterOverflow2", func { t | + t.Run("ReadAfterOverflow2", func { t -> // overflow record synthesized by read b := NewProfBuf(2, 16, 5) write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) @@ -117,7 +117,7 @@ func TestProfBuf(t *testing.T) { read(t, b, []uint64{5, 500, 502, 505, 506}, []unsafe.Pointer{unsafe.Pointer(&myTags[1])}) }) - t.Run("ReadAtEndAfterOverflow", func { t | + t.Run("ReadAtEndAfterOverflow", func { t -> b := NewProfBuf(2, 12, 5) write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) write(t, b, unsafe.Pointer(&myTags[2]), 99, []uint64{101, 102}, []uintptr{201, 202, 203, 204}) @@ -130,7 +130,7 @@ func TestProfBuf(t *testing.T) { read(t, b, []uint64{5, 500, 502, 504, 506}, []unsafe.Pointer{unsafe.Pointer(&myTags[1])}) }) - t.Run("BlockingWriteRead", func { t | + t.Run("BlockingWriteRead", func { t -> b := NewProfBuf(2, 11, 1) wait := readBlock(t, b, []uint64{10, 1, 2, 3, 4, 5, 6, 7, 8, 9}, []unsafe.Pointer{unsafe.Pointer(&myTags[0])}) write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) @@ -147,7 +147,7 @@ func TestProfBuf(t *testing.T) { readEOF(t, b) }) - t.Run("DataWraparound", func { t | + t.Run("DataWraparound", func { t -> b := NewProfBuf(2, 16, 1024) for i := 0; i < 10; i++ { write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) @@ -156,7 +156,7 @@ func TestProfBuf(t *testing.T) { } }) - t.Run("TagWraparound", func { t | + t.Run("TagWraparound", func { t -> b := NewProfBuf(2, 1024, 2) for i := 0; i < 10; i++ { write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) @@ -165,7 +165,7 @@ func TestProfBuf(t *testing.T) { } }) - t.Run("BothWraparound", func { t | + t.Run("BothWraparound", func { t -> b := NewProfBuf(2, 16, 2) for i := 0; i < 10; i++ { write(t, b, unsafe.Pointer(&myTags[0]), 1, []uint64{2, 3}, []uintptr{4, 5, 6, 7, 8, 9}) diff --git a/src/runtime/rand_test.go b/src/runtime/rand_test.go index a7b85c69d1296..d936a7ae045df 100644 --- a/src/runtime/rand_test.go +++ b/src/runtime/rand_test.go @@ -23,13 +23,13 @@ func TestReadRandom(t *testing.T) { } func BenchmarkFastrand(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { Fastrand() } }) } func BenchmarkFastrand64(b *testing.B) { - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { Fastrand64() } }) } @@ -39,7 +39,7 @@ func BenchmarkFastrandHashiter(b *testing.B) { for i := 0; i < 10; i++ { m[i] = i } - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { for range m { break } @@ -50,7 +50,7 @@ var sink32 uint32 func BenchmarkFastrandn(b *testing.B) { for n := uint32(2); n <= 5; n++ { - b.Run(strconv.Itoa(int(n)), func { b | for i := 0; i < b.N; i++ { + b.Run(strconv.Itoa(int(n)), func { b -> for i := 0; i < b.N; i++ { sink32 = Fastrandn(n) } }) } diff --git a/src/runtime/runtime_linux_test.go b/src/runtime/runtime_linux_test.go index e7a77936428b5..bfcfbc0141238 100644 --- a/src/runtime/runtime_linux_test.go +++ b/src/runtime/runtime_linux_test.go @@ -23,7 +23,7 @@ func init() { pid, tid = syscall.Getpid(), syscall.Gettid() LockOSThread() - sysNanosleep = func { d | + sysNanosleep = func { d -> // Invoke a blocking syscall directly; calling time.Sleep() // would deschedule the goroutine instead. ts := syscall.NsecToTimespec(d.Nanoseconds()) diff --git a/src/runtime/runtime_test.go b/src/runtime/runtime_test.go index 91332cb616799..3751a780d8cd7 100644 --- a/src/runtime/runtime_test.go +++ b/src/runtime/runtime_test.go @@ -390,7 +390,7 @@ func BenchmarkGoroutineProfile(b *testing.B) { return func(b *testing.B) { b.Run("idle", runOne) - b.Run("loaded", func { b | + b.Run("loaded", func { b -> stop := applyGCLoad(b) runOne(b) // Make sure to stop the timer before we wait! The load created above @@ -517,7 +517,7 @@ func TestTimediv(t *testing.T) { }, } { name := fmt.Sprintf("%d div %d", tc.num, tc.div) - t.Run(name, func { t | + t.Run(name, func { t -> // Double check that the inputs make sense using // standard 64-bit division. ret64 := tc.num / int64(tc.div) diff --git a/src/runtime/rwmutex_test.go b/src/runtime/rwmutex_test.go index f7d65ff4919d6..a1ef77d468088 100644 --- a/src/runtime/rwmutex_test.go +++ b/src/runtime/rwmutex_test.go @@ -141,7 +141,7 @@ func BenchmarkRWMutexUncontended(b *testing.B) { RWMutex pad [32]uint32 } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var rwm PaddedRWMutex rwm.Init() for pb.Next() { @@ -158,7 +158,7 @@ func BenchmarkRWMutexUncontended(b *testing.B) { func benchmarkRWMutex(b *testing.B, localWork, writeRatio int) { var rwm RWMutex rwm.Init() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> foo := 0 for pb.Next() { foo++ diff --git a/src/runtime/sema_test.go b/src/runtime/sema_test.go index 844b9d0bf6e5f..12af79ef9a3b0 100644 --- a/src/runtime/sema_test.go +++ b/src/runtime/sema_test.go @@ -105,7 +105,7 @@ func testSemaHandoff() bool { func BenchmarkSemTable(b *testing.B) { for _, n := range []int{1000, 2000, 4000, 8000} { - b.Run(fmt.Sprintf("OneAddrCollision/n=%d", n), func { b | + b.Run(fmt.Sprintf("OneAddrCollision/n=%d", n), func { b -> tab := Escape(new(SemTable)) u := make([]uint32, SemTableSize+1) @@ -144,7 +144,7 @@ func BenchmarkSemTable(b *testing.B) { } } }) - b.Run(fmt.Sprintf("ManyAddrCollision/n=%d", n), func { b | + b.Run(fmt.Sprintf("ManyAddrCollision/n=%d", n), func { b -> tab := Escape(new(SemTable)) u := make([]uint32, n*SemTableSize) diff --git a/src/runtime/slice_test.go b/src/runtime/slice_test.go index ec160c6f441e6..4f3686795b47b 100644 --- a/src/runtime/slice_test.go +++ b/src/runtime/slice_test.go @@ -16,22 +16,22 @@ func BenchmarkMakeSliceCopy(b *testing.B) { var bytes = make([]byte, 8*length) var ints = make([]int, length) var ptrs = make([]*byte, length) - b.Run("mallocmove", func { b | - b.Run("Byte", func { b | + b.Run("mallocmove", func { b -> + b.Run("Byte", func { b -> var x []byte for i := 0; i < b.N; i++ { x = make([]byte, len(bytes)) copy(x, bytes) } }) - b.Run("Int", func { b | + b.Run("Int", func { b -> var x []int for i := 0; i < b.N; i++ { x = make([]int, len(ints)) copy(x, ints) } }) - b.Run("Ptr", func { b | + b.Run("Ptr", func { b -> var x []*byte for i := 0; i < b.N; i++ { x = make([]*byte, len(ptrs)) @@ -39,22 +39,22 @@ func BenchmarkMakeSliceCopy(b *testing.B) { } }) }) - b.Run("makecopy", func { b | - b.Run("Byte", func { b | + b.Run("makecopy", func { b -> + b.Run("Byte", func { b -> var x []byte for i := 0; i < b.N; i++ { x = make([]byte, 8*length) copy(x, bytes) } }) - b.Run("Int", func { b | + b.Run("Int", func { b -> var x []int for i := 0; i < b.N; i++ { x = make([]int, length) copy(x, ints) } }) - b.Run("Ptr", func { b | + b.Run("Ptr", func { b -> var x []*byte for i := 0; i < b.N; i++ { x = make([]*byte, length) @@ -62,22 +62,22 @@ func BenchmarkMakeSliceCopy(b *testing.B) { } }) }) - b.Run("nilappend", func { b | - b.Run("Byte", func { b | + b.Run("nilappend", func { b -> + b.Run("Byte", func { b -> var x []byte for i := 0; i < b.N; i++ { x = append([]byte(nil), bytes...) _ = x } }) - b.Run("Int", func { b | + b.Run("Int", func { b -> var x []int for i := 0; i < b.N; i++ { x = append([]int(nil), ints...) _ = x } }) - b.Run("Ptr", func { b | + b.Run("Ptr", func { b -> var x []*byte for i := 0; i < b.N; i++ { x = append([]*byte(nil), ptrs...) @@ -95,50 +95,50 @@ type ( func BenchmarkMakeSlice(b *testing.B) { const length = 2 - b.Run("Byte", func { b | + b.Run("Byte", func { b -> var x []byte for i := 0; i < b.N; i++ { x = make([]byte, length, 2*length) _ = x } }) - b.Run("Int16", func { b | + b.Run("Int16", func { b -> var x []int16 for i := 0; i < b.N; i++ { x = make([]int16, length, 2*length) _ = x } }) - b.Run("Int", func { b | + b.Run("Int", func { b -> var x []int for i := 0; i < b.N; i++ { x = make([]int, length, 2*length) _ = x } }) - b.Run("Ptr", func { b | + b.Run("Ptr", func { b -> var x []*byte for i := 0; i < b.N; i++ { x = make([]*byte, length, 2*length) _ = x } }) - b.Run("Struct", func { b | - b.Run("24", func { b | + b.Run("Struct", func { b -> + b.Run("24", func { b -> var x []struct24 for i := 0; i < b.N; i++ { x = make([]struct24, length, 2*length) _ = x } }) - b.Run("32", func { b | + b.Run("32", func { b -> var x []struct32 for i := 0; i < b.N; i++ { x = make([]struct32, length, 2*length) _ = x } }) - b.Run("40", func { b | + b.Run("40", func { b -> var x []struct40 for i := 0; i < b.N; i++ { x = make([]struct40, length, 2*length) @@ -149,44 +149,44 @@ func BenchmarkMakeSlice(b *testing.B) { } func BenchmarkGrowSlice(b *testing.B) { - b.Run("Byte", func { b | + b.Run("Byte", func { b -> x := make([]byte, 9) for i := 0; i < b.N; i++ { _ = append([]byte(nil), x...) } }) - b.Run("Int16", func { b | + b.Run("Int16", func { b -> x := make([]int16, 9) for i := 0; i < b.N; i++ { _ = append([]int16(nil), x...) } }) - b.Run("Int", func { b | + b.Run("Int", func { b -> x := make([]int, 9) for i := 0; i < b.N; i++ { _ = append([]int(nil), x...) } }) - b.Run("Ptr", func { b | + b.Run("Ptr", func { b -> x := make([]*byte, 9) for i := 0; i < b.N; i++ { _ = append([]*byte(nil), x...) } }) - b.Run("Struct", func { b | - b.Run("24", func { b | + b.Run("Struct", func { b -> + b.Run("24", func { b -> x := make([]struct24, 9) for i := 0; i < b.N; i++ { _ = append([]struct24(nil), x...) } }) - b.Run("32", func { b | + b.Run("32", func { b -> x := make([]struct32, 9) for i := 0; i < b.N; i++ { _ = append([]struct32(nil), x...) } }) - b.Run("40", func { b | + b.Run("40", func { b -> x := make([]struct40, 9) for i := 0; i < b.N; i++ { _ = append([]struct40(nil), x...) @@ -202,21 +202,21 @@ var ( func BenchmarkExtendSlice(b *testing.B) { var length = 4 // Use a variable to prevent stack allocation of slices. - b.Run("IntSlice", func { b | + b.Run("IntSlice", func { b -> s := make([]int, 0, length) for i := 0; i < b.N; i++ { s = append(s[:0:length/2], make([]int, length)...) } SinkIntSlice = s }) - b.Run("PointerSlice", func { b | + b.Run("PointerSlice", func { b -> s := make([]*int, 0, length) for i := 0; i < b.N; i++ { s = append(s[:0:length/2], make([]*int, length)...) } SinkIntPointerSlice = s }) - b.Run("NoGrow", func { b | + b.Run("NoGrow", func { b -> s := make([]int, 0, length) for i := 0; i < b.N; i++ { s = append(s[:0:length], make([]int, length)...) @@ -258,7 +258,7 @@ func BenchmarkAppendGrowString(b *testing.B) { func BenchmarkAppendSlice(b *testing.B) { for _, length := range []int{1, 4, 7, 8, 15, 16, 32} { - b.Run(fmt.Sprint(length, "Bytes"), func { b | + b.Run(fmt.Sprint(length, "Bytes"), func { b -> x := make([]byte, 0, N) y := make([]byte, length) for i := 0; i < b.N; i++ { @@ -276,7 +276,7 @@ var ( func BenchmarkAppendSliceLarge(b *testing.B) { for _, length := range []int{1 << 10, 4 << 10, 16 << 10, 64 << 10, 256 << 10, 1024 << 10} { y := make([]byte, length) - b.Run(fmt.Sprint(length, "Bytes"), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprint(length, "Bytes"), func { b -> for i := 0; i < b.N; i++ { blackhole = nil blackhole = append(blackhole, y...) } }) @@ -291,7 +291,7 @@ func BenchmarkAppendStr(b *testing.B) { "1234567890123456", "12345678901234567890123456789012", } { - b.Run(fmt.Sprint(len(str), "Bytes"), func { b | + b.Run(fmt.Sprint(len(str), "Bytes"), func { b -> x := make([]byte, 0, N) for i := 0; i < b.N; i++ { x = x[0:0] @@ -346,7 +346,7 @@ func TestAppendOverlap(t *testing.T) { func BenchmarkCopy(b *testing.B) { for _, l := range []int{1, 2, 4, 8, 12, 16, 32, 128, 1024} { buf := make([]byte, 4096) - b.Run(fmt.Sprint(l, "Byte"), func { b | + b.Run(fmt.Sprint(l, "Byte"), func { b -> s := make([]byte, l) var n int for i := 0; i < b.N; i++ { @@ -354,7 +354,7 @@ func BenchmarkCopy(b *testing.B) { } b.SetBytes(int64(n)) }) - b.Run(fmt.Sprint(l, "String"), func { b | + b.Run(fmt.Sprint(l, "String"), func { b -> s := string(make([]byte, l)) var n int for i := 0; i < b.N; i++ { @@ -388,10 +388,10 @@ var ( // We benchmark four common sizes (byte, pointer, string/interface, slice), // and one larger size. func BenchmarkAppendInPlace(b *testing.B) { - b.Run("NoGrow", func { b | + b.Run("NoGrow", func { b -> const C = 128 - b.Run("Byte", func { b | + b.Run("Byte", func { b -> for i := 0; i < b.N; i++ { sByte = make([]byte, C) for j := 0; j < C; j++ { @@ -400,7 +400,7 @@ func BenchmarkAppendInPlace(b *testing.B) { } }) - b.Run("1Ptr", func { b | + b.Run("1Ptr", func { b -> for i := 0; i < b.N; i++ { s1Ptr = make([]uintptr, C) for j := 0; j < C; j++ { @@ -409,7 +409,7 @@ func BenchmarkAppendInPlace(b *testing.B) { } }) - b.Run("2Ptr", func { b | + b.Run("2Ptr", func { b -> for i := 0; i < b.N; i++ { s2Ptr = make([][2]uintptr, C) for j := 0; j < C; j++ { @@ -418,7 +418,7 @@ func BenchmarkAppendInPlace(b *testing.B) { } }) - b.Run("3Ptr", func { b | + b.Run("3Ptr", func { b -> for i := 0; i < b.N; i++ { s3Ptr = make([][3]uintptr, C) for j := 0; j < C; j++ { @@ -427,7 +427,7 @@ func BenchmarkAppendInPlace(b *testing.B) { } }) - b.Run("4Ptr", func { b | + b.Run("4Ptr", func { b -> for i := 0; i < b.N; i++ { s4Ptr = make([][4]uintptr, C) for j := 0; j < C; j++ { @@ -437,10 +437,10 @@ func BenchmarkAppendInPlace(b *testing.B) { }) }) - b.Run("Grow", func { b | + b.Run("Grow", func { b -> const C = 5 - b.Run("Byte", func { b | + b.Run("Byte", func { b -> for i := 0; i < b.N; i++ { sByte = make([]byte, 0) for j := 0; j < C; j++ { @@ -450,7 +450,7 @@ func BenchmarkAppendInPlace(b *testing.B) { } }) - b.Run("1Ptr", func { b | + b.Run("1Ptr", func { b -> for i := 0; i < b.N; i++ { s1Ptr = make([]uintptr, 0) for j := 0; j < C; j++ { @@ -460,7 +460,7 @@ func BenchmarkAppendInPlace(b *testing.B) { } }) - b.Run("2Ptr", func { b | + b.Run("2Ptr", func { b -> for i := 0; i < b.N; i++ { s2Ptr = make([][2]uintptr, 0) for j := 0; j < C; j++ { @@ -470,7 +470,7 @@ func BenchmarkAppendInPlace(b *testing.B) { } }) - b.Run("3Ptr", func { b | + b.Run("3Ptr", func { b -> for i := 0; i < b.N; i++ { s3Ptr = make([][3]uintptr, 0) for j := 0; j < C; j++ { @@ -480,7 +480,7 @@ func BenchmarkAppendInPlace(b *testing.B) { } }) - b.Run("4Ptr", func { b | + b.Run("4Ptr", func { b -> for i := 0; i < b.N; i++ { s4Ptr = make([][4]uintptr, 0) for j := 0; j < C; j++ { diff --git a/src/runtime/stack_test.go b/src/runtime/stack_test.go index b2ffad09ac4e6..7f6710e7ada9d 100644 --- a/src/runtime/stack_test.go +++ b/src/runtime/stack_test.go @@ -38,7 +38,7 @@ func TestStackMem(t *testing.T) { for i := 0; i < BatchSize; i++ { go func() { var f func(k int, a [ArraySize]byte) - f = func { k, a | + f = func { k, a -> if k == 0 { time.Sleep(time.Millisecond) return @@ -111,7 +111,7 @@ func TestStackGrowth(t *testing.T) { var progress atomic.Uint32 wg.Add(1) s := new(string) // Must be of a type that avoids the tiny allocator, or else the finalizer might not run. - SetFinalizer(s, func { ss | + SetFinalizer(s, func { ss -> defer wg.Done() finalizerStart = time.Now() started.Store(true) @@ -223,7 +223,7 @@ func TestStackGrowthCallback(t *testing.T) { func growStackWithCallback(cb func()) { var f func(n int) - f = func { n | + f = func { n -> if n == 0 { cb() return @@ -722,10 +722,10 @@ type I interface { } func TestStackWrapperStackPanic(t *testing.T) { - t.Run("sigpanic", func { t | + t.Run("sigpanic", func { t -> // nil calls to interface methods cause a sigpanic. testStackWrapperPanic(t, func() { I.M(nil) }, "runtime_test.I.M") }) - t.Run("panicwrap", func { t | + t.Run("panicwrap", func { t -> // Nil calls to value method wrappers call panicwrap. wrapper := (*structWithMethod).nop testStackWrapperPanic(t, func() { wrapper(nil) }, "runtime_test.(*structWithMethod).nop") @@ -735,7 +735,7 @@ func TestStackWrapperStackPanic(t *testing.T) { func testStackWrapperPanic(t *testing.T, cb func(), expect string) { // Test that the stack trace from a panicking wrapper includes // the wrapper, even though elide these when they don't panic. - t.Run("CallersFrames", func { t | + t.Run("CallersFrames", func { t -> defer func() { err := recover() if err == nil { @@ -758,7 +758,7 @@ func testStackWrapperPanic(t *testing.T, cb func(), expect string) { }() cb() }) - t.Run("Stack", func { t | + t.Run("Stack", func { t -> defer func() { err := recover() if err == nil { diff --git a/src/runtime/start_line_test.go b/src/runtime/start_line_test.go index 4595c7d411e51..bab3d5762e5c1 100644 --- a/src/runtime/start_line_test.go +++ b/src/runtime/start_line_test.go @@ -107,7 +107,7 @@ func TestStartLine(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> got := tc.fn() if got != tc.want { t.Errorf("start line got %d want %d", got, tc.want) diff --git a/src/runtime/string_test.go b/src/runtime/string_test.go index c91cdb716fa89..861f8b1d07f8f 100644 --- a/src/runtime/string_test.go +++ b/src/runtime/string_test.go @@ -96,7 +96,7 @@ var escapeString string func BenchmarkSliceByteToString(b *testing.B) { buf := []byte{'!'} for n := 0; n < 8; n++ { - b.Run(strconv.Itoa(len(buf)), func { b | for i := 0; i < b.N; i++ { + b.Run(strconv.Itoa(len(buf)), func { b -> for i := 0; i < b.N; i++ { escapeString = string(buf) } }) buf = append(buf, buf...) @@ -113,16 +113,16 @@ var sinkInt int func BenchmarkRuneCount(b *testing.B) { // Each sub-benchmark counts the runes in a string in a different way. - b.Run("lenruneslice", func { b | + b.Run("lenruneslice", func { b -> for _, sd := range stringdata { - b.Run(sd.name, func { b | for i := 0; i < b.N; i++ { + b.Run(sd.name, func { b -> for i := 0; i < b.N; i++ { sinkInt += len([]rune(sd.data)) } }) } }) - b.Run("rangeloop", func { b | + b.Run("rangeloop", func { b -> for _, sd := range stringdata { - b.Run(sd.name, func { b | + b.Run(sd.name, func { b -> for i := 0; i < b.N; i++ { n := 0 for range sd.data { @@ -133,9 +133,9 @@ func BenchmarkRuneCount(b *testing.B) { }) } }) - b.Run("utf8.RuneCountInString", func { b | + b.Run("utf8.RuneCountInString", func { b -> for _, sd := range stringdata { - b.Run(sd.name, func { b | for i := 0; i < b.N; i++ { + b.Run(sd.name, func { b -> for i := 0; i < b.N; i++ { sinkInt += utf8.RuneCountInString(sd.data) } }) } @@ -143,25 +143,25 @@ func BenchmarkRuneCount(b *testing.B) { } func BenchmarkRuneIterate(b *testing.B) { - b.Run("range", func { b | + b.Run("range", func { b -> for _, sd := range stringdata { - b.Run(sd.name, func { b | for i := 0; i < b.N; i++ { + b.Run(sd.name, func { b -> for i := 0; i < b.N; i++ { for range sd.data { } } }) } }) - b.Run("range1", func { b | + b.Run("range1", func { b -> for _, sd := range stringdata { - b.Run(sd.name, func { b | for i := 0; i < b.N; i++ { + b.Run(sd.name, func { b -> for i := 0; i < b.N; i++ { for range sd.data { } } }) } }) - b.Run("range2", func { b | + b.Run("range2", func { b -> for _, sd := range stringdata { - b.Run(sd.name, func { b | for i := 0; i < b.N; i++ { + b.Run(sd.name, func { b -> for i := 0; i < b.N; i++ { for range sd.data { } } }) diff --git a/src/runtime/symtab_test.go b/src/runtime/symtab_test.go index ccfa8fcf368c0..a19de9c8e09a7 100644 --- a/src/runtime/symtab_test.go +++ b/src/runtime/symtab_test.go @@ -258,7 +258,7 @@ func BenchmarkFunc(b *testing.B) { b.Fatal("failed to look up PC") } f := runtime.FuncForPC(pc) - b.Run("Name", func { b | + b.Run("Name", func { b -> for i := 0; i < b.N; i++ { name := f.Name() if name != "runtime_test.BenchmarkFunc" { @@ -266,13 +266,13 @@ func BenchmarkFunc(b *testing.B) { } } }) - b.Run("Entry", func { b | for i := 0; i < b.N; i++ { + b.Run("Entry", func { b -> for i := 0; i < b.N; i++ { pc := f.Entry() if pc == 0 { b.Fatal("zero PC") } } }) - b.Run("FileLine", func { b | + b.Run("FileLine", func { b -> for i := 0; i < b.N; i++ { file, line := f.FileLine(pc) if !strings.HasSuffix(file, "symtab_test.go") || line == 0 { diff --git a/src/runtime/syscall_windows_test.go b/src/runtime/syscall_windows_test.go index 6a2edcdc2c5f5..f0d87ea47dc0b 100644 --- a/src/runtime/syscall_windows_test.go +++ b/src/runtime/syscall_windows_test.go @@ -138,7 +138,7 @@ func TestEnumWindows(t *testing.T) { d := GetDLL(t, "user32.dll") isWindows := d.Proc("IsWindow") counter := 0 - cb := syscall.NewCallback(func { hwnd, lparam | + cb := syscall.NewCallback(func { hwnd, lparam -> if lparam != 888 { t.Error("lparam was not passed to callback") } @@ -562,16 +562,16 @@ func TestStdcallAndCDeclCallbacks(t *testing.T) { defer runtime.SetIntArgRegs(oldRegs) for _, dll := range cbDLLs { - t.Run(dll.name, func { t | + t.Run(dll.name, func { t -> dllPath := dll.build(t, tmp) dll := syscall.MustLoadDLL(dllPath) defer dll.Release() for _, cbf := range getCallbackTestFuncs() { - t.Run(cbf.cName(false), func { t | + t.Run(cbf.cName(false), func { t -> stdcall := syscall.NewCallback(cbf.goFunc) cbf.testOne(t, dll, false, stdcall) }) - t.Run(cbf.cName(true), func { t | + t.Run(cbf.cName(true), func { t -> cdecl := syscall.NewCallbackCDecl(cbf.goFunc) cbf.testOne(t, dll, true, cdecl) }) @@ -688,7 +688,7 @@ func use(buf []byte) { func forceStackCopy() (r int) { var f func(int) int - f = func { i | + f = func { i -> var buf [256]byte use(buf[:]) if i == 0 { @@ -739,7 +739,7 @@ uintptr_t cfunc(callback f, uintptr_t n) { proc := dll.MustFindProc("cfunc") - cb := syscall.NewCallback(func { n | + cb := syscall.NewCallback(func { n -> forceStackCopy() return n }) @@ -774,7 +774,7 @@ func TestSyscallN(t *testing.T) { for arglen := 0; arglen <= runtime.MaxArgs; arglen++ { arglen := arglen - t.Run(fmt.Sprintf("arg-%d", arglen), func { t | + t.Run(fmt.Sprintf("arg-%d", arglen), func { t -> t.Parallel() args := make([]string, arglen) rets := make([]string, arglen+1) diff --git a/src/runtime/trace.go b/src/runtime/trace.go index 300456e19e9f5..6d0c9d6884e60 100644 --- a/src/runtime/trace.go +++ b/src/runtime/trace.go @@ -357,7 +357,7 @@ func traceAdvance(stopTrace bool) { inMarkAssist bool } var untracedGs []untracedG - forEachGRace(func { gp | + forEachGRace(func { gp -> // Make absolutely sure all Gs are ready for the next // generation. We need to do this even for dead Gs because // they may come alive with a new identity, and its status @@ -635,7 +635,7 @@ func traceAdvance(stopTrace bool) { // preempt all Ps anyway, might as well stay consistent with StartTrace // which does this during the STW. semacquire(&worldsema) - forEachP(waitReasonTraceProcStatus, func { pp | + forEachP(waitReasonTraceProcStatus, func { pp -> tl := traceAcquire() if !pp.trace.statusWasTraced(tl.gen) { tl.writer().writeProcStatusForP(pp, false).end() @@ -754,7 +754,7 @@ top: buf, park = readTrace0() }) if park { - gopark(func { gp, _ | + gopark(func { gp, _ -> if !trace.reader.CompareAndSwapNoWB(nil, gp) { // We're racing with another reader. // Wake up and handle this case. diff --git a/src/runtime/trace/annotation_test.go b/src/runtime/trace/annotation_test.go index 36491a4606165..f0d2cfb041a12 100644 --- a/src/runtime/trace/annotation_test.go +++ b/src/runtime/trace/annotation_test.go @@ -15,7 +15,7 @@ func BenchmarkStartRegion(b *testing.B) { ctx, task := NewTask(context.Background(), "benchmark") defer task.End() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { StartRegion(ctx, "region").End() } }) } @@ -25,7 +25,7 @@ func BenchmarkNewTask(b *testing.B) { pctx, task := NewTask(context.Background(), "benchmark") defer task.End() - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { _, task := NewTask(pctx, "task") task.End() } }) diff --git a/src/runtime/trace_cgo_test.go b/src/runtime/trace_cgo_test.go index c16fac43ec70a..b5df557d5ac48 100644 --- a/src/runtime/trace_cgo_test.go +++ b/src/runtime/trace_cgo_test.go @@ -94,7 +94,7 @@ func mustFindLogV2(t *testing.T, trc io.Reader, category string) trace.Event { // dumpStack returns e.Stack() as a string. func dumpStackV2(e *trace.Event) string { var buf bytes.Buffer - e.Stack().Frames(func { f | + e.Stack().Frames(func { f -> file := strings.TrimPrefix(f.File, runtime.GOROOT()) fmt.Fprintf(&buf, "%s\n\t%s:%d\n", f.Func, file, f.Line) return true diff --git a/src/runtime/traceallocfree.go b/src/runtime/traceallocfree.go index 859b290160f35..9d492fe24cf3e 100644 --- a/src/runtime/traceallocfree.go +++ b/src/runtime/traceallocfree.go @@ -74,7 +74,7 @@ func traceSnapshotMemory(gen uintptr) { } // Write out all the goroutine stacks. - forEachGRace(func { gp | trace.GoroutineStackExists(gp.stack.lo, gp.stack.hi-gp.stack.lo) }) + forEachGRace(func { gp -> trace.GoroutineStackExists(gp.stack.lo, gp.stack.hi-gp.stack.lo) }) traceRelease(trace) } diff --git a/src/runtime/traceback.go b/src/runtime/traceback.go index 9158c3b3c3d13..23464abec0781 100644 --- a/src/runtime/traceback.go +++ b/src/runtime/traceback.go @@ -1260,7 +1260,7 @@ func tracebackothers(me *g) { // Instead, use forEachGRace, which requires no locking. We don't lock // against concurrent creation of new Gs, but even with allglock we may // miss Gs created after this loop. - forEachGRace(func { gp | + forEachGRace(func { gp -> if gp == me || gp == curgp || readgstatus(gp) == _Gdead || isSystemGoroutine(gp, false) && level < 2 { return } @@ -1313,7 +1313,7 @@ func tracebackHexdump(stk stack, frame *stkframe, bad uintptr) { // Print the hex dump. print("stack: frame={sp:", hex(frame.sp), ", fp:", hex(frame.fp), "} stack=[", hex(stk.lo), ",", hex(stk.hi), ")\n") - hexdumpWords(lo, hi, func { p | + hexdumpWords(lo, hi, func { p -> switch p { case frame.fp: return '>' diff --git a/src/runtime/traceback_test.go b/src/runtime/traceback_test.go index b0e358fe66ed1..7ec9579a72722 100644 --- a/src/runtime/traceback_test.go +++ b/src/runtime/traceback_test.go @@ -53,25 +53,25 @@ func TestTracebackInlined(t *testing.T) { } } - t.Run("simple", func { t | + t.Run("simple", func { t -> // Check a simple case of inlining r := ttiSimple1() check(t, r, "runtime_test.ttiSimple3(...)", "runtime_test.ttiSimple2(...)", "runtime_test.ttiSimple1()") }) - t.Run("sigpanic", func { t | + t.Run("sigpanic", func { t -> // Check that sigpanic from an inlined function prints correctly r := ttiSigpanic1() check(t, r, "runtime_test.ttiSigpanic1.func1()", "panic", "runtime_test.ttiSigpanic3(...)", "runtime_test.ttiSigpanic2(...)", "runtime_test.ttiSigpanic1()") }) - t.Run("wrapper", func { t | + t.Run("wrapper", func { t -> // Check that a method inlined into a wrapper prints correctly r := ttiWrapper1() check(t, r, "runtime_test.ttiWrapper.m1(...)", "runtime_test.ttiWrapper1()") }) - t.Run("excluded", func { t | + t.Run("excluded", func { t -> // Check that when F -> G is inlined and F is excluded from stack // traces, G still appears. r := ttiExcluded1() @@ -166,7 +166,7 @@ func TestTracebackElision(t *testing.T) { // in the paused physical frame, and eliding 10 so we have to advance the // physical frame forward. for _, elided := range []int{0, 1, 10} { - t.Run(fmt.Sprintf("elided=%d", elided), func { t | + t.Run(fmt.Sprintf("elided=%d", elided), func { t -> n := elided + runtime.TracebackInnerFrames + runtime.TracebackOuterFrames // Start a new goroutine so we have control over the whole stack. diff --git a/src/slices/example_test.go b/src/slices/example_test.go index 95d110c3f95ce..8d06857edee32 100644 --- a/src/slices/example_test.go +++ b/src/slices/example_test.go @@ -33,7 +33,7 @@ func ExampleBinarySearchFunc() { {"Bob", 24}, {"Gopher", 13}, } - n, found := slices.BinarySearchFunc(people, Person{"Bob", 0}, func { a, b | return strings.Compare(a.Name, b.Name) }) + n, found := slices.BinarySearchFunc(people, Person{"Bob", 0}, func { a, b -> return strings.Compare(a.Name, b.Name) }) fmt.Println("Bob:", n, found) // Output: // Bob: 1 true @@ -71,7 +71,7 @@ func ExampleCompare() { func ExampleCompareFunc() { numbers := []int{0, 43, 8} strings := []string{"0", "0", "8"} - result := slices.CompareFunc(numbers, strings, func { n, s | + result := slices.CompareFunc(numbers, strings, func { n, s -> sn, err := strconv.Atoi(s) if err != nil { return 1 @@ -85,9 +85,9 @@ func ExampleCompareFunc() { func ExampleContainsFunc() { numbers := []int{0, 42, -10, 8} - hasNegative := slices.ContainsFunc(numbers, func { n | return n < 0 }) + hasNegative := slices.ContainsFunc(numbers, func { n -> return n < 0 }) fmt.Println("Has a negative:", hasNegative) - hasOdd := slices.ContainsFunc(numbers, func { n | return n%2 != 0 }) + hasOdd := slices.ContainsFunc(numbers, func { n -> return n%2 != 0 }) fmt.Println("Has an odd number:", hasOdd) // Output: // Has a negative: true @@ -104,7 +104,7 @@ func ExampleDelete() { func ExampleDeleteFunc() { seq := []int{0, 1, 1, 2, 3, 5, 8} - seq = slices.DeleteFunc(seq, func { n | return n%2 != 0 })// delete the odd numbers + seq = slices.DeleteFunc(seq, func { n -> return n%2 != 0 })// delete the odd numbers fmt.Println(seq) // Output: @@ -123,7 +123,7 @@ func ExampleEqual() { func ExampleEqualFunc() { numbers := []int{0, 42, 8} strings := []string{"000", "42", "0o10"} - equal := slices.EqualFunc(numbers, strings, func { n, s | + equal := slices.EqualFunc(numbers, strings, func { n, s -> sn, err := strconv.ParseInt(s, 0, 64) if err != nil { return false @@ -146,7 +146,7 @@ func ExampleIndex() { func ExampleIndexFunc() { numbers := []int{0, 42, -10, 8} - i := slices.IndexFunc(numbers, func { n | return n < 0 }) + i := slices.IndexFunc(numbers, func { n -> return n < 0 }) fmt.Println("First negative at index", i) // Output: // First negative at index 2 @@ -171,7 +171,7 @@ func ExampleIsSorted() { func ExampleIsSortedFunc() { names := []string{"alice", "Bob", "VERA"} - isSortedInsensitive := slices.IsSortedFunc(names, func { a, b | return strings.Compare(strings.ToLower(a), strings.ToLower(b)) }) + isSortedInsensitive := slices.IsSortedFunc(names, func { a, b -> return strings.Compare(strings.ToLower(a), strings.ToLower(b)) }) fmt.Println(isSortedInsensitive) fmt.Println(slices.IsSorted(names)) // Output: @@ -197,7 +197,7 @@ func ExampleMaxFunc() { {"Vera", 24}, {"Bob", 55}, } - firstOldest := slices.MaxFunc(people, func { a, b | return cmp.Compare(a.Age, b.Age) }) + firstOldest := slices.MaxFunc(people, func { a, b -> return cmp.Compare(a.Age, b.Age) }) fmt.Println(firstOldest.Name) // Output: // Alice @@ -221,7 +221,7 @@ func ExampleMinFunc() { {"Vera", 24}, {"Bill", 5}, } - firstYoungest := slices.MinFunc(people, func { a, b | return cmp.Compare(a.Age, b.Age) }) + firstYoungest := slices.MinFunc(people, func { a, b -> return cmp.Compare(a.Age, b.Age) }) fmt.Println(firstYoungest.Name) // Output: // Bob @@ -253,7 +253,7 @@ func ExampleSort() { func ExampleSortFunc_caseInsensitive() { names := []string{"Bob", "alice", "VERA"} - slices.SortFunc(names, func { a, b | return strings.Compare(strings.ToLower(a), strings.ToLower(b)) }) + slices.SortFunc(names, func { a, b -> return strings.Compare(strings.ToLower(a), strings.ToLower(b)) }) fmt.Println(names) // Output: // [alice Bob VERA] @@ -270,7 +270,7 @@ func ExampleSortFunc_multiField() { {"Bob", 24}, {"Alice", 20}, } - slices.SortFunc(people, func { a, b | + slices.SortFunc(people, func { a, b -> if n := strings.Compare(a.Name, b.Name); n != 0 { return n } @@ -294,7 +294,7 @@ func ExampleSortStableFunc() { {"Alice", 55}, } // Stable sort by name, keeping age ordering of Alices intact - slices.SortStableFunc(people, func { a, b | return strings.Compare(a.Name, b.Name) }) + slices.SortStableFunc(people, func { a, b -> return strings.Compare(a.Name, b.Name) }) fmt.Println(people) // Output: // [{Alice 20} {Alice 55} {Bob 24} {Gopher 13}] diff --git a/src/slices/iter_test.go b/src/slices/iter_test.go index 849b5234dda31..fcf7ab64680b9 100644 --- a/src/slices/iter_test.go +++ b/src/slices/iter_test.go @@ -140,7 +140,7 @@ func TestSorted(t *testing.T) { } func TestSortedFunc(t *testing.T) { - s := SortedFunc(Values(ints[:]), func { a, b | return a - b }) + s := SortedFunc(Values(ints[:]), func { a, b -> return a - b }) if !IsSorted(s) { t.Errorf("sorted %v", ints) t.Errorf(" got %v", s) @@ -229,7 +229,7 @@ func TestChunk(t *testing.T) { } for _, tc := range cases { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> var chunks [][]int for c := range Chunk(tc.s, tc.n) { chunks = append(chunks, c) diff --git a/src/slices/slices_test.go b/src/slices/slices_test.go index b230d4efa5570..b28ae50900432 100644 --- a/src/slices/slices_test.go +++ b/src/slices/slices_test.go @@ -132,7 +132,7 @@ func BenchmarkEqualFunc_Large(b *testing.B) { xs := make([]Large, 1024) ys := make([]Large, 1024) for i := 0; i < b.N; i++ { - _ = EqualFunc(xs, ys, func { x, y | return x == y }) + _ = EqualFunc(xs, ys, func { x, y -> return x == y }) } } @@ -419,7 +419,7 @@ func BenchmarkIndexFunc_Large(b *testing.B) { ss := make([]Large, 1024) for i := 0; i < b.N; i++ { - _ = IndexFunc(ss, func { e | return e == Large{1} }) + _ = IndexFunc(ss, func { e -> return e == Large{1} }) } } @@ -708,7 +708,7 @@ func TestDeleteFuncClearTail(t *testing.T) { *mem[2], *mem[3] = 42, 42 s := mem[0:5] // there is 1 element beyond len(s), within cap(s) - s = DeleteFunc(s, func { i | return i != nil && *i == 42 }) + s = DeleteFunc(s, func { i -> return i != nil && *i == 42 }) if mem[3] != nil || mem[4] != nil { // Check that potential memory leak is avoided @@ -786,7 +786,7 @@ func TestCompact(t *testing.T) { func BenchmarkCompact(b *testing.B) { for _, c := range compactTests { - b.Run(c.name, func { b | + b.Run(c.name, func { b -> ss := make([]int, 0, 64) for k := 0; k < b.N; k++ { ss = ss[:0] @@ -801,14 +801,14 @@ func BenchmarkCompact_Large(b *testing.B) { type Large [16]int const N = 1024 - b.Run("all_dup", func { b | + b.Run("all_dup", func { b -> ss := make([]Large, N) b.ResetTimer() for i := 0; i < b.N; i++ { _ = Compact(ss) } }) - b.Run("no_dup", func { b | + b.Run("no_dup", func { b -> ss := make([]Large, N) for i := range ss { ss[i][0] = i @@ -863,7 +863,7 @@ func TestCompactFuncClearTail(t *testing.T) { s := mem[0:5] // there is 1 element beyond len(s), within cap(s) copy := Clone(s) - s = CompactFunc(s, func { x, y | + s = CompactFunc(s, func { x, y -> if x == nil || y == nil { return x == y } @@ -885,12 +885,12 @@ func TestCompactFuncClearTail(t *testing.T) { func BenchmarkCompactFunc(b *testing.B) { for _, c := range compactTests { - b.Run(c.name, func { b | + b.Run(c.name, func { b -> ss := make([]int, 0, 64) for k := 0; k < b.N; k++ { ss = ss[:0] ss = append(ss, c.s...) - _ = CompactFunc(ss, func { a, b | return a == b }) + _ = CompactFunc(ss, func { a, b -> return a == b }) } }) } @@ -900,21 +900,21 @@ func BenchmarkCompactFunc_Large(b *testing.B) { type Element = int const N = 1024 * 1024 - b.Run("all_dup", func { b | + b.Run("all_dup", func { b -> ss := make([]Element, N) b.ResetTimer() for i := 0; i < b.N; i++ { - _ = CompactFunc(ss, func { a, b | return a == b }) + _ = CompactFunc(ss, func { a, b -> return a == b }) } }) - b.Run("no_dup", func { b | + b.Run("no_dup", func { b -> ss := make([]Element, N) for i := range ss { ss[i] = i } b.ResetTimer() for i := 0; i < b.N; i++ { - _ = CompactFunc(ss, func { a, b | return a == b }) + _ = CompactFunc(ss, func { a, b -> return a == b }) } }) } @@ -1201,14 +1201,14 @@ func BenchmarkReplace(b *testing.B) { } for _, c := range cases { - b.Run("naive-"+c.name, func { b | + b.Run("naive-"+c.name, func { b -> for k := 0; k < b.N; k++ { s := c.s() v := c.v() _ = naiveReplace(s, c.i, c.j, v...) } }) - b.Run("optimized-"+c.name, func { b | for k := 0; k < b.N; k++ { + b.Run("optimized-"+c.name, func { b -> for k := 0; k < b.N; k++ { s := c.s() v := c.v() _ = Replace(s, c.i, c.j, v...) diff --git a/src/slices/sort_benchmark_test.go b/src/slices/sort_benchmark_test.go index f48546a10a594..ff90515fe7777 100644 --- a/src/slices/sort_benchmark_test.go +++ b/src/slices/sort_benchmark_test.go @@ -14,7 +14,7 @@ import ( func BenchmarkBinarySearchFloats(b *testing.B) { for _, size := range []int{16, 32, 64, 128, 512, 1024} { - b.Run(fmt.Sprintf("Size%d", size), func { b | + b.Run(fmt.Sprintf("Size%d", size), func { b -> floats := make([]float64, size) for i := range floats { floats[i] = float64(i) @@ -36,7 +36,7 @@ type myStruct struct { func BenchmarkBinarySearchFuncStruct(b *testing.B) { for _, size := range []int{16, 32, 64, 128, 512, 1024} { - b.Run(fmt.Sprintf("Size%d", size), func { b | + b.Run(fmt.Sprintf("Size%d", size), func { b -> structs := make([]*myStruct, size) for i := range structs { structs[i] = &myStruct{n: i} @@ -54,7 +54,7 @@ func BenchmarkBinarySearchFuncStruct(b *testing.B) { func BenchmarkSortFuncStruct(b *testing.B) { for _, size := range []int{16, 32, 64, 128, 512, 1024} { - b.Run(fmt.Sprintf("Size%d", size), func { b | + b.Run(fmt.Sprintf("Size%d", size), func { b -> structs := make([]*myStruct, size) for i := range structs { structs[i] = &myStruct{ @@ -73,7 +73,7 @@ func BenchmarkSortFuncStruct(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { // Sort the slice twice because slices.SortFunc modifies the slice in place. - slices.SortFunc(structs, func { a, b | return cmpFunc(b, a) }) + slices.SortFunc(structs, func { a, b -> return cmpFunc(b, a) }) slices.SortFunc(structs, cmpFunc) } }) diff --git a/src/slices/sort_test.go b/src/slices/sort_test.go index 1a87710117b8a..a450fd9f95aea 100644 --- a/src/slices/sort_test.go +++ b/src/slices/sort_test.go @@ -30,7 +30,7 @@ func TestSortIntSlice(t *testing.T) { func TestSortFuncIntSlice(t *testing.T) { data := Clone(ints[:]) - SortFunc(data, func { a, b | return a - b }) + SortFunc(data, func { a, b -> return a - b }) if !IsSorted(data) { t.Errorf("sorted %v", ints) t.Errorf(" got %v", data) @@ -190,7 +190,7 @@ func TestMinMax(t *testing.T) { {[]int{0, 2, -9}, -9, 2}, } for _, tt := range tests { - t.Run(fmt.Sprintf("%v", tt.data), func { t | + t.Run(fmt.Sprintf("%v", tt.data), func { t -> gotMin := Min(tt.data) if gotMin != tt.wantMin { t.Errorf("Min got %v, want %v", gotMin, tt.wantMin) @@ -341,7 +341,7 @@ func TestBinarySearch(t *testing.T) { {strSame, "zz", 3, false}, } for _, tt := range tests { - t.Run(tt.target, func { t | + t.Run(tt.target, func { t -> { pos, found := BinarySearch(tt.data, tt.target) if pos != tt.wantPos || found != tt.wantFound { @@ -372,7 +372,7 @@ func TestBinarySearchInts(t *testing.T) { {80, 6, true}, } for _, tt := range tests { - t.Run(strconv.Itoa(tt.target), func { t | + t.Run(strconv.Itoa(tt.target), func { t -> { pos, found := BinarySearch(data, tt.target) if pos != tt.wantPos || found != tt.wantFound { @@ -408,7 +408,7 @@ func TestBinarySearchFloats(t *testing.T) { {1.5, 4, false}, } for _, tt := range tests { - t.Run(fmt.Sprintf("%v", tt.target), func { t | + t.Run(fmt.Sprintf("%v", tt.target), func { t -> { pos, found := BinarySearch(data, tt.target) if pos != tt.wantPos || found != tt.wantFound { diff --git a/src/sort/example_interface_test.go b/src/sort/example_interface_test.go index 3fdc79c714f38..0fb65b8dd2d2d 100644 --- a/src/sort/example_interface_test.go +++ b/src/sort/example_interface_test.go @@ -46,7 +46,7 @@ func Example() { // case no methods are needed. (And if they exist, they // are ignored.) Here we re-sort in reverse order: compare // the closure with ByAge.Less. - sort.Slice(people, func { i, j | return people[i].Age > people[j].Age }) + sort.Slice(people, func { i, j -> return people[i].Age > people[j].Age }) fmt.Println(people) // Output: diff --git a/src/sort/example_search_test.go b/src/sort/example_search_test.go index 0da461d4fe11c..da9fbe563ee72 100644 --- a/src/sort/example_search_test.go +++ b/src/sort/example_search_test.go @@ -15,7 +15,7 @@ func ExampleSearch() { a := []int{1, 3, 6, 10, 15, 21, 28, 36, 45, 55} x := 6 - i := sort.Search(len(a), func { i | return a[i] >= x }) + i := sort.Search(len(a), func { i -> return a[i] >= x }) if i < len(a) && a[i] == x { fmt.Printf("found %d at index %d in %v\n", x, i, a) } else { @@ -32,7 +32,7 @@ func ExampleSearch_descendingOrder() { a := []int{55, 45, 36, 28, 21, 15, 10, 6, 3, 1} x := 6 - i := sort.Search(len(a), func { i | return a[i] <= x }) + i := sort.Search(len(a), func { i -> return a[i] <= x }) if i < len(a) && a[i] == x { fmt.Printf("found %d at index %d in %v\n", x, i, a) } else { @@ -47,7 +47,7 @@ func ExampleFind() { a := []string{"apple", "banana", "lemon", "mango", "pear", "strawberry"} for _, x := range []string{"banana", "orange"} { - i, found := sort.Find(len(a), func { i | return strings.Compare(x, a[i]) }) + i, found := sort.Find(len(a), func { i -> return strings.Compare(x, a[i]) }) if found { fmt.Printf("found %s at index %d\n", x, i) } else { diff --git a/src/sort/example_test.go b/src/sort/example_test.go index 3805a501099e9..18b4b0ae58a61 100644 --- a/src/sort/example_test.go +++ b/src/sort/example_test.go @@ -77,10 +77,10 @@ func ExampleSlice() { {"Vera", 24}, {"Bob", 75}, } - sort.Slice(people, func { i, j | return people[i].Name < people[j].Name }) + sort.Slice(people, func { i, j -> return people[i].Name < people[j].Name }) fmt.Println("By name:", people) - sort.Slice(people, func { i, j | return people[i].Age < people[j].Age }) + sort.Slice(people, func { i, j -> return people[i].Age < people[j].Age }) fmt.Println("By age:", people) // Output: By name: [{Alice 55} {Bob 75} {Gopher 7} {Vera 24}] // By age: [{Gopher 7} {Vera 24} {Alice 55} {Bob 75}] @@ -103,11 +103,11 @@ func ExampleSliceStable() { } // Sort by name, preserving original order - sort.SliceStable(people, func { i, j | return people[i].Name < people[j].Name }) + sort.SliceStable(people, func { i, j -> return people[i].Name < people[j].Name }) fmt.Println("By name:", people) // Sort by age preserving name order - sort.SliceStable(people, func { i, j | return people[i].Age < people[j].Age }) + sort.SliceStable(people, func { i, j -> return people[i].Age < people[j].Age }) fmt.Println("By age,name:", people) // Output: By name: [{Alice 25} {Alice 75} {Alice 75} {Bob 75} {Bob 25} {Colin 25} {Elizabeth 75} {Elizabeth 25}] diff --git a/src/sort/search.go b/src/sort/search.go index 6f959cfde671e..a6c86a06a2bf0 100644 --- a/src/sort/search.go +++ b/src/sort/search.go @@ -121,7 +121,7 @@ func Find(n int, cmp func(int) int) (i int, found bool) { // not present (it could be len(a)). // The slice must be sorted in ascending order. func SearchInts(a []int, x int) int { - return Search(len(a), func { i | return a[i] >= x }) + return Search(len(a), func { i -> return a[i] >= x }) } // SearchFloat64s searches for x in a sorted slice of float64s and returns the index @@ -129,7 +129,7 @@ func SearchInts(a []int, x int) int { // present (it could be len(a)). // The slice must be sorted in ascending order. func SearchFloat64s(a []float64, x float64) int { - return Search(len(a), func { i | return a[i] >= x }) + return Search(len(a), func { i -> return a[i] >= x }) } // SearchStrings searches for x in a sorted slice of strings and returns the index @@ -137,7 +137,7 @@ func SearchFloat64s(a []float64, x float64) int { // present (it could be len(a)). // The slice must be sorted in ascending order. func SearchStrings(a []string, x string) int { - return Search(len(a), func { i | return a[i] >= x }) + return Search(len(a), func { i -> return a[i] >= x }) } // Search returns the result of applying [SearchInts] to the receiver and x. diff --git a/src/sort/search_test.go b/src/sort/search_test.go index 9b01bb48ed38f..224edff7054d9 100644 --- a/src/sort/search_test.go +++ b/src/sort/search_test.go @@ -119,7 +119,7 @@ func TestFind(t *testing.T) { } for _, tt := range tests { - t.Run(tt.target, func { t | + t.Run(tt.target, func { t -> cmp := func(i int) int { return stringspkg.Compare(tt.target, tt.data[i]) } @@ -153,7 +153,7 @@ func TestSearchEfficiency(t *testing.T) { max := log2(n) for x := 0; x < n; x += step { count := 0 - i := Search(n, func { i | + i := Search(n, func { i -> count++ return i >= x }) @@ -229,7 +229,7 @@ func BenchmarkSearchWrappers(b *testing.B) { func TestSearchExhaustive(t *testing.T) { for size := 0; size <= 100; size++ { for targ := 0; targ <= size; targ++ { - i := Search(size, func { i | return i >= targ }) + i := Search(size, func { i -> return i >= targ }) if i != targ { t.Errorf("Search(%d, %d) = %d", size, targ, i) } diff --git a/src/sort/sort_slices_benchmark_test.go b/src/sort/sort_slices_benchmark_test.go index b91ec10f9a944..410b43a6dc2f1 100644 --- a/src/sort/sort_slices_benchmark_test.go +++ b/src/sort/sort_slices_benchmark_test.go @@ -172,7 +172,7 @@ func TestStructSorts(t *testing.T) { } Sort(ss) - slices.SortFunc(ss2, func { a, b | return a.n - b.n }) + slices.SortFunc(ss2, func { a, b -> return a.n - b.n }) for i := range ss { if *ss[i] != *ss2[i] { diff --git a/src/sort/sort_test.go b/src/sort/sort_test.go index 207fede8324f3..edb8c7c2ee165 100644 --- a/src/sort/sort_test.go +++ b/src/sort/sort_test.go @@ -50,7 +50,7 @@ func TestSortFloat64sCompareSlicesSort(t *testing.T) { slices.Sort(slice2) // Compare for equality using cmp.Compare, which considers NaNs equal. - if !slices.EqualFunc(slice1, slice2, func { a, b | return cmp.Compare(a, b) == 0 }) { + if !slices.EqualFunc(slice1, slice2, func { a, b -> return cmp.Compare(a, b) == 0 }) { t.Errorf("mismatch between Sort and slices.Sort: got %v, want %v", slice1, slice2) } } @@ -94,8 +94,8 @@ func TestStrings(t *testing.T) { func TestSlice(t *testing.T) { data := stringsData - Slice(data[:], func { i, j | return data[i] < data[j] }) - if !SliceIsSorted(data[:], func { i, j | return data[i] < data[j] }) { + Slice(data[:], func { i, j -> return data[i] < data[j] }) + if !SliceIsSorted(data[:], func { i, j -> return data[i] < data[j] }) { t.Errorf("sorted %v", stringsData) t.Errorf(" got %v", data) } @@ -231,7 +231,7 @@ func BenchmarkSortString1K_Slice(b *testing.B) { for i := 0; i < b.N; i++ { copy(data, unsorted) b.StartTimer() - Slice(data, func { i, j | return data[i] < data[j] }) + Slice(data, func { i, j -> return data[i] < data[j] }) b.StopTimer() } } @@ -329,7 +329,7 @@ func BenchmarkStableInt1K_Slice(b *testing.B) { for i := 0; i < b.N; i++ { copy(data, unsorted) b.StartTimer() - SliceStable(data, func { i, j | return data[i] < data[j] }) + SliceStable(data, func { i, j -> return data[i] < data[j] }) b.StopTimer() } } @@ -355,7 +355,7 @@ func BenchmarkSortInt64K_Slice(b *testing.B) { data[i] = i ^ 0xcccc } b.StartTimer() - Slice(data, func { i, j | return data[i] < data[j] }) + Slice(data, func { i, j -> return data[i] < data[j] }) b.StopTimer() } } @@ -518,15 +518,15 @@ func testBentleyMcIlroy(t *testing.T, sort func(Interface), maxswap func(int) in } func TestSortBM(t *testing.T) { - testBentleyMcIlroy(t, Sort, func { n | return n * lg(n) * 12 / 10 }) + testBentleyMcIlroy(t, Sort, func { n -> return n * lg(n) * 12 / 10 }) } func TestHeapsortBM(t *testing.T) { - testBentleyMcIlroy(t, Heapsort, func { n | return n * lg(n) * 12 / 10 }) + testBentleyMcIlroy(t, Heapsort, func { n -> return n * lg(n) * 12 / 10 }) } func TestStableBM(t *testing.T) { - testBentleyMcIlroy(t, Stable, func { n | return n * lg(n) * lg(n) / 3 }) + testBentleyMcIlroy(t, Stable, func { n -> return n * lg(n) * lg(n) / 3 }) } // This is based on the "antiquicksort" implementation by M. Douglas McIlroy. diff --git a/src/strconv/atoi_test.go b/src/strconv/atoi_test.go index c4cdcfbd1c919..5513f0b100028 100644 --- a/src/strconv/atoi_test.go +++ b/src/strconv/atoi_test.go @@ -612,8 +612,8 @@ func TestNumErrorUnwrap(t *testing.T) { } func BenchmarkParseInt(b *testing.B) { - b.Run("Pos", func { b | benchmarkParseInt(b, 1) }) - b.Run("Neg", func { b | benchmarkParseInt(b, -1) }) + b.Run("Pos", func { b -> benchmarkParseInt(b, 1) }) + b.Run("Neg", func { b -> benchmarkParseInt(b, -1) }) } type benchCase struct { @@ -630,7 +630,7 @@ func benchmarkParseInt(b *testing.B, neg int) { {"63bit", 1<<63 - 1}, } for _, cs := range cases { - b.Run(cs.name, func { b | + b.Run(cs.name, func { b -> s := fmt.Sprintf("%d", cs.num*int64(neg)) for i := 0; i < b.N; i++ { out, _ := ParseInt(s, 10, 64) @@ -641,8 +641,8 @@ func benchmarkParseInt(b *testing.B, neg int) { } func BenchmarkAtoi(b *testing.B) { - b.Run("Pos", func { b | benchmarkAtoi(b, 1) }) - b.Run("Neg", func { b | benchmarkAtoi(b, -1) }) + b.Run("Pos", func { b -> benchmarkAtoi(b, 1) }) + b.Run("Neg", func { b -> benchmarkAtoi(b, -1) }) } func benchmarkAtoi(b *testing.B, neg int) { @@ -658,7 +658,7 @@ func benchmarkAtoi(b *testing.B, neg int) { }...) } for _, cs := range cases { - b.Run(cs.name, func { b | + b.Run(cs.name, func { b -> s := fmt.Sprintf("%d", cs.num*int64(neg)) for i := 0; i < b.N; i++ { out, _ := Atoi(s) diff --git a/src/strconv/ftoa_test.go b/src/strconv/ftoa_test.go index 3af0b8358496f..c1048a515e852 100644 --- a/src/strconv/ftoa_test.go +++ b/src/strconv/ftoa_test.go @@ -304,7 +304,7 @@ var ftoaBenches = []struct { func BenchmarkFormatFloat(b *testing.B) { for _, c := range ftoaBenches { - b.Run(c.name, func { b | for i := 0; i < b.N; i++ { + b.Run(c.name, func { b -> for i := 0; i < b.N; i++ { FormatFloat(c.float, c.fmt, c.prec, c.bitSize) } }) } @@ -313,7 +313,7 @@ func BenchmarkFormatFloat(b *testing.B) { func BenchmarkAppendFloat(b *testing.B) { dst := make([]byte, 30) for _, c := range ftoaBenches { - b.Run(c.name, func { b | for i := 0; i < b.N; i++ { + b.Run(c.name, func { b -> for i := 0; i < b.N; i++ { AppendFloat(dst[:0], c.float, c.fmt, c.prec, c.bitSize) } }) } diff --git a/src/strconv/itoa_test.go b/src/strconv/itoa_test.go index 906a49e446cc5..b79b8ab12bc03 100644 --- a/src/strconv/itoa_test.go +++ b/src/strconv/itoa_test.go @@ -210,7 +210,7 @@ func BenchmarkAppendUint(b *testing.B) { func BenchmarkFormatIntSmall(b *testing.B) { smallInts := []int64{7, 42} for _, smallInt := range smallInts { - b.Run(Itoa(int(smallInt)), func { b | for i := 0; i < b.N; i++ { + b.Run(Itoa(int(smallInt)), func { b -> for i := 0; i < b.N; i++ { s := FormatInt(smallInt, 10) BenchSink += len(s) } }) @@ -228,7 +228,7 @@ func BenchmarkAppendIntSmall(b *testing.B) { func BenchmarkAppendUintVarlen(b *testing.B) { for _, test := range varlenUints { - b.Run(test.out, func { b | + b.Run(test.out, func { b -> dst := make([]byte, 0, 30) for j := 0; j < b.N; j++ { dst = AppendUint(dst[:0], test.in, 10) diff --git a/src/strings/builder_test.go b/src/strings/builder_test.go index b05f82f373ebf..00b93df81d8e8 100644 --- a/src/strings/builder_test.go +++ b/src/strings/builder_test.go @@ -153,7 +153,7 @@ func TestBuilderWrite2(t *testing.T) { s0, }, } { - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> var b Builder n, err := tt.fn(&b) if err != nil { @@ -326,22 +326,22 @@ var someBytes = []byte("some bytes sdljlk jsklj3lkjlk djlkjw") var sinkS string func benchmarkBuilder(b *testing.B, f func(b *testing.B, numWrite int, grow bool)) { - b.Run("1Write_NoGrow", func { b | + b.Run("1Write_NoGrow", func { b -> b.ReportAllocs() f(b, 1, false) }) - b.Run("3Write_NoGrow", func { b | + b.Run("3Write_NoGrow", func { b -> b.ReportAllocs() f(b, 3, false) }) - b.Run("3Write_Grow", func { b | + b.Run("3Write_Grow", func { b -> b.ReportAllocs() f(b, 3, true) }) } func BenchmarkBuildString_Builder(b *testing.B) { - benchmarkBuilder(b, func { b, numWrite, grow | + benchmarkBuilder(b, func { b, numWrite, grow -> for i := 0; i < b.N; i++ { var buf Builder if grow { @@ -357,7 +357,7 @@ func BenchmarkBuildString_Builder(b *testing.B) { func BenchmarkBuildString_WriteString(b *testing.B) { someString := string(someBytes) - benchmarkBuilder(b, func { b, numWrite, grow | + benchmarkBuilder(b, func { b, numWrite, grow -> for i := 0; i < b.N; i++ { var buf Builder if grow { @@ -372,7 +372,7 @@ func BenchmarkBuildString_WriteString(b *testing.B) { } func BenchmarkBuildString_ByteBuffer(b *testing.B) { - benchmarkBuilder(b, func { b, numWrite, grow | + benchmarkBuilder(b, func { b, numWrite, grow -> for i := 0; i < b.N; i++ { var buf bytes.Buffer if grow { diff --git a/src/strings/example_test.go b/src/strings/example_test.go index 89d39eb659676..39b602f014d93 100644 --- a/src/strings/example_test.go +++ b/src/strings/example_test.go @@ -419,7 +419,7 @@ func ExampleTrimSuffix() { } func ExampleTrimFunc() { - fmt.Print(strings.TrimFunc("¡¡¡Hello, Gophers!!!", func { r | return !unicode.IsLetter(r) && !unicode.IsNumber(r) })) + fmt.Print(strings.TrimFunc("¡¡¡Hello, Gophers!!!", func { r -> return !unicode.IsLetter(r) && !unicode.IsNumber(r) })) // Output: Hello, Gophers } @@ -429,7 +429,7 @@ func ExampleTrimLeft() { } func ExampleTrimLeftFunc() { - fmt.Print(strings.TrimLeftFunc("¡¡¡Hello, Gophers!!!", func { r | return !unicode.IsLetter(r) && !unicode.IsNumber(r) })) + fmt.Print(strings.TrimLeftFunc("¡¡¡Hello, Gophers!!!", func { r -> return !unicode.IsLetter(r) && !unicode.IsNumber(r) })) // Output: Hello, Gophers!!! } @@ -439,7 +439,7 @@ func ExampleTrimRight() { } func ExampleTrimRightFunc() { - fmt.Print(strings.TrimRightFunc("¡¡¡Hello, Gophers!!!", func { r | return !unicode.IsLetter(r) && !unicode.IsNumber(r) })) + fmt.Print(strings.TrimRightFunc("¡¡¡Hello, Gophers!!!", func { r -> return !unicode.IsLetter(r) && !unicode.IsNumber(r) })) // Output: ¡¡¡Hello, Gophers } diff --git a/src/strings/replace_test.go b/src/strings/replace_test.go index 1f6e3c399b8c9..cf209e1c36d9c 100644 --- a/src/strings/replace_test.go +++ b/src/strings/replace_test.go @@ -551,9 +551,9 @@ func BenchmarkMap(b *testing.B) { return r } - b.Run("identity", func { b | + b.Run("identity", func { b -> for _, md := range mapdata { - b.Run(md.name, func { b | for i := 0; i < b.N; i++ { + b.Run(md.name, func { b -> for i := 0; i < b.N; i++ { Map(mapidentity, md.data) } }) } @@ -569,9 +569,9 @@ func BenchmarkMap(b *testing.B) { return r } - b.Run("change", func { b | + b.Run("change", func { b -> for _, md := range mapdata { - b.Run(md.name, func { b | for i := 0; i < b.N; i++ { + b.Run(md.name, func { b -> for i := 0; i < b.N; i++ { Map(mapchange, md.data) } }) } diff --git a/src/strings/strings.go b/src/strings/strings.go index 153947e954692..a831672e3cdae 100644 --- a/src/strings/strings.go +++ b/src/strings/strings.go @@ -817,7 +817,7 @@ func Title(s string) string { // the closure once per rune. prev := ' ' return Map( - func { r | + func { r -> if isSeparator(prev) { prev = r return unicode.ToTitle(r) diff --git a/src/strings/strings_test.go b/src/strings/strings_test.go index 7bb8c497ff03b..2f62d064e8f02 100644 --- a/src/strings/strings_test.go +++ b/src/strings/strings_test.go @@ -753,7 +753,7 @@ func TestToValidUTF8(t *testing.T) { func BenchmarkToUpper(b *testing.B) { for _, tc := range upperTests { - b.Run(tc.in, func { b | + b.Run(tc.in, func { b -> for i := 0; i < b.N; i++ { actual := ToUpper(tc.in) if actual != tc.out { @@ -766,7 +766,7 @@ func BenchmarkToUpper(b *testing.B) { func BenchmarkToLower(b *testing.B) { for _, tc := range lowerTests { - b.Run(tc.in, func { b | + b.Run(tc.in, func { b -> for i := 0; i < b.N; i++ { actual := ToLower(tc.in) if actual != tc.out { @@ -911,7 +911,7 @@ func BenchmarkToValidUTF8(b *testing.B) { replacement := "\uFFFD" b.ResetTimer() for _, test := range tests { - b.Run(test.name, func { b | for i := 0; i < b.N; i++ { + b.Run(test.name, func { b -> for i := 0; i < b.N; i++ { ToValidUTF8(test.input, replacement) } }) } @@ -1563,7 +1563,7 @@ func TestContainsRune(t *testing.T) { func TestContainsFunc(t *testing.T) { for _, ct := range ContainsRuneTests { - if ContainsFunc(ct.str, func { r | return ct.r == r }) != ct.expected { + if ContainsFunc(ct.str, func { r -> return ct.r == r }) != ct.expected { t.Errorf("ContainsFunc(%q, func(%q)) = %v, want %v", ct.str, ct.r, !ct.expected, ct.expected) } @@ -1601,7 +1601,7 @@ func TestEqualFold(t *testing.T) { } func BenchmarkEqualFold(b *testing.B) { - b.Run("Tests", func { b | + b.Run("Tests", func { b -> for i := 0; i < b.N; i++ { for _, tt := range EqualFoldTests { if out := EqualFold(tt.s, tt.t); out != tt.out { @@ -1614,15 +1614,15 @@ func BenchmarkEqualFold(b *testing.B) { const s1 = "abcdefghijKz" const s2 = "abcDefGhijKz" - b.Run("ASCII", func { b | for i := 0; i < b.N; i++ { + b.Run("ASCII", func { b -> for i := 0; i < b.N; i++ { EqualFold(s1, s2) } }) - b.Run("UnicodePrefix", func { b | for i := 0; i < b.N; i++ { + b.Run("UnicodePrefix", func { b -> for i := 0; i < b.N; i++ { EqualFold("αβδ"+s1, "ΑΒΔ"+s2) } }) - b.Run("UnicodeSuffix", func { b | for i := 0; i < b.N; i++ { + b.Run("UnicodeSuffix", func { b -> for i := 0; i < b.N; i++ { EqualFold(s1+"αβδ", s2+"ΑΒΔ") } }) } @@ -1802,7 +1802,7 @@ func BenchmarkCountByte(b *testing.B) { } } for _, size := range indexSizes { - b.Run(fmt.Sprintf("%d", size), func { b | benchFunc(b, benchStr[:size]) }) + b.Run(fmt.Sprintf("%d", size), func { b -> benchFunc(b, benchStr[:size]) }) } } @@ -1847,9 +1847,9 @@ var stringdata = []struct{ name, data string }{ func BenchmarkFields(b *testing.B) { for _, sd := range stringdata { - b.Run(sd.name, func { b | + b.Run(sd.name, func { b -> for j := 1 << 4; j <= 1<<20; j <<= 4 { - b.Run(fmt.Sprintf("%d", j), func { b | + b.Run(fmt.Sprintf("%d", j), func { b -> b.ReportAllocs() b.SetBytes(int64(j)) data := sd.data[:j] @@ -1864,9 +1864,9 @@ func BenchmarkFields(b *testing.B) { func BenchmarkFieldsFunc(b *testing.B) { for _, sd := range stringdata { - b.Run(sd.name, func { b | + b.Run(sd.name, func { b -> for j := 1 << 4; j <= 1<<20; j <<= 4 { - b.Run(fmt.Sprintf("%d", j), func { b | + b.Run(fmt.Sprintf("%d", j), func { b -> b.ReportAllocs() b.SetBytes(int64(j)) data := sd.data[:j] @@ -1913,7 +1913,7 @@ func BenchmarkRepeat(b *testing.B) { s := "0123456789" for _, n := range []int{5, 10} { for _, c := range []int{0, 1, 2, 6} { - b.Run(fmt.Sprintf("%dx%d", n, c), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%dx%d", n, c), func { b -> for i := 0; i < b.N; i++ { Repeat(s[:n], c) } }) } @@ -1929,7 +1929,7 @@ func BenchmarkRepeatLarge(b *testing.B) { if n == 0 { continue } - b.Run(fmt.Sprintf("%d/%d", 1< for i := 0; i < b.N; i++ { Repeat(s, n) } @@ -1951,7 +1951,7 @@ func BenchmarkIndexAnyASCII(b *testing.B) { cs := "0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz" for k := 1; k <= 2048; k <<= 4 { for j := 1; j <= 64; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> for i := 0; i < b.N; i++ { IndexAny(x[:k], cs[:j]) } }) } @@ -1963,7 +1963,7 @@ func BenchmarkIndexAnyUTF8(b *testing.B) { cs := "你好世界, hello world. 你好世界, hello world. 你好世界, hello world." for k := 1; k <= 2048; k <<= 4 { for j := 1; j <= 64; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> for i := 0; i < b.N; i++ { IndexAny(x[:k], cs[:j]) } }) } @@ -1975,7 +1975,7 @@ func BenchmarkLastIndexAnyASCII(b *testing.B) { cs := "0123456789abcdefghijklmnopqrstuvwxyz0123456789abcdefghijklmnopqrstuvwxyz" for k := 1; k <= 2048; k <<= 4 { for j := 1; j <= 64; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> for i := 0; i < b.N; i++ { LastIndexAny(x[:k], cs[:j]) } }) } @@ -1987,7 +1987,7 @@ func BenchmarkLastIndexAnyUTF8(b *testing.B) { cs := "你好世界, hello world. 你好世界, hello world. 你好世界, hello world." for k := 1; k <= 2048; k <<= 4 { for j := 1; j <= 64; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | for i := 0; i < b.N; i++ { + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> for i := 0; i < b.N; i++ { LastIndexAny(x[:k], cs[:j]) } }) } @@ -1998,7 +1998,7 @@ func BenchmarkTrimASCII(b *testing.B) { cs := "0123456789abcdef" for k := 1; k <= 4096; k <<= 4 { for j := 1; j <= 16; j <<= 1 { - b.Run(fmt.Sprintf("%d:%d", k, j), func { b | + b.Run(fmt.Sprintf("%d:%d", k, j), func { b -> x := Repeat(cs[:j], k) // Always matches set for i := 0; i < b.N; i++ { Trim(x[:k], cs[:j]) @@ -2018,7 +2018,7 @@ func BenchmarkTrimByte(b *testing.B) { func BenchmarkIndexPeriodic(b *testing.B) { key := "aa" for _, skip := range [...]int{2, 4, 8, 16, 32, 64} { - b.Run(fmt.Sprintf("IndexPeriodic%d", skip), func { b | + b.Run(fmt.Sprintf("IndexPeriodic%d", skip), func { b -> s := Repeat("a"+Repeat(" ", skip-1), 1<<16/skip) for i := 0; i < b.N; i++ { Index(s, key) @@ -2030,7 +2030,7 @@ func BenchmarkIndexPeriodic(b *testing.B) { func BenchmarkJoin(b *testing.B) { vals := []string{"red", "yellow", "pink", "green", "purple", "orange", "blue"} for l := 0; l <= len(vals); l++ { - b.Run(strconv.Itoa(l), func { b | + b.Run(strconv.Itoa(l), func { b -> b.ReportAllocs() vals := vals[:l] for i := 0; i < b.N; i++ { @@ -2048,7 +2048,7 @@ func BenchmarkTrimSpace(b *testing.B) { {"JustNonASCII", "\u2000\u2000\u2000☺☺☺☺\u3000\u3000\u3000"}, } for _, test := range tests { - b.Run(test.name, func { b | for i := 0; i < b.N; i++ { + b.Run(test.name, func { b -> for i := 0; i < b.N; i++ { TrimSpace(test.input) } }) } diff --git a/src/sync/atomic/value_test.go b/src/sync/atomic/value_test.go index ab1b9fc975187..b222eb53dfc63 100644 --- a/src/sync/atomic/value_test.go +++ b/src/sync/atomic/value_test.go @@ -127,7 +127,7 @@ func TestValueConcurrent(t *testing.T) { func BenchmarkValueRead(b *testing.B) { var v Value v.Store(new(int)) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { x := v.Load().(*int) if *x != 0 { @@ -151,7 +151,7 @@ var Value_SwapTests = []struct { func TestValue_Swap(t *testing.T) { for i, tt := range Value_SwapTests { - t.Run(strconv.Itoa(i), func { t | + t.Run(strconv.Itoa(i), func { t -> var v Value if tt.init != nil { v.Store(tt.init) @@ -225,7 +225,7 @@ var Value_CompareAndSwapTests = []struct { func TestValue_CompareAndSwap(t *testing.T) { for i, tt := range Value_CompareAndSwapTests { - t.Run(strconv.Itoa(i), func { t | + t.Run(strconv.Itoa(i), func { t -> var v Value if tt.init != nil { v.Store(tt.init) diff --git a/src/sync/map_bench_test.go b/src/sync/map_bench_test.go index 6aaeb465b31b6..d74dd1933c2e9 100644 --- a/src/sync/map_bench_test.go +++ b/src/sync/map_bench_test.go @@ -19,7 +19,7 @@ type bench struct { func benchMap(b *testing.B, bench bench) { for _, m := range [...]mapInterface{&DeepCopyMap{}, &RWMutexMap{}, &sync.Map{}} { - b.Run(fmt.Sprintf("%T", m), func { b | + b.Run(fmt.Sprintf("%T", m), func { b -> m = reflect.New(reflect.TypeOf(m).Elem()).Interface().(mapInterface) if bench.setup != nil { bench.setup(b, m) @@ -28,7 +28,7 @@ func benchMap(b *testing.B, bench bench) { b.ResetTimer() var i int64 - b.RunParallel(func { pb | + b.RunParallel(func { pb -> id := int(atomic.AddInt64(&i, 1) - 1) bench.perG(b, pb, id*b.N, m) }) @@ -218,7 +218,7 @@ func BenchmarkRange(b *testing.B) { perG: func(b *testing.B, pb *testing.PB, i int, m mapInterface) { for ; pb.Next(); i++ { - m.Range(func { _, _ | return true }) + m.Range(func { _, _ -> return true }) } }, }) @@ -265,7 +265,7 @@ func BenchmarkAdversarialDelete(b *testing.B) { m.Load(i) if i%mapSize == 0 { - m.Range(func { k, _ | + m.Range(func { k, _ -> m.Delete(k) return false }) diff --git a/src/sync/map_test.go b/src/sync/map_test.go index de1a99bad7ecd..5ef4aa56aa19f 100644 --- a/src/sync/map_test.go +++ b/src/sync/map_test.go @@ -113,7 +113,7 @@ func applyCalls(m mapInterface, calls []mapCall) (results []mapResult, final map } final = make(map[any]any) - m.Range(func { k, v | + m.Range(func { k, v -> final[k] = v return true }) @@ -188,7 +188,7 @@ func TestConcurrentRange(t *testing.T) { for n := iters; n > 0; n-- { seen := make(map[int64]bool, mapSize) - m.Range(func { ki, vi | + m.Range(func { ki, vi -> k, v := ki.(int64), vi.(int64) if v%k != 0 { t.Fatalf("while Storing multiples of %v, Range saw value %v", k, v) @@ -232,8 +232,8 @@ func TestMapRangeNestedCall(t *testing.T) { // Issue 46399 for i, v := range [3]string{"hello", "world", "Go"} { m.Store(i, v) } - m.Range(func { key, value | - m.Range(func { key, value | + m.Range(func { key, value -> + m.Range(func { key, value -> // We should be able to load the key offered in the Range callback, // because there are no concurrent Delete involved in this tested map. if v, ok := m.Load(key); !ok || !reflect.DeepEqual(v, value) { @@ -267,7 +267,7 @@ func TestMapRangeNestedCall(t *testing.T) { // Issue 46399 // After a Range of Delete, all keys should be removed and any // further Range won't invoke the callback. Hence length remains 0. length := 0 - m.Range(func { key, value | + m.Range(func { key, value -> length++ return true }) @@ -289,7 +289,7 @@ func TestMapRangeNoAllocations(t *testing.T) { // Issue 62404 testenv.SkipIfOptimizationOff(t) var m sync.Map allocs := testing.AllocsPerRun(10, func() { - m.Range(func { key, value | return true }) + m.Range(func { key, value -> return true }) }) if allocs > 0 { t.Errorf("AllocsPerRun of m.Range = %v; want 0", allocs) @@ -336,7 +336,7 @@ func TestConcurrentClear(t *testing.T) { m.Clear() - m.Range(func { k, v | + m.Range(func { k, v -> t.Errorf("after Clear, Map contains (%v, %v); expected to be empty", k, v) return true diff --git a/src/sync/mutex_test.go b/src/sync/mutex_test.go index 753370c47b190..142ac7be0d802 100644 --- a/src/sync/mutex_test.go +++ b/src/sync/mutex_test.go @@ -233,7 +233,7 @@ func BenchmarkMutexUncontended(b *testing.B) { Mutex pad [128]uint8 } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var mu PaddedMutex for pb.Next() { mu.Lock() @@ -247,7 +247,7 @@ func benchmarkMutex(b *testing.B, slack, work bool) { if slack { b.SetParallelism(10) } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> foo := 0 for pb.Next() { mu.Lock() @@ -289,7 +289,7 @@ func BenchmarkMutexNoSpin(b *testing.B) { var m Mutex var acc0, acc1 uint64 b.SetParallelism(4) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> c := make(chan bool) var data [4 << 10]uint64 for i := 0; pb.Next(); i++ { @@ -320,7 +320,7 @@ func BenchmarkMutexSpin(b *testing.B) { // unnecessary rescheduling is penalized by cache misses. var m Mutex var acc0, acc1 uint64 - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var data [16 << 10]uint64 for i := 0; pb.Next(); i++ { m.Lock() diff --git a/src/sync/once_test.go b/src/sync/once_test.go index 0c2882f0ab6fa..1a668a654bebe 100644 --- a/src/sync/once_test.go +++ b/src/sync/once_test.go @@ -60,7 +60,7 @@ func TestOncePanic(t *testing.T) { func BenchmarkOnce(b *testing.B) { var once Once f := func() {} - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { once.Do(f) } }) } diff --git a/src/sync/oncefunc_test.go b/src/sync/oncefunc_test.go index e91f8f8f6d769..9d88e8d7ee773 100644 --- a/src/sync/oncefunc_test.go +++ b/src/sync/oncefunc_test.go @@ -68,7 +68,7 @@ func TestOnceValues(t *testing.T) { } func testOncePanicX(t *testing.T, calls *int, f func()) { - testOncePanicWith(t, calls, f, func { label, p | if p != "x" { + testOncePanicWith(t, calls, f, func { label, p -> if p != "x" { t.Fatalf("%s: want panic %v, got %v", label, "x", p) } }) } @@ -129,7 +129,7 @@ func TestOnceFuncPanicNil(t *testing.T) { calls++ panic(nil) }) - testOncePanicWith(t, &calls, f, func { label, p | + testOncePanicWith(t, &calls, f, func { label, p -> switch p.(type) { case nil, *runtime.PanicNilError: return @@ -204,10 +204,10 @@ func TestOnceXGC(t *testing.T) { }, } for n, fn := range fns { - t.Run(n, func { t | + t.Run(n, func { t -> buf := make([]byte, 1024) var gc atomic.Bool - runtime.SetFinalizer(&buf[0], func { _ | gc.Store(true) }) + runtime.SetFinalizer(&buf[0], func { _ -> gc.Store(true) }) f := fn(buf) gcwaitfin() if gc.Load() != false { @@ -245,14 +245,14 @@ func doOnceFunc() { } func BenchmarkOnceFunc(b *testing.B) { - b.Run("v=Once", func { b | + b.Run("v=Once", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { // The baseline is direct use of sync.Once. doOnceFunc() } }) - b.Run("v=Global", func { b | + b.Run("v=Global", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { // As of 3/2023, the compiler doesn't recognize that onceFunc is @@ -261,7 +261,7 @@ func BenchmarkOnceFunc(b *testing.B) { onceFunc() } }) - b.Run("v=Local", func { b | + b.Run("v=Local", func { b -> b.ReportAllocs() // As of 3/2023, the compiler *does* recognize this local binding as an // inlinable closure. This is the best case for OnceFunc, but probably @@ -289,7 +289,7 @@ func doOnceValue() int { func BenchmarkOnceValue(b *testing.B) { // See BenchmarkOnceFunc - b.Run("v=Once", func { b | + b.Run("v=Once", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { if want, got := 42, doOnceValue(); want != got { @@ -297,7 +297,7 @@ func BenchmarkOnceValue(b *testing.B) { } } }) - b.Run("v=Global", func { b | + b.Run("v=Global", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { if want, got := 42, onceValue(); want != got { @@ -305,7 +305,7 @@ func BenchmarkOnceValue(b *testing.B) { } } }) - b.Run("v=Local", func { b | + b.Run("v=Local", func { b -> b.ReportAllocs() onceValue := sync.OnceValue(func { return 42 }) for i := 0; i < b.N; i++ { diff --git a/src/sync/pool_test.go b/src/sync/pool_test.go index 88ce463d67de3..0fd8442f75e44 100644 --- a/src/sync/pool_test.go +++ b/src/sync/pool_test.go @@ -112,7 +112,7 @@ loop: var fin, fin1 uint32 for i := 0; i < N; i++ { v := new(string) - runtime.SetFinalizer(v, func { vv | atomic.AddUint32(&fin, 1) }) + runtime.SetFinalizer(v, func { vv -> atomic.AddUint32(&fin, 1) }) p.Put(v) } if drain { @@ -253,14 +253,14 @@ func TestNilPool(t *testing.T) { } var p *Pool - t.Run("Get", func { t | + t.Run("Get", func { t -> defer catch() if p.Get() != nil { t.Error("expected empty") } t.Error("should have panicked already") }) - t.Run("Put", func { t | + t.Run("Put", func { t -> defer catch() p.Put("a") t.Error("should have panicked already") @@ -269,7 +269,7 @@ func TestNilPool(t *testing.T) { func BenchmarkPool(b *testing.B) { var p Pool - b.RunParallel(func { pb | for pb.Next() { + b.RunParallel(func { pb -> for pb.Next() { p.Put(1) p.Get() } }) @@ -277,7 +277,7 @@ func BenchmarkPool(b *testing.B) { func BenchmarkPoolOverflow(b *testing.B) { var p Pool - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { for b := 0; b < 100; b++ { p.Put(1) @@ -297,7 +297,7 @@ func BenchmarkPoolStarvation(b *testing.B) { // Reduce number of putted objects by 33 %. It creates objects starvation // that force P-local storage to steal objects from other Ps. countStarved := count - int(float32(count)*0.33) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { for b := 0; b < countStarved; b++ { p.Put(1) @@ -364,7 +364,7 @@ func BenchmarkPoolExpensiveNew(b *testing.B) { } var mstats1, mstats2 runtime.MemStats runtime.ReadMemStats(&mstats1) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> // Simulate 100X the number of goroutines having items // checked out from the Pool simultaneously. items := make([]any, 100) diff --git a/src/sync/runtime_sema_test.go b/src/sync/runtime_sema_test.go index 2d41a90d28582..6e91ba43122ba 100644 --- a/src/sync/runtime_sema_test.go +++ b/src/sync/runtime_sema_test.go @@ -15,7 +15,7 @@ func BenchmarkSemaUncontended(b *testing.B) { sem uint32 pad [32]uint32 } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> sem := new(PaddedSem) for pb.Next() { Runtime_Semrelease(&sem.sem, false, 0) @@ -41,7 +41,7 @@ func benchmarkSema(b *testing.B, block, work bool) { <-done }() } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> foo := 0 for pb.Next() { Runtime_Semrelease(&sem, false, 0) diff --git a/src/sync/rwmutex_test.go b/src/sync/rwmutex_test.go index d42227aca3020..c505d1c539a97 100644 --- a/src/sync/rwmutex_test.go +++ b/src/sync/rwmutex_test.go @@ -193,7 +193,7 @@ func BenchmarkRWMutexUncontended(b *testing.B) { RWMutex pad [32]uint32 } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var rwm PaddedRWMutex for pb.Next() { rwm.RLock() @@ -208,7 +208,7 @@ func BenchmarkRWMutexUncontended(b *testing.B) { func benchmarkRWMutex(b *testing.B, localWork, writeRatio int) { var rwm RWMutex - b.RunParallel(func { pb | + b.RunParallel(func { pb -> foo := 0 for pb.Next() { foo++ diff --git a/src/sync/waitgroup_test.go b/src/sync/waitgroup_test.go index c7de0d56dabe8..70c46ac5c8864 100644 --- a/src/sync/waitgroup_test.go +++ b/src/sync/waitgroup_test.go @@ -103,7 +103,7 @@ func BenchmarkWaitGroupUncontended(b *testing.B) { WaitGroup pad [128]uint8 } - b.RunParallel(func { pb | + b.RunParallel(func { pb -> var wg PaddedWaitGroup for pb.Next() { wg.Add(1) @@ -115,7 +115,7 @@ func BenchmarkWaitGroupUncontended(b *testing.B) { func benchmarkWaitGroupAddDone(b *testing.B, localWork int) { var wg WaitGroup - b.RunParallel(func { pb | + b.RunParallel(func { pb -> foo := 0 for pb.Next() { wg.Add(1) @@ -139,7 +139,7 @@ func BenchmarkWaitGroupAddDoneWork(b *testing.B) { func benchmarkWaitGroupWait(b *testing.B, localWork int) { var wg WaitGroup - b.RunParallel(func { pb | + b.RunParallel(func { pb -> foo := 0 for pb.Next() { wg.Wait() @@ -162,7 +162,7 @@ func BenchmarkWaitGroupWaitWork(b *testing.B) { func BenchmarkWaitGroupActuallyWait(b *testing.B) { b.ReportAllocs() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { var wg WaitGroup wg.Add(1) diff --git a/src/syscall/exec_linux_test.go b/src/syscall/exec_linux_test.go index 877dc57773f26..805c2cf9c06c0 100644 --- a/src/syscall/exec_linux_test.go +++ b/src/syscall/exec_linux_test.go @@ -51,7 +51,7 @@ func whoamiNEWUSER(t *testing.T, uid, gid int, setgroups bool) *exec.Cmd { func TestCloneNEWUSERAndRemap(t *testing.T) { for _, setgroups := range []bool{false, true} { setgroups := setgroups - t.Run(fmt.Sprintf("setgroups=%v", setgroups), func { t | + t.Run(fmt.Sprintf("setgroups=%v", setgroups), func { t -> uid := os.Getuid() gid := os.Getgid() diff --git a/src/syscall/exec_unix_test.go b/src/syscall/exec_unix_test.go index 206009546dcca..3cb47807e4d6a 100644 --- a/src/syscall/exec_unix_test.go +++ b/src/syscall/exec_unix_test.go @@ -275,7 +275,7 @@ func TestForegroundSignal(t *testing.T) { // Test a couple of cases that SysProcAttr can't handle. Issue 29458. func TestInvalidExec(t *testing.T) { t.Parallel() - t.Run("SetCtty-Foreground", func { t | + t.Run("SetCtty-Foreground", func { t -> t.Parallel() cmd := create(t) cmd.proc.SysProcAttr = &syscall.SysProcAttr{ @@ -287,7 +287,7 @@ func TestInvalidExec(t *testing.T) { t.Error("expected error setting both SetCtty and Foreground") } }) - t.Run("invalid-Ctty", func { t | + t.Run("invalid-Ctty", func { t -> t.Parallel() cmd := create(t) cmd.proc.SysProcAttr = &syscall.SysProcAttr{ diff --git a/src/syscall/fs_js.go b/src/syscall/fs_js.go index 98fc9549d6789..f31da7a245923 100644 --- a/src/syscall/fs_js.go +++ b/src/syscall/fs_js.go @@ -512,7 +512,7 @@ func fsCall(name string, args ...any) (js.Value, error) { } c := make(chan callResult, 1) - f := js.FuncOf(func { this, args | + f := js.FuncOf(func { this, args -> var res callResult if len(args) >= 1 { // on Node.js 8, fs.utimes calls the callback without any arguments diff --git a/src/syscall/fs_wasip1_test.go b/src/syscall/fs_wasip1_test.go index e0d55f4163fd2..09c75b5fc3980 100644 --- a/src/syscall/fs_wasip1_test.go +++ b/src/syscall/fs_wasip1_test.go @@ -56,7 +56,7 @@ var joinPathTests = [...]struct { func TestJoinPath(t *testing.T) { for _, test := range joinPathTests { - t.Run("", func { t | + t.Run("", func { t -> path := syscall.JoinPath(test.dir, test.file) if path != test.path { t.Errorf("join(%q,%q): want=%q got=%q", test.dir, test.file, test.path, path) @@ -67,7 +67,7 @@ func TestJoinPath(t *testing.T) { func BenchmarkJoinPath(b *testing.B) { for _, test := range joinPathTests { - b.Run("", func { b | for i := 0; i < b.N; i++ { + b.Run("", func { b -> for i := 0; i < b.N; i++ { syscall.JoinPath(test.dir, test.file) } }) } diff --git a/src/syscall/getdirentries_test.go b/src/syscall/getdirentries_test.go index d57378da1c144..d0a8ab76bf92e 100644 --- a/src/syscall/getdirentries_test.go +++ b/src/syscall/getdirentries_test.go @@ -19,7 +19,7 @@ import ( func TestGetdirentries(t *testing.T) { for _, count := range []int{10, 1000} { - t.Run(fmt.Sprintf("n=%d", count), func { t | testGetdirentries(t, count) }) + t.Run(fmt.Sprintf("n=%d", count), func { t -> testGetdirentries(t, count) }) } } func testGetdirentries(t *testing.T, count int) { diff --git a/src/syscall/js/js.go b/src/syscall/js/js.go index 54531ff4e143c..c93716c39eb15 100644 --- a/src/syscall/js/js.go +++ b/src/syscall/js/js.go @@ -50,7 +50,7 @@ func makeValue(r ref) Value { if (r>>32)&nanHead == nanHead && typeFlag != typeFlagNone { gcPtr = new(ref) *gcPtr = r - runtime.SetFinalizer(gcPtr, func { p | finalizeRef(*p) }) + runtime.SetFinalizer(gcPtr, func { p -> finalizeRef(*p) }) } return Value{ref: r, gcPtr: gcPtr} diff --git a/src/syscall/js/js_test.go b/src/syscall/js/js_test.go index f3bd59a66d723..6de1febe6c81d 100644 --- a/src/syscall/js/js_test.go +++ b/src/syscall/js/js_test.go @@ -400,7 +400,7 @@ func TestZeroValue(t *testing.T) { func TestFuncOf(t *testing.T) { c := make(chan struct{}) - cb := js.FuncOf(func { this, args | + cb := js.FuncOf(func { this, args -> if got := args[0].Int(); got != 42 { t.Errorf("got %#v, want %#v", got, 42) } @@ -414,8 +414,8 @@ func TestFuncOf(t *testing.T) { func TestInvokeFunction(t *testing.T) { called := false - cb := js.FuncOf(func { this, args | - cb2 := js.FuncOf(func { this, args | + cb := js.FuncOf(func { this, args -> + cb2 := js.FuncOf(func { this, args -> called = true return 42 }) @@ -435,7 +435,7 @@ func TestInterleavedFunctions(t *testing.T) { c1 := make(chan struct{}) c2 := make(chan struct{}) - js.Global().Get("setTimeout").Invoke(js.FuncOf(func { this, args | + js.Global().Get("setTimeout").Invoke(js.FuncOf(func { this, args -> c1 <- struct{}{} <-c2 return nil @@ -444,13 +444,13 @@ func TestInterleavedFunctions(t *testing.T) { <-c1 c2 <- struct{}{} // this goroutine is running, but the callback of setTimeout did not return yet, invoke another function now - f := js.FuncOf(func { this, args | return nil }) + f := js.FuncOf(func { this, args -> return nil }) f.Invoke() } func ExampleFuncOf() { var cb js.Func - cb = js.FuncOf(func { this, args | + cb = js.FuncOf(func { this, args -> fmt.Println("button clicked") cb.Release() // release the function if the button will not be clicked again return nil @@ -527,7 +527,7 @@ var copyTests = []struct { func TestCopyBytesToGo(t *testing.T) { for _, tt := range copyTests { - t.Run(fmt.Sprintf("%d-to-%d", tt.srcLen, tt.dstLen), func { t | + t.Run(fmt.Sprintf("%d-to-%d", tt.srcLen, tt.dstLen), func { t -> src := js.Global().Get("Uint8Array").New(tt.srcLen) if tt.srcLen >= 2 { src.SetIndex(1, 42) @@ -548,7 +548,7 @@ func TestCopyBytesToGo(t *testing.T) { func TestCopyBytesToJS(t *testing.T) { for _, tt := range copyTests { - t.Run(fmt.Sprintf("%d-to-%d", tt.srcLen, tt.dstLen), func { t | + t.Run(fmt.Sprintf("%d-to-%d", tt.srcLen, tt.dstLen), func { t -> src := make([]byte, tt.srcLen) if tt.srcLen >= 2 { src[1] = 42 @@ -677,7 +677,7 @@ func BenchmarkDOM(b *testing.B) { } func TestGlobal(t *testing.T) { - ident := js.FuncOf(func { this, args | return args[0] }) + ident := js.FuncOf(func { this, args -> return args[0] }) defer ident.Release() if got := ident.Invoke(js.Global()); !got.Equal(js.Global()) { diff --git a/src/syscall/syscall_windows_test.go b/src/syscall/syscall_windows_test.go index 58cef0d433cc3..1b0ffcc20adb7 100644 --- a/src/syscall/syscall_windows_test.go +++ b/src/syscall/syscall_windows_test.go @@ -222,7 +222,7 @@ func FuzzUTF16FromString(f *testing.F) { f.Add("\xe3\x81") // truncated f.Add("\xe3\xc1\x81") // invalid middle byte - f.Fuzz(func { t, tst | + f.Fuzz(func { t, tst -> res, err := syscall.UTF16FromString(tst) if err != nil { if strings.Contains(tst, "\x00") { diff --git a/src/syscall/wtf8_windows_test.go b/src/syscall/wtf8_windows_test.go index 41f2cdef62c96..134d7bf52caf6 100644 --- a/src/syscall/wtf8_windows_test.go +++ b/src/syscall/wtf8_windows_test.go @@ -133,7 +133,7 @@ var wtf8tests = []struct { func TestWTF16Rountrip(t *testing.T) { for _, tt := range wtf8tests { - t.Run(fmt.Sprintf("%X", tt.str), func { t | + t.Run(fmt.Sprintf("%X", tt.str), func { t -> got := syscall.EncodeWTF16(tt.str, nil) got2 := string(syscall.DecodeWTF16(got, nil)) if got2 != tt.str { @@ -145,7 +145,7 @@ func TestWTF16Rountrip(t *testing.T) { func TestWTF16Golden(t *testing.T) { for _, tt := range wtf8tests { - t.Run(fmt.Sprintf("%X", tt.str), func { t | + t.Run(fmt.Sprintf("%X", tt.str), func { t -> got := syscall.EncodeWTF16(tt.str, nil) if !slices.Equal(got, tt.wstr) { t.Errorf("got:\n%v\nwant:\n%v", got, tt.wstr) @@ -158,7 +158,7 @@ func FuzzEncodeWTF16(f *testing.F) { for _, tt := range wtf8tests { f.Add(tt.str) } - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> // test that there are no panics got := syscall.EncodeWTF16(b, nil) syscall.DecodeWTF16(got, nil) @@ -179,7 +179,7 @@ func FuzzDecodeWTF16(f *testing.F) { b := unsafe.Slice((*uint8)(unsafe.Pointer(unsafe.SliceData(tt.wstr))), len(tt.wstr)*2) f.Add(b) } - f.Fuzz(func { t, b | + f.Fuzz(func { t, b -> u16 := unsafe.Slice((*uint16)(unsafe.Pointer(unsafe.SliceData(b))), len(b)/2) got := syscall.DecodeWTF16(u16, nil) if utf8.Valid(got) { diff --git a/src/testing/benchmark_test.go b/src/testing/benchmark_test.go index 8deb4d287e1d4..d23982477d26f 100644 --- a/src/testing/benchmark_test.go +++ b/src/testing/benchmark_test.go @@ -73,11 +73,11 @@ func TestRunParallel(t *testing.T) { if testing.Short() { t.Skip("skipping in short mode") } - testing.Benchmark(func { b | + testing.Benchmark(func { b -> procs := uint32(0) iters := uint64(0) b.SetParallelism(3) - b.RunParallel(func { pb | + b.RunParallel(func { pb -> atomic.AddUint32(&procs, 1) for pb.Next() { atomic.AddUint64(&iters, 1) @@ -93,8 +93,8 @@ func TestRunParallel(t *testing.T) { } func TestRunParallelFail(t *testing.T) { - testing.Benchmark(func { b | - b.RunParallel(func { pb | + testing.Benchmark(func { b -> + b.RunParallel(func { pb -> // The function must be able to log/abort // w/o crashing/deadlocking the whole benchmark. b.Log("log") @@ -104,8 +104,8 @@ func TestRunParallelFail(t *testing.T) { } func TestRunParallelFatal(t *testing.T) { - testing.Benchmark(func { b | - b.RunParallel(func { pb | for pb.Next() { + testing.Benchmark(func { b -> + b.RunParallel(func { pb -> for pb.Next() { if b.N > 1 { b.Fatal("error") } @@ -114,8 +114,8 @@ func TestRunParallelFatal(t *testing.T) { } func TestRunParallelSkipNow(t *testing.T) { - testing.Benchmark(func { b | - b.RunParallel(func { pb | for pb.Next() { + testing.Benchmark(func { b -> + b.RunParallel(func { pb -> for pb.Next() { if b.N > 1 { b.SkipNow() } @@ -125,11 +125,11 @@ func TestRunParallelSkipNow(t *testing.T) { func ExampleB_RunParallel() { // Parallel benchmark for text/template.Template.Execute on a single object. - testing.Benchmark(func { b | + testing.Benchmark(func { b -> templ := template.Must(template.New("test").Parse("Hello, {{.}}!")) // RunParallel will create GOMAXPROCS goroutines // and distribute work among them. - b.RunParallel(func { pb | + b.RunParallel(func { pb -> // Each goroutine has its own bytes.Buffer. var buf bytes.Buffer for pb.Next() { @@ -142,7 +142,7 @@ func ExampleB_RunParallel() { } func TestReportMetric(t *testing.T) { - res := testing.Benchmark(func { b | + res := testing.Benchmark(func { b -> b.ReportMetric(12345, "ns/op") b.ReportMetric(0.2, "frobs/op") }) @@ -161,11 +161,11 @@ func TestReportMetric(t *testing.T) { func ExampleB_ReportMetric() { // This reports a custom benchmark metric relevant to a // specific algorithm (in this case, sorting). - testing.Benchmark(func { b | + testing.Benchmark(func { b -> var compares int64 for i := 0; i < b.N; i++ { s := []int{5, 4, 3, 2, 1} - slices.SortFunc(s, func { a, b | + slices.SortFunc(s, func { a, b -> compares++ return cmp.Compare(a, b) }) @@ -182,12 +182,12 @@ func ExampleB_ReportMetric() { func ExampleB_ReportMetric_parallel() { // This reports a custom benchmark metric relevant to a // specific algorithm (in this case, sorting) in parallel. - testing.Benchmark(func { b | + testing.Benchmark(func { b -> var compares atomic.Int64 - b.RunParallel(func { pb | + b.RunParallel(func { pb -> for pb.Next() { s := []int{5, 4, 3, 2, 1} - slices.SortFunc(s, func { a, b | + slices.SortFunc(s, func { a, b -> // Because RunParallel runs the function many // times in parallel, we must increment the // counter atomically to avoid racing writes. diff --git a/src/testing/flag_test.go b/src/testing/flag_test.go index 6fbe0beaf9545..ccbebd56d15d0 100644 --- a/src/testing/flag_test.go +++ b/src/testing/flag_test.go @@ -26,7 +26,7 @@ func TestFlag(t *testing.T) { for _, flag := range []string{"", "-test.v", "-test.v=test2json"} { flag := flag - t.Run(flag, func { t | + t.Run(flag, func { t -> t.Parallel() exe, err := os.Executable() if err != nil { diff --git a/src/testing/fstest/mapfs.go b/src/testing/fstest/mapfs.go index d25e10372f6cf..382029ea084ae 100644 --- a/src/testing/fstest/mapfs.go +++ b/src/testing/fstest/mapfs.go @@ -100,7 +100,7 @@ func (fsys MapFS) Open(name string) (fs.File, error) { for name := range need { list = append(list, mapFileInfo{name, &MapFile{Mode: fs.ModeDir | 0555}}) } - slices.SortFunc(list, func { a, b | return strings.Compare(a.name, b.name) }) + slices.SortFunc(list, func { a, b -> return strings.Compare(a.name, b.name) }) if file == nil { file = &MapFile{Mode: fs.ModeDir | 0555} diff --git a/src/testing/fstest/mapfs_test.go b/src/testing/fstest/mapfs_test.go index 54aec25a40497..9f7d91b275083 100644 --- a/src/testing/fstest/mapfs_test.go +++ b/src/testing/fstest/mapfs_test.go @@ -27,7 +27,7 @@ func TestMapFSChmodDot(t *testing.T) { ".": &MapFile{Mode: 0777 | fs.ModeDir}, } buf := new(strings.Builder) - fs.WalkDir(m, ".", func { path, d, err | + fs.WalkDir(m, ".", func { path, d, err -> fi, err := d.Info() if err != nil { return err diff --git a/src/testing/fstest/testfs.go b/src/testing/fstest/testfs.go index 3072d4767cb63..51f68afce80e0 100644 --- a/src/testing/fstest/testfs.go +++ b/src/testing/fstest/testfs.go @@ -488,7 +488,7 @@ func (t *fsTester) checkDirList(dir, desc string, list1, list2 []fs.DirEntry) { return } - slices.SortFunc(diffs, func { a, b | + slices.SortFunc(diffs, func { a, b -> fa := strings.Fields(a) fb := strings.Fields(b) // sort by name (i < j) and then +/- (j < i, because + < -) @@ -546,7 +546,7 @@ func (t *fsTester) checkFile(file string) { t.checkFileRead(file, "Readall vs second fsys.ReadFile", data, data2) t.checkBadPath(file, "ReadFile", - func { name | + func { name -> _, err := fsys.ReadFile(name) return err }) @@ -581,7 +581,7 @@ func (t *fsTester) checkFileRead(file, desc string, data1, data2 []byte) { // checkBadPath checks that various invalid forms of file's name cannot be opened using t.fsys.Open. func (t *fsTester) checkOpen(file string) { - t.checkBadPath(file, "Open", func { file | + t.checkBadPath(file, "Open", func { file -> f, err := t.fsys.Open(file) if err == nil { f.Close() diff --git a/src/testing/fstest/testfs_test.go b/src/testing/fstest/testfs_test.go index 2d959a73fdf64..a67f8cd77e7da 100644 --- a/src/testing/fstest/testfs_test.go +++ b/src/testing/fstest/testfs_test.go @@ -62,7 +62,7 @@ func (f *shuffledFile) ReadDir(n int) ([]fs.DirEntry, error) { // // We do this to make sure that the TestFS test suite is not affected by the // order of directory entries. - slices.SortFunc(dirents, func { a, b | return strings.Compare(b.Name(), a.Name()) }) + slices.SortFunc(dirents, func { a, b -> return strings.Compare(b.Name(), a.Name()) }) return dirents, err } diff --git a/src/testing/fuzz.go b/src/testing/fuzz.go index 9dd599bed1943..f5711254b1a75 100644 --- a/src/testing/fuzz.go +++ b/src/testing/fuzz.go @@ -319,7 +319,7 @@ func (f *F) Fuzz(ff any) { t.chatty.Updatef(t.name, "=== RUN %s\n", t.name) } f.common.inFuzzFn, f.inFuzzFn = true, true - go tRunner(t, func { t | + go tRunner(t, func { t -> args := []reflect.Value{reflect.ValueOf(t)} for _, v := range e.Values { args = append(args, reflect.ValueOf(v)) @@ -376,7 +376,7 @@ func (f *F) Fuzz(ff any) { case fuzzWorker: // Fuzzing is enabled, and this is a worker process. Follow instructions // from the coordinator. - if err := f.fuzzContext.deps.RunFuzzWorker(func { e | + if err := f.fuzzContext.deps.RunFuzzWorker(func { e -> // Don't write to f.w (which points to Stdout) if running from a // fuzz worker. This would become very verbose, particularly during // minimization. Return the error instead, and let the caller deal diff --git a/src/testing/helperfuncs_test.go b/src/testing/helperfuncs_test.go index 6e3ee21673ee1..4aea4bc158228 100644 --- a/src/testing/helperfuncs_test.go +++ b/src/testing/helperfuncs_test.go @@ -55,7 +55,7 @@ func testHelper(t *testing.T) { } fn("4") - t.Run("sub", func { t | + t.Run("sub", func { t -> helper(t, "5") notHelperCallingHelper(t, "6") // Check that calling Helper from inside a subtest entry function @@ -101,7 +101,7 @@ func parallelTestHelper(t *testing.T) { func helperSubCallingHelper(t *testing.T, msg string) { t.Helper() - t.Run("sub2", func { t | + t.Run("sub2", func { t -> t.Helper() t.Fatal(msg) }) diff --git a/src/testing/iotest/reader_test.go b/src/testing/iotest/reader_test.go index bf1c3b178a1cd..ab48cadc70b40 100644 --- a/src/testing/iotest/reader_test.go +++ b/src/testing/iotest/reader_test.go @@ -239,7 +239,7 @@ func TestErrReader(t *testing.T) { for _, tt := range cases { tt := tt - t.Run(tt.name, func { t | + t.Run(tt.name, func { t -> n, err := ErrReader(tt.err).Read(nil) if err != tt.err { t.Fatalf("Error mismatch\nGot: %v\nWant: %v", err, tt.err) diff --git a/src/testing/match_test.go b/src/testing/match_test.go index 7359fa3c2cee2..289e6305a7dc4 100644 --- a/src/testing/match_test.go +++ b/src/testing/match_test.go @@ -232,7 +232,7 @@ func FuzzNaming(f *F) { } reset() - f.Fuzz(func { t, subname | + f.Fuzz(func { t, subname -> if len(subname) > 10 { // Long names attract the OOM killer. t.Skip() diff --git a/src/testing/panic_test.go b/src/testing/panic_test.go index 6bf4ebb1ff0ca..e7b10bf9673b5 100644 --- a/src/testing/panic_test.go +++ b/src/testing/panic_test.go @@ -138,7 +138,7 @@ ran outer cleanup `, }} for _, tc := range testCases { - t.Run(tc.desc, func { t | + t.Run(tc.desc, func { t -> cmd := exec.Command(os.Args[0], "-test.run=^TestPanicHelper$") cmd.Args = append(cmd.Args, tc.flags...) cmd.Env = append(os.Environ(), "GO_WANT_HELPER_PROCESS=1") @@ -181,7 +181,7 @@ func TestPanicHelper(t *testing.T) { }) for i := 0; i < 3; i++ { i := i - t.Run(fmt.Sprintf("%v", i), func { t | + t.Run(fmt.Sprintf("%v", i), func { t -> chosen := t.Name() == *testPanicTest if chosen && *testPanicCleanup { t.Cleanup(func() { @@ -250,7 +250,7 @@ func TestCallRunInCleanupHelper(t *testing.T) { } t.Cleanup(func() { - t.Run("in-cleanup", func { t | t.Log("must not be executed") }) + t.Run("in-cleanup", func { t -> t.Log("must not be executed") }) }) } diff --git a/src/testing/quick/quick_test.go b/src/testing/quick/quick_test.go index fb39f4272b88b..7d90da1b7d1e1 100644 --- a/src/testing/quick/quick_test.go +++ b/src/testing/quick/quick_test.go @@ -242,7 +242,7 @@ func TestFailure(t *testing.T) { t.Errorf("#1 Error was not a SetupError: %s", err) } - err = CheckEqual(func { x, y | }, func { x | }, nil) + err = CheckEqual(func { x, y -> }, func { x -> }, nil) if err == nil { t.Errorf("#2 CheckEqual didn't return an error") } @@ -250,7 +250,7 @@ func TestFailure(t *testing.T) { t.Errorf("#2 Error was not a SetupError: %s", err) } - err = CheckEqual(func { x | return 0 }, func { x | return 0 }, nil) + err = CheckEqual(func { x -> return 0 }, func { x -> return 0 }, nil) if err == nil { t.Errorf("#3 CheckEqual didn't return an error") } diff --git a/src/testing/slogtest/slogtest.go b/src/testing/slogtest/slogtest.go index 7d4dc756b4c29..8a140e60db9aa 100644 --- a/src/testing/slogtest/slogtest.go +++ b/src/testing/slogtest/slogtest.go @@ -282,7 +282,7 @@ func TestHandler(h slog.Handler, results func() []map[string]any) error { // calls result to get the result. If the test case fails, it calls t.Error. func Run(t *testing.T, newHandler func(*testing.T) slog.Handler, result func(*testing.T) map[string]any) { for _, c := range cases { - t.Run(c.name, func { t | + t.Run(c.name, func { t -> h := newHandler(t) if c.mod != nil { h = &wrapper{h, c.mod} diff --git a/src/testing/sub_test.go b/src/testing/sub_test.go index b509c8dbd8260..47c2767eed094 100644 --- a/src/testing/sub_test.go +++ b/src/testing/sub_test.go @@ -138,15 +138,15 @@ func TestTRun(t *T) { f: func(t *T) { ranSeq := false ranPar := false - t.Run("", func { t | - t.Run("par", func { t | + t.Run("", func { t -> + t.Run("par", func { t -> t.Parallel() ranPar = true }) - t.Run("seq", func { t | ranSeq = true }) + t.Run("seq", func { t -> ranSeq = true }) t.FailNow() - t.Run("seq", func { t | realTest.Error("test must be skipped") }) - t.Run("par", func { t | + t.Run("seq", func { t -> realTest.Error("test must be skipped") }) + t.Run("par", func { t -> t.Parallel() realTest.Error("test must be skipped.") }) @@ -168,9 +168,9 @@ func TestTRun(t *T) { --- FAIL: failure in parallel test propagates upwards/#00/par (N.NNs) `, f: func(t *T) { - t.Run("", func { t | + t.Run("", func { t -> t.Parallel() - t.Run("par", func { t | + t.Run("par", func { t -> t.Parallel() t.Fail() }) @@ -196,7 +196,7 @@ func TestTRun(t *T) { --- PASS: chatty with recursion/#00 (N.NNs) --- PASS: chatty with recursion/#00/#00 (N.NNs)`, f: func(t *T) { - t.Run("", func { t | t.Run("", func { t | }) }) + t.Run("", func { t -> t.Run("", func { t -> }) }) }, }, { desc: "chatty with recursion and json", @@ -222,10 +222,10 @@ func TestTRun(t *T) { ^V--- FAIL: chatty with recursion and json (N.NNs) ^V=== NAME `, f: func(t *T) { - t.Run("", func { t | - t.Run("", func { t | }) - t.Run("", func { t | t.Skip("skip") }) - t.Run("", func { t | t.Fatal("fail") }) + t.Run("", func { t -> + t.Run("", func { t -> }) + t.Run("", func { t -> t.Skip("skip") }) + t.Run("", func { t -> t.Fatal("fail") }) }) }, }, { @@ -248,9 +248,9 @@ func TestTRun(t *T) { maxPar: 1, f: func(t *T) { var count uint32 - t.Run("waitGroup", func { t | + t.Run("waitGroup", func { t -> for i := 0; i < 4; i++ { - t.Run("par", func { t | + t.Run("par", func { t -> t.Parallel() atomic.AddUint32(&count, 1) }) @@ -268,11 +268,11 @@ func TestTRun(t *T) { ok: true, maxPar: 1, f: func(t *T) { - t.Run("a", func { t | + t.Run("a", func { t -> t.Parallel() - t.Run("b", func { t | + t.Run("b", func { t -> // Sequential: ensure running count is decremented. - t.Run("c", func { t | t.Parallel() }) }) + t.Run("c", func { t -> t.Parallel() }) }) }) }, }, { @@ -284,14 +284,14 @@ func TestTRun(t *T) { maxPar: 2, f: func(t *T) { for i := 0; i < 2; i++ { - t.Run("a", func { t | + t.Run("a", func { t -> t.Parallel() time.Sleep(time.Nanosecond) for i := 0; i < 2; i++ { - t.Run("b", func { t | + t.Run("b", func { t -> time.Sleep(time.Nanosecond) for i := 0; i < 2; i++ { - t.Run("c", func { t | + t.Run("c", func { t -> t.Parallel() time.Sleep(time.Nanosecond) }) @@ -308,20 +308,20 @@ func TestTRun(t *T) { f: func(t *T) { t.Parallel() for i := 0; i < 12; i++ { - t.Run("a", func { t | + t.Run("a", func { t -> t.Parallel() time.Sleep(time.Nanosecond) for i := 0; i < 12; i++ { - t.Run("b", func { t | + t.Run("b", func { t -> time.Sleep(time.Nanosecond) for i := 0; i < 12; i++ { - t.Run("c", func { t | + t.Run("c", func { t -> t.Parallel() time.Sleep(time.Nanosecond) - t.Run("d1", func { t | }) - t.Run("d2", func { t | }) - t.Run("d3", func { t | }) - t.Run("d4", func { t | }) + t.Run("d1", func { t -> }) + t.Run("d2", func { t -> }) + t.Run("d3", func { t -> }) + t.Run("d4", func { t -> }) }) } }) @@ -348,7 +348,7 @@ func TestTRun(t *T) { f: func(t *T) { t.Errorf("first this") outer := t - t.Run("", func { t | outer.Errorf("and now this!") }) + t.Run("", func { t -> outer.Errorf("and now this!") }) t.Errorf("oh, and this too") }, }, { @@ -364,7 +364,7 @@ func TestTRun(t *T) { f: func(t *T) { outer := t t.Errorf("first this") - t.Run("", func { t | outer.Fatalf("and now this!") }) + t.Run("", func { t -> outer.Fatalf("and now this!") }) t.Errorf("Should not reach here.") }, }, { @@ -379,8 +379,8 @@ func TestTRun(t *T) { maxPar: 1, f: func(t *T) { outer := t - t.Run("", func { t | - t.Run("", func { t | outer.Errorf("Report to ancestor") }) + t.Run("", func { t -> + t.Run("", func { t -> outer.Errorf("Report to ancestor") }) t.Errorf("Still do this") }) t.Errorf("Also do this") @@ -394,9 +394,9 @@ func TestTRun(t *T) { maxPar: 1, f: func(t *T) { outer := t - t.Run("", func { t | + t.Run("", func { t -> for i := 0; i < 4; i++ { - t.Run("", func { t | outer.Fatalf("Nope") }) + t.Run("", func { t -> outer.Fatalf("Nope") }) t.Errorf("Don't do this") } t.Errorf("And neither do this") @@ -409,7 +409,7 @@ func TestTRun(t *T) { maxPar: 4, f: func(t *T) { ch := make(chan bool) - t.Run("", func { t | + t.Run("", func { t -> go func() { <-ch defer func() { @@ -435,7 +435,7 @@ func TestTRun(t *T) { maxPar: 1, f: func(t *T) { ch := make(chan bool) - t.Run("sub", func { t2 | go func() { + t.Run("sub", func { t2 -> go func() { <-ch t2.Log("message1") ch <- true @@ -456,7 +456,7 @@ func TestTRun(t *T) { maxPar: 1, f: func(t *T) { ch := make(chan bool) - t.Run("sub", func { t2 | go func() { + t.Run("sub", func { t2 -> go func() { <-ch t2.Log("message1") ch <- true @@ -477,11 +477,11 @@ func TestTRun(t *T) { sub_test.go:NNN: running cleanup`, f: func(t *T) { t.Cleanup(func() { t.Log("running cleanup") }) - t.Run("sub", func { t2 | t2.FailNow() }) + t.Run("sub", func { t2 -> t2.FailNow() }) }, }} for _, tc := range testCases { - t.Run(tc.desc, func { t | + t.Run(tc.desc, func { t -> ctx := newTestContext(tc.maxPar, allMatcher()) buf := &strings.Builder{} root := &T{ @@ -534,9 +534,9 @@ func TestBRun(t *T) { }{{ desc: "simulate sequential run of subbenchmarks.", f: func(b *B) { - b.Run("", func { b | work(b) }) + b.Run("", func { b -> work(b) }) time1 := b.result.NsPerOp() - b.Run("", func { b | work(b) }) + b.Run("", func { b -> work(b) }) time2 := b.result.NsPerOp() if time1 >= time2 { t.Errorf("no time spent in benchmark t1 >= t2 (%d >= %d)", time1, time2) @@ -545,11 +545,11 @@ func TestBRun(t *T) { }, { desc: "bytes set by all benchmarks", f: func(b *B) { - b.Run("", func { b | + b.Run("", func { b -> b.SetBytes(10) work(b) }) - b.Run("", func { b | + b.Run("", func { b -> b.SetBytes(10) work(b) }) @@ -561,12 +561,12 @@ func TestBRun(t *T) { desc: "bytes set by some benchmarks", // In this case the bytes result is meaningless, so it must be 0. f: func(b *B) { - b.Run("", func { b | + b.Run("", func { b -> b.SetBytes(10) work(b) }) - b.Run("", func { b | work(b) }) - b.Run("", func { b | + b.Run("", func { b -> work(b) }) + b.Run("", func { b -> b.SetBytes(10) work(b) }) @@ -588,7 +588,7 @@ func TestBRun(t *T) { desc: "chatty with recursion", chatty: true, f: func(b *B) { - b.Run("", func { b | b.Run("", func { b | }) }) + b.Run("", func { b -> b.Run("", func { b -> }) }) }, }, { desc: "skipping without message, not chatty", @@ -614,11 +614,11 @@ func TestBRun(t *T) { _ = append([]byte(nil), buf[:]...) } } - b.Run("", func { b | + b.Run("", func { b -> alloc(b) b.ReportAllocs() }) - b.Run("", func { b | + b.Run("", func { b -> alloc(b) b.ReportAllocs() }) @@ -637,12 +637,12 @@ func TestBRun(t *T) { desc: "cleanup is called", f: func(b *B) { var calls, cleanups, innerCalls, innerCleanups int - b.Run("", func { b | + b.Run("", func { b -> calls++ b.Cleanup(func() { cleanups++ }) - b.Run("", func { b | + b.Run("", func { b -> b.Cleanup(func() { innerCleanups++ }) @@ -662,7 +662,7 @@ func TestBRun(t *T) { failed: true, f: func(b *B) { var calls, cleanups int - b.Run("", func { b | + b.Run("", func { b -> calls++ b.Cleanup(func() { cleanups++ @@ -679,7 +679,7 @@ func TestBRun(t *T) { hideStdoutForTesting = false }() for _, tc := range testCases { - t.Run(tc.desc, func { t | + t.Run(tc.desc, func { t -> var ok bool buf := &strings.Builder{} // This is almost like the Benchmark function, except that we override @@ -728,13 +728,13 @@ func makeRegexp(s string) string { func TestBenchmarkOutput(t *T) { // Ensure Benchmark initialized common.w by invoking it with an error and // normal case. - Benchmark(func { b | b.Error("do not print this output") }) - Benchmark(func { b | }) + Benchmark(func { b -> b.Error("do not print this output") }) + Benchmark(func { b -> }) } func TestBenchmarkStartsFrom1(t *T) { var first = true - Benchmark(func { b | + Benchmark(func { b -> if first && b.N != 1 { panic(fmt.Sprintf("Benchmark() first N=%v; want 1", b.N)) } @@ -744,7 +744,7 @@ func TestBenchmarkStartsFrom1(t *T) { func TestBenchmarkReadMemStatsBeforeFirstRun(t *T) { var first = true - Benchmark(func { b | + Benchmark(func { b -> if first && (b.startAllocs == 0 || b.startBytes == 0) { panic("ReadMemStats not called before first run") } @@ -779,13 +779,13 @@ func TestRacyOutput(t *T) { context: newTestContext(1, allMatcher()), } root.chatty = newChattyPrinter(root.w) - root.Run("", func { t | + root.Run("", func { t -> var wg sync.WaitGroup for i := 0; i < 100; i++ { wg.Add(1) go func(i int) { defer wg.Done() - t.Run(fmt.Sprint(i), func { t | t.Logf("testing run %d", i) }) + t.Run(fmt.Sprint(i), func { t -> t.Logf("testing run %d", i) }) }(i) } wg.Wait() @@ -812,8 +812,8 @@ func TestLogAfterComplete(t *T) { c1 := make(chan bool) c2 := make(chan string) - tRunner(t1, func { t | - t.Run("TestLateLog", func { t | + tRunner(t1, func { t -> + t.Run("TestLateLog", func { t -> go func() { defer close(c2) defer func() { @@ -849,9 +849,9 @@ func TestBenchmark(t *T) { if Short() { t.Skip("skipping in short mode") } - res := Benchmark(func { b | + res := Benchmark(func { b -> for i := 0; i < 5; i++ { - b.Run("", func { b | for i := 0; i < b.N; i++ { + b.Run("", func { b -> for i := 0; i < b.N; i++ { time.Sleep(time.Millisecond) } }) } @@ -863,7 +863,7 @@ func TestBenchmark(t *T) { func TestCleanup(t *T) { var cleanups []int - t.Run("test", func { t | + t.Run("test", func { t -> t.Cleanup(func() { cleanups = append(cleanups, 1) }) t.Cleanup(func() { cleanups = append(cleanups, 2) }) }) @@ -874,7 +874,7 @@ func TestCleanup(t *T) { func TestConcurrentCleanup(t *T) { cleanups := 0 - t.Run("test", func { t | + t.Run("test", func { t -> var wg sync.WaitGroup wg.Add(2) for i := 0; i < 2; i++ { @@ -899,7 +899,7 @@ func TestConcurrentCleanup(t *T) { func TestCleanupCalledEvenAfterGoexit(t *T) { cleanups := 0 - t.Run("test", func { t | + t.Run("test", func { t -> t.Cleanup(func() { cleanups++ }) @@ -915,9 +915,9 @@ func TestCleanupCalledEvenAfterGoexit(t *T) { func TestRunCleanup(t *T) { outerCleanup := 0 innerCleanup := 0 - t.Run("test", func { t | + t.Run("test", func { t -> t.Cleanup(func() { outerCleanup++ }) - t.Run("x", func { t | t.Cleanup(func() { innerCleanup++ }) }) + t.Run("x", func { t -> t.Cleanup(func() { innerCleanup++ }) }) }) if innerCleanup != 1 { t.Errorf("unexpected inner cleanup count; got %d want 1", innerCleanup) @@ -929,9 +929,9 @@ func TestRunCleanup(t *T) { func TestCleanupParallelSubtests(t *T) { ranCleanup := 0 - t.Run("test", func { t | + t.Run("test", func { t -> t.Cleanup(func() { ranCleanup++ }) - t.Run("x", func { t | + t.Run("x", func { t -> t.Parallel() if ranCleanup > 0 { t.Error("outer cleanup ran before parallel subtest") @@ -945,7 +945,7 @@ func TestCleanupParallelSubtests(t *T) { func TestNestedCleanup(t *T) { ranCleanup := 0 - t.Run("test", func { t | + t.Run("test", func { t -> t.Cleanup(func() { if ranCleanup != 2 { t.Errorf("unexpected cleanup count in first cleanup: got %d want 2", ranCleanup) diff --git a/src/testing/testing.go b/src/testing/testing.go index ed119da3c4b48..cd3f78924aba1 100644 --- a/src/testing/testing.go +++ b/src/testing/testing.go @@ -2016,8 +2016,8 @@ func (m *M) Run() (code int) { } fmt.Println("-test.shuffle", n) rng := rand.New(rand.NewSource(n)) - rng.Shuffle(len(m.tests), func { i, j | m.tests[i], m.tests[j] = m.tests[j], m.tests[i] }) - rng.Shuffle(len(m.benchmarks), func { i, j | m.benchmarks[i], m.benchmarks[j] = m.benchmarks[j], m.benchmarks[i] }) + rng.Shuffle(len(m.tests), func { i, j -> m.tests[i], m.tests[j] = m.tests[j], m.tests[i] }) + rng.Shuffle(len(m.benchmarks), func { i, j -> m.benchmarks[i], m.benchmarks[j] = m.benchmarks[j], m.benchmarks[i] }) } parseCpuList() @@ -2163,7 +2163,7 @@ func runTests(matchString func(pat, str string) (bool, error), tests []InternalT if Verbose() { t.chatty = newChattyPrinter(t.w) } - tRunner(t, func { t | for _, test := range tests { + tRunner(t, func { t -> for _, test := range tests { t.Run(test.Name, test.F) } }) select { @@ -2376,7 +2376,7 @@ func (m *M) startAlarm() time.Time { // runningList returns the list of running tests. func runningList() []string { var list []string - running.Range(func { k, v | + running.Range(func { k, v -> list = append(list, fmt.Sprintf("%s (%v)", k.(string), highPrecisionTimeSince(v.(highPrecisionTime)).Round(time.Second))) return true }) diff --git a/src/testing/testing_test.go b/src/testing/testing_test.go index f2faf2efd3ca5..5304197bf1257 100644 --- a/src/testing/testing_test.go +++ b/src/testing/testing_test.go @@ -46,7 +46,7 @@ func TestMain(m *testing.M) { func TestTempDirInCleanup(t *testing.T) { var dir string - t.Run("test", func { t | + t.Run("test", func { t -> t.Cleanup(func() { dir = t.TempDir() }) @@ -63,8 +63,8 @@ func TestTempDirInCleanup(t *testing.T) { } func TestTempDirInBenchmark(t *testing.T) { - testing.Benchmark(func { b | - if !b.Run("test", func { b | + testing.Benchmark(func { b -> + if !b.Run("test", func { b -> // Add a loop so that the test won't fail. See issue 38677. for i := 0; i < b.N; i++ { _ = b.TempDir() @@ -182,7 +182,7 @@ func TestSetenv(t *testing.T) { os.Unsetenv(test.key) } - t.Run(test.name, func { t | + t.Run(test.name, func { t -> t.Setenv(test.key, test.newValue) if os.Getenv(test.key) != test.newValue { t.Fatalf("unexpected value after t.Setenv: got %s, want %s", os.Getenv(test.key), test.newValue) @@ -228,7 +228,7 @@ func TestSetenvWithParallelBeforeSetenv(t *testing.T) { func TestSetenvWithParallelParentBeforeSetenv(t *testing.T) { t.Parallel() - t.Run("child", func { t | + t.Run("child", func { t -> defer func() { want := "testing: t.Setenv called after t.Parallel; cannot set environment variables in parallel tests" if got := recover(); got != want { @@ -243,8 +243,8 @@ func TestSetenvWithParallelParentBeforeSetenv(t *testing.T) { func TestSetenvWithParallelGrandParentBeforeSetenv(t *testing.T) { t.Parallel() - t.Run("child", func { t | - t.Run("grand-child", func { t | + t.Run("child", func { t -> + t.Run("grand-child", func { t -> defer func() { want := "testing: t.Setenv called after t.Parallel; cannot set environment variables in parallel tests" if got := recover(); got != want { @@ -353,7 +353,7 @@ func doRace() { func TestRaceReports(t *testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { // Generate a race detector report in a sub test. - t.Run("Sub", func { t | doRace() }) + t.Run("Sub", func { t -> doRace() }) return } @@ -388,13 +388,13 @@ func TestRaceSubReports(t *testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { t.Parallel() c1 := make(chan bool, 1) - t.Run("sub", func { t | - t.Run("subsub1", func { t | + t.Run("sub", func { t -> + t.Run("subsub1", func { t -> t.Parallel() doRace() c1 <- true }) - t.Run("subsub2", func { t | + t.Run("subsub2", func { t -> t.Parallel() doRace() <-c1 @@ -435,7 +435,7 @@ func TestRaceInCleanup(t *testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { t.Cleanup(doRace) t.Parallel() - t.Run("sub", func { t | t.Parallel() })// No race should be reported for sub. + t.Run("sub", func { t -> t.Parallel() })// No race should be reported for sub. return } @@ -466,8 +466,8 @@ func TestRaceInCleanup(t *testing.T) { func TestDeepSubtestRace(t *testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { - t.Run("sub", func { t | - t.Run("subsub", func { t | t.Run("subsubsub", func { t | doRace() }) }) + t.Run("sub", func { t -> + t.Run("subsub", func { t -> t.Run("subsubsub", func { t -> doRace() }) }) doRace() }) return @@ -497,13 +497,13 @@ func TestRaceDuringParallelFailsAllSubtests(t *testing.T) { close(done) }() - t.Run("sub", func { t | - t.Run("subsub1", func { t | + t.Run("sub", func { t -> + t.Run("subsub1", func { t -> t.Parallel() ready.Done() <-done }) - t.Run("subsub2", func { t | + t.Run("subsub2", func { t -> t.Parallel() ready.Done() <-done @@ -528,7 +528,7 @@ func TestRaceDuringParallelFailsAllSubtests(t *testing.T) { func TestRaceBeforeParallel(t *testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { - t.Run("sub", func { t | + t.Run("sub", func { t -> doRace() t.Parallel() }) @@ -616,7 +616,7 @@ func BenchmarkSubRacy(b *testing.B) { b.Skipf("skipping intentionally-racy benchmark") } - b.Run("non-racy", func { b | + b.Run("non-racy", func { b -> tot := 0 for i := 0; i < b.N; i++ { tot++ @@ -624,7 +624,7 @@ func BenchmarkSubRacy(b *testing.B) { _ = tot }) - b.Run("racy", func { b | for i := 0; i < b.N; i++ { + b.Run("racy", func { b -> for i := 0; i < b.N; i++ { doRace() } }) @@ -640,10 +640,10 @@ func TestRunningTests(t *testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { for i := 0; i < 2; i++ { - t.Run(fmt.Sprintf("outer%d", i), func { t | + t.Run(fmt.Sprintf("outer%d", i), func { t -> t.Parallel() for j := 0; j < 2; j++ { - t.Run(fmt.Sprintf("inner%d", j), func { t | + t.Run(fmt.Sprintf("inner%d", j), func { t -> t.Parallel() for { time.Sleep(1 * time.Millisecond) @@ -694,7 +694,7 @@ func TestRunningTestsInCleanup(t *testing.T) { if os.Getenv("GO_WANT_HELPER_PROCESS") == "1" { for i := 0; i < 2; i++ { - t.Run(fmt.Sprintf("outer%d", i), func { t | + t.Run(fmt.Sprintf("outer%d", i), func { t -> // Not parallel: we expect to see only one outer test, // stuck in cleanup after its subtest finishes. @@ -705,7 +705,7 @@ func TestRunningTestsInCleanup(t *testing.T) { }) for j := 0; j < 2; j++ { - t.Run(fmt.Sprintf("inner%d", j), func { t | t.Parallel() }) + t.Run(fmt.Sprintf("inner%d", j), func { t -> t.Parallel() }) } }) } @@ -793,9 +793,9 @@ func TestParentRun(t1 *testing.T) { // Regression test for https://go.dev/issue/64402: // this deadlocked after https://go.dev/cl/506755. - t1.Run("outer", func { t2 | + t1.Run("outer", func { t2 -> t2.Log("Hello outer!") - t1.Run("not_inner", func { t3 | // Note: this is t1.Run, not t2.Run. + t1.Run("not_inner", func { t3 -> // Note: this is t1.Run, not t2.Run. t3.Log("Hello inner!") }) }) } diff --git a/src/text/scanner/example_test.go b/src/text/scanner/example_test.go index 196cf48c5d305..941a185bd7178 100644 --- a/src/text/scanner/example_test.go +++ b/src/text/scanner/example_test.go @@ -53,7 +53,7 @@ func Example_isIdentRune() { s.Filename = "percent" // treat leading '%' as part of an identifier - s.IsIdentRune = func { ch, i | return ch == '%' && i == 0 || unicode.IsLetter(ch) || unicode.IsDigit(ch) && i > 0 } + s.IsIdentRune = func { ch, i -> return ch == '%' && i == 0 || unicode.IsLetter(ch) || unicode.IsDigit(ch) && i > 0 } for tok := s.Scan(); tok != scanner.EOF; tok = s.Scan() { fmt.Printf("%s: %s\n", s.Position, s.TokenText()) diff --git a/src/text/scanner/scanner_test.go b/src/text/scanner/scanner_test.go index 713094ad42eea..a726308c9666c 100644 --- a/src/text/scanner/scanner_test.go +++ b/src/text/scanner/scanner_test.go @@ -293,7 +293,7 @@ func TestScan(t *testing.T) { func TestInvalidExponent(t *testing.T) { const src = "1.5e 1.5E 1e+ 1e- 1.5z" s := new(Scanner).Init(strings.NewReader(src)) - s.Error = func { s, msg | + s.Error = func { s, msg -> const want = "exponent has no digits" if msg != want { t.Errorf("%s: got error %q; want %q", s.TokenText(), msg, want) @@ -392,7 +392,7 @@ func TestScanCustomIdent(t *testing.T) { // ident = ( 'a' | 'b' ) { digit } . // digit = '0' .. '3' . // with a maximum length of 4 - s.IsIdentRune = func { ch, i | return i == 0 && (ch == 'a' || ch == 'b') || 0 < i && i < 4 && '0' <= ch && ch <= '3' } + s.IsIdentRune = func { ch, i -> return i == 0 && (ch == 'a' || ch == 'b') || 0 < i && i < 4 && '0' <= ch && ch <= '3' } checkTok(t, s, 1, s.Scan(), 'f', "f") checkTok(t, s, 1, s.Scan(), Ident, "a") checkTok(t, s, 1, s.Scan(), Ident, "a") @@ -453,7 +453,7 @@ func TestScanWhitespace(t *testing.T) { func testError(t *testing.T, src, pos, msg string, tok rune) { s := new(Scanner).Init(strings.NewReader(src)) errorCalled := false - s.Error = func { s, m | + s.Error = func { s, m -> if !errorCalled { // only look at first error if p := s.Pos().String(); p != pos { @@ -525,7 +525,7 @@ func (errReader) Read(b []byte) (int, error) { func TestIOError(t *testing.T) { s := new(Scanner).Init(errReader{}) errorCalled := false - s.Error = func { s, msg | + s.Error = func { s, msg -> if !errorCalled { if want := io.ErrNoProgress.Error(); msg != want { t.Errorf("msg = %q, want %q", msg, want) @@ -699,7 +699,7 @@ func TestScanEOFHandling(t *testing.T) { func TestIssue29723(t *testing.T) { s := new(Scanner).Init(strings.NewReader(`x "`)) - s.Error = func { s, _ | + s.Error = func { s, _ -> got := s.TokenText() // this call shouldn't panic const want = `"` if got != want { @@ -846,7 +846,7 @@ func TestNumbers(t *testing.T) { } { s := new(Scanner).Init(strings.NewReader(test.src)) var err string - s.Error = func { s, msg | if err == "" { + s.Error = func { s, msg -> if err == "" { err = msg } } @@ -913,7 +913,7 @@ func extractInts(t string, mode uint) (res string) { func TestIssue50909(t *testing.T) { var s Scanner s.Init(strings.NewReader("hello \n\nworld\n!\n")) - s.IsIdentRune = func { ch, _ | return ch != '\n' } + s.IsIdentRune = func { ch, _ -> return ch != '\n' } r := "" n := 0 diff --git a/src/text/tabwriter/tabwriter_test.go b/src/text/tabwriter/tabwriter_test.go index ec314c6a1ae40..cb78e62141723 100644 --- a/src/text/tabwriter/tabwriter_test.go +++ b/src/text/tabwriter/tabwriter_test.go @@ -659,8 +659,8 @@ func BenchmarkTable(b *testing.B) { line := bytes.Repeat([]byte("a\t"), w) line = append(line, '\n') for _, h := range [...]int{10, 1000, 100000} { - b.Run(fmt.Sprintf("%dx%d", w, h), func { b | - b.Run("new", func { b | + b.Run(fmt.Sprintf("%dx%d", w, h), func { b -> + b.Run("new", func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings @@ -672,7 +672,7 @@ func BenchmarkTable(b *testing.B) { } }) - b.Run("reuse", func { b | + b.Run("reuse", func { b -> b.ReportAllocs() w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings for i := 0; i < b.N; i++ { @@ -692,7 +692,7 @@ func BenchmarkPyramid(b *testing.B) { for _, x := range [...]int{10, 100, 1000} { // Build a line with x cells. line := bytes.Repeat([]byte("a\t"), x) - b.Run(fmt.Sprintf("%d", x), func { b | + b.Run(fmt.Sprintf("%d", x), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings @@ -714,7 +714,7 @@ func BenchmarkRagged(b *testing.B) { lines[i] = bytes.Repeat([]byte("a\t"), w) } for _, h := range [...]int{10, 100, 1000} { - b.Run(fmt.Sprintf("%d", h), func { b | + b.Run(fmt.Sprintf("%d", h), func { b -> b.ReportAllocs() for i := 0; i < b.N; i++ { w := NewWriter(io.Discard, 4, 4, 1, ' ', 0) // no particular reason for these settings diff --git a/src/text/template/exec_test.go b/src/text/template/exec_test.go index 21c4abd1ce873..dc1af48c0b0f2 100644 --- a/src/text/template/exec_test.go +++ b/src/text/template/exec_test.go @@ -1527,7 +1527,7 @@ func TestEvalFieldErrors(t *testing.T) { }, } for _, tc := range tests { - t.Run(tc.name, func { t | + t.Run(tc.name, func { t -> tmpl := Must(New("tmpl").Parse(tc.src)) err := tmpl.Execute(io.Discard, tc.value) got := "" diff --git a/src/text/template/parse/parse_test.go b/src/text/template/parse/parse_test.go index 620658e9572bb..15194a036b868 100644 --- a/src/text/template/parse/parse_test.go +++ b/src/text/template/parse/parse_test.go @@ -384,7 +384,7 @@ func TestParseWithComments(t *testing.T) { {"comment trim left and right", "x \r\n\t{{- /* */ -}}\n\n\ty", noError, `"x"{{/* */}}"y"`}, } for _, test := range tests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> tr := New(test.name) tr.Mode = ParseComments tmpl, err := tr.Parse(test.input, "", "", make(map[string]*Tree)) @@ -598,7 +598,7 @@ var errorTests = []parseTest{ func TestErrors(t *testing.T) { for _, test := range errorTests { - t.Run(test.name, func { t | + t.Run(test.name, func { t -> _, err := New(test.name).Parse(test.input, "", "", make(map[string]*Tree)) if err == nil { t.Fatalf("expected error %q, got nil", test.result) diff --git a/src/time/format_test.go b/src/time/format_test.go index 80d3c46c634b3..869cc1c895fb6 100644 --- a/src/time/format_test.go +++ b/src/time/format_test.go @@ -1008,7 +1008,7 @@ func FuzzFormatRFC3339(f *testing.F) { } } - f.Fuzz(func { t, sec, nsec, useUTC, useLocal, tzOffset | + f.Fuzz(func { t, sec, nsec, useUTC, useLocal, tzOffset -> var loc *Location switch { case useUTC: @@ -1048,7 +1048,7 @@ func FuzzParseRFC3339(f *testing.F) { f.Add(tt.value) } - f.Fuzz(func { t, s | + f.Fuzz(func { t, s -> // equalTime is like time.Time.Equal, but also compares the time zone. equalTime := func(t1, t2 Time) bool { name1, offset1 := t1.Zone() diff --git a/src/time/genzabbrs.go b/src/time/genzabbrs.go index bd58bc0fc567c..c5971a10db427 100644 --- a/src/time/genzabbrs.go +++ b/src/time/genzabbrs.go @@ -110,7 +110,7 @@ func main() { if err != nil { log.Fatal(err) } - slices.SortFunc(zs, func { a, b | return strings.Compare(a.UnixName, b.UnixName) }) + slices.SortFunc(zs, func { a, b -> return strings.Compare(a.UnixName, b.UnixName) }) var v = struct { URL string Zs []*zone diff --git a/src/time/sleep_test.go b/src/time/sleep_test.go index e1d92415bb462..43bf9b73cb225 100644 --- a/src/time/sleep_test.go +++ b/src/time/sleep_test.go @@ -205,7 +205,7 @@ func benchmark(b *testing.B, bench func(*testing.PB)) { } func BenchmarkAfterFunc1000(b *testing.B) { - benchmark(b, func { pb | + benchmark(b, func { pb -> for pb.Next() { n := 1000 c := make(chan bool) @@ -225,24 +225,24 @@ func BenchmarkAfterFunc1000(b *testing.B) { } func BenchmarkAfter(b *testing.B) { - benchmark(b, func { pb | for pb.Next() { + benchmark(b, func { pb -> for pb.Next() { <-After(1) } }) } func BenchmarkStop(b *testing.B) { - b.Run("impl=chan", func { b | benchmark(b, func { pb | for pb.Next() { + b.Run("impl=chan", func { b -> benchmark(b, func { pb -> for pb.Next() { NewTimer(1 * Second).Stop() } }) }) - b.Run("impl=func", func { b | - benchmark(b, func { pb | for pb.Next() { + b.Run("impl=func", func { b -> + benchmark(b, func { pb -> for pb.Next() { newTimerFunc(1 * Second).Stop() } }) }) } func BenchmarkSimultaneousAfterFunc1000(b *testing.B) { - benchmark(b, func { pb | + benchmark(b, func { pb -> for pb.Next() { n := 1000 var wg sync.WaitGroup @@ -256,7 +256,7 @@ func BenchmarkSimultaneousAfterFunc1000(b *testing.B) { } func BenchmarkStartStop1000(b *testing.B) { - benchmark(b, func { pb | + benchmark(b, func { pb -> for pb.Next() { const N = 1000 timers := make([]*Timer, N) @@ -272,8 +272,8 @@ func BenchmarkStartStop1000(b *testing.B) { } func BenchmarkReset(b *testing.B) { - b.Run("impl=chan", func { b | - benchmark(b, func { pb | + b.Run("impl=chan", func { b -> + benchmark(b, func { pb -> t := NewTimer(Hour) for pb.Next() { t.Reset(Hour) @@ -281,8 +281,8 @@ func BenchmarkReset(b *testing.B) { t.Stop() }) }) - b.Run("impl=func", func { b | - benchmark(b, func { pb | + b.Run("impl=func", func { b -> + benchmark(b, func { pb -> t := newTimerFunc(Hour) for pb.Next() { t.Reset(Hour) @@ -293,7 +293,7 @@ func BenchmarkReset(b *testing.B) { } func BenchmarkSleep1000(b *testing.B) { - benchmark(b, func { pb | + benchmark(b, func { pb -> for pb.Next() { const N = 1000 var wg sync.WaitGroup @@ -345,8 +345,8 @@ func TestAfterTick(t *testing.T) { } func TestAfterStop(t *testing.T) { - t.Run("impl=chan", func { t | testAfterStop(t, NewTimer) }) - t.Run("impl=func", func { t | testAfterStop(t, newTimerFunc) }) + t.Run("impl=chan", func { t -> testAfterStop(t, NewTimer) }) + t.Run("impl=func", func { t -> testAfterStop(t, newTimerFunc) }) } func testAfterStop(t *testing.T, newTimer func(Duration) *Timer) { @@ -406,8 +406,8 @@ func testAfterStop(t *testing.T, newTimer func(Duration) *Timer) { } func TestAfterQueuing(t *testing.T) { - t.Run("impl=chan", func { t | testAfterQueuing(t, After) }) - t.Run("impl=func", func { t | testAfterQueuing(t, func { d | return newTimerFunc(d).C }) }) + t.Run("impl=chan", func { t -> testAfterQueuing(t, After) }) + t.Run("impl=func", func { t -> testAfterQueuing(t, func { d -> return newTimerFunc(d).C }) }) } func testAfterQueuing(t *testing.T, after func(Duration) <-chan Time) { @@ -634,11 +634,11 @@ func TestZeroTimerStopPanics(t *testing.T) { // Test that zero duration timers aren't missed by the scheduler. Regression test for issue 44868. func TestZeroTimer(t *testing.T) { - t.Run("impl=chan", func { t | testZeroTimer(t, NewTimer) }) - t.Run("impl=func", func { t | testZeroTimer(t, newTimerFunc) }) - t.Run("impl=cache", func { t | + t.Run("impl=chan", func { t -> testZeroTimer(t, NewTimer) }) + t.Run("impl=func", func { t -> testZeroTimer(t, newTimerFunc) }) + t.Run("impl=cache", func { t -> timer := newTimerFunc(Hour) - testZeroTimer(t, func { d | + testZeroTimer(t, func { d -> timer.Reset(d) return timer }) @@ -778,7 +778,7 @@ func TestResetResult(t *testing.T) { // Issue #69312. func testStopResetResult(t *testing.T, testStop bool) { for _, name := range []string{"0", "1", "2"} { - t.Run("asynctimerchan="+name, func { t | testStopResetResultGODEBUG(t, testStop, name) }) + t.Run("asynctimerchan="+name, func { t -> testStopResetResultGODEBUG(t, testStop, name) }) } } @@ -970,10 +970,10 @@ func BenchmarkStaggeredTickerLatency(b *testing.B) { const delay = 3 * Millisecond for _, dur := range []Duration{300 * Microsecond, 2 * Millisecond} { - b.Run(fmt.Sprintf("work-dur=%s", dur), func { b | + b.Run(fmt.Sprintf("work-dur=%s", dur), func { b -> for tickersPerP := 1; tickersPerP < int(delay/dur)+1; tickersPerP++ { tickerCount := gmp * tickersPerP - b.Run(fmt.Sprintf("tickers-per-P=%d", tickersPerP), func { b | + b.Run(fmt.Sprintf("tickers-per-P=%d", tickersPerP), func { b -> // allocate memory now to avoid GC interference later. stats := make([]struct { sum float64 @@ -1064,7 +1064,7 @@ func doWork(dur Duration) { } func BenchmarkAdjustTimers10000(b *testing.B) { - benchmark(b, func { pb | + benchmark(b, func { pb -> for pb.Next() { const n = 10000 timers := make([]*Timer, 0, n) diff --git a/src/time/tick_test.go b/src/time/tick_test.go index b89594b5dac9c..d05085d7c5503 100644 --- a/src/time/tick_test.go +++ b/src/time/tick_test.go @@ -231,7 +231,7 @@ func TestLongAdjustTimers(t *testing.T) { } } func BenchmarkTicker(b *testing.B) { - benchmark(b, func { pb | + benchmark(b, func { pb -> ticker := NewTicker(Nanosecond) for pb.Next() { <-ticker.C @@ -241,7 +241,7 @@ func BenchmarkTicker(b *testing.B) { } func BenchmarkTickerReset(b *testing.B) { - benchmark(b, func { pb | + benchmark(b, func { pb -> ticker := NewTicker(Nanosecond) for pb.Next() { ticker.Reset(Nanosecond * 2) @@ -251,7 +251,7 @@ func BenchmarkTickerReset(b *testing.B) { } func BenchmarkTickerResetNaive(b *testing.B) { - benchmark(b, func { pb | + benchmark(b, func { pb -> ticker := NewTicker(Nanosecond) for pb.Next() { ticker.Stop() @@ -264,7 +264,7 @@ func BenchmarkTickerResetNaive(b *testing.B) { func TestTimerGC(t *testing.T) { run := func(t *testing.T, what string, f func()) { t.Helper() - t.Run(what, func { t | + t.Run(what, func { t -> t.Helper() const N = 1e4 var stats runtime.MemStats @@ -308,13 +308,13 @@ func TestTimerGC(t *testing.T) { func TestChan(t *testing.T) { for _, name := range []string{"0", "1", "2"} { - t.Run("asynctimerchan="+name, func { t | + t.Run("asynctimerchan="+name, func { t -> t.Setenv("GODEBUG", "asynctimerchan="+name) - t.Run("Timer", func { t | + t.Run("Timer", func { t -> tim := NewTimer(10000 * Second) testTimerChan(t, tim, tim.C, name == "0") }) - t.Run("Ticker", func { t | + t.Run("Ticker", func { t -> tim := &tickerTimer{Ticker: NewTicker(10000 * Second)} testTimerChan(t, tim, tim.C, name == "0") }) diff --git a/src/unicode/letter_test.go b/src/unicode/letter_test.go index 7fedd5455ecf5..458322d42d89c 100644 --- a/src/unicode/letter_test.go +++ b/src/unicode/letter_test.go @@ -464,7 +464,7 @@ func TestCalibrate(t *testing.T) { // The 10% bias gives linear search an edge when they're close, // because on predominantly ASCII inputs linear search is even // better than our benchmarks measure. - n := sort.Search(64, func { n | + n := sort.Search(64, func { n -> tab := fakeTable(n) blinear := func(b *testing.B) { tab := tab diff --git a/src/unicode/utf8/utf8_test.go b/src/unicode/utf8/utf8_test.go index c1ea335f212d1..0e213c107d533 100644 --- a/src/unicode/utf8/utf8_test.go +++ b/src/unicode/utf8/utf8_test.go @@ -694,7 +694,7 @@ func BenchmarkFullRune(b *testing.B) { {"Japanese", []byte("本")}, } for _, bm := range benchmarks { - b.Run(bm.name, func { b | for i := 0; i < b.N; i++ { + b.Run(bm.name, func { b -> for i := 0; i < b.N; i++ { boolSink = FullRune(bm.data) } }) } diff --git a/src/unique/clone_test.go b/src/unique/clone_test.go index e334b29936e0e..228ec4a212d22 100644 --- a/src/unique/clone_test.go +++ b/src/unique/clone_test.go @@ -28,7 +28,7 @@ func cSeq(stringOffsets ...uintptr) cloneSeq { func testCloneSeq[T any](t *testing.T, want cloneSeq) { typName := reflect.TypeFor[T]().Name() typ := abi.TypeFor[T]() - t.Run(typName, func { t | + t.Run(typName, func { t -> got := makeCloneSeq(typ) if !reflect.DeepEqual(got, want) { t.Errorf("unexpected cloneSeq for type %s: got %#v, want %#v", typName, got, want) diff --git a/src/unique/handle.go b/src/unique/handle.go index da34c49e2b39a..8fd5adb8e2635 100644 --- a/src/unique/handle.go +++ b/src/unique/handle.go @@ -127,7 +127,7 @@ func addUniqueMap[T comparable](typ *abi.Type) *uniqueMap[T] { cleanupFuncs = append(cleanupFuncs, func() { // Delete all the entries whose weak references are nil and clean up // deleted entries. - m.All()(func { key, wp | + m.All()(func { key, wp -> if wp.Strong() == nil { m.CompareAndDelete(key, wp) } diff --git a/src/unique/handle_bench_test.go b/src/unique/handle_bench_test.go index c06b042123007..533ef711088b5 100644 --- a/src/unique/handle_bench_test.go +++ b/src/unique/handle_bench_test.go @@ -31,7 +31,7 @@ func benchmarkMake(b *testing.B, testData []string) { b.ReportAllocs() b.ResetTimer() - b.RunParallel(func { pb | + b.RunParallel(func { pb -> i := 0 for pb.Next() { _ = Make(testData[i]) diff --git a/src/unique/handle_test.go b/src/unique/handle_test.go index a5c4efdc00101..22ebc3b67095c 100644 --- a/src/unique/handle_test.go +++ b/src/unique/handle_test.go @@ -49,7 +49,7 @@ func TestHandle(t *testing.T) { func testHandle[T comparable](t *testing.T, value T) { name := reflect.TypeFor[T]().Name() - t.Run(fmt.Sprintf("%s/%#v", name, value), func { t | + t.Run(fmt.Sprintf("%s/%#v", name, value), func { t -> t.Parallel() v0 := Make(value) @@ -117,7 +117,7 @@ func checkMapsFor[T comparable](t *testing.T, value T) { func TestMakeClonesStrings(t *testing.T) { s := strings.Clone("abcdefghijklmnopqrstuvwxyz") // N.B. Must be big enough to not be tiny-allocated. ran := make(chan bool) - runtime.SetFinalizer(unsafe.StringData(s), func { _ | ran <- true }) + runtime.SetFinalizer(unsafe.StringData(s), func { _ -> ran <- true }) h := Make(s) // Clean up s (hopefully) and run the finalizer. diff --git a/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go b/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go index 0c34ba8567fb7..94aa1aac9b665 100644 --- a/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go +++ b/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go @@ -35,7 +35,7 @@ func (b *Builder) AddASN1Enum(v int64) { } func (b *Builder) addASN1Signed(tag asn1.Tag, v int64) { - b.AddASN1(tag, func { c | + b.AddASN1(tag, func { c -> length := 1 for i := v; i >= 0x80 || i < -0x80; i >>= 8 { length++ @@ -50,7 +50,7 @@ func (b *Builder) addASN1Signed(tag asn1.Tag, v int64) { // AddASN1Uint64 appends a DER-encoded ASN.1 INTEGER. func (b *Builder) AddASN1Uint64(v uint64) { - b.AddASN1(asn1.INTEGER, func { c | + b.AddASN1(asn1.INTEGER, func { c -> length := 1 for i := v; i >= 0x80; i >>= 8 { length++ @@ -69,7 +69,7 @@ func (b *Builder) AddASN1BigInt(n *big.Int) { return } - b.AddASN1(asn1.INTEGER, func { c | + b.AddASN1(asn1.INTEGER, func { c -> if n.Sign() < 0 { // A negative number has to be converted to two's-complement form. So we // invert and subtract 1. If the most-significant-bit isn't set then @@ -99,7 +99,7 @@ func (b *Builder) AddASN1BigInt(n *big.Int) { // AddASN1OctetString appends a DER-encoded ASN.1 OCTET STRING. func (b *Builder) AddASN1OctetString(bytes []byte) { - b.AddASN1(asn1.OCTET_STRING, func { c | c.AddBytes(bytes) }) + b.AddASN1(asn1.OCTET_STRING, func { c -> c.AddBytes(bytes) }) } const generalizedTimeFormatStr = "20060102150405Z0700" @@ -110,12 +110,12 @@ func (b *Builder) AddASN1GeneralizedTime(t time.Time) { b.err = fmt.Errorf("cryptobyte: cannot represent %v as a GeneralizedTime", t) return } - b.AddASN1(asn1.GeneralizedTime, func { c | c.AddBytes([]byte(t.Format(generalizedTimeFormatStr))) }) + b.AddASN1(asn1.GeneralizedTime, func { c -> c.AddBytes([]byte(t.Format(generalizedTimeFormatStr))) }) } // AddASN1UTCTime appends a DER-encoded ASN.1 UTCTime. func (b *Builder) AddASN1UTCTime(t time.Time) { - b.AddASN1(asn1.UTCTime, func { c | + b.AddASN1(asn1.UTCTime, func { c -> // As utilized by the X.509 profile, UTCTime can only // represent the years 1950 through 2049. if t.Year() < 1950 || t.Year() >= 2050 { @@ -129,7 +129,7 @@ func (b *Builder) AddASN1UTCTime(t time.Time) { // AddASN1BitString appends a DER-encoded ASN.1 BIT STRING. This does not // support BIT STRINGs that are not a whole number of bytes. func (b *Builder) AddASN1BitString(data []byte) { - b.AddASN1(asn1.BIT_STRING, func { b | + b.AddASN1(asn1.BIT_STRING, func { b -> b.AddUint8(0) b.AddBytes(data) }) @@ -175,7 +175,7 @@ func isValidOID(oid encoding_asn1.ObjectIdentifier) bool { } func (b *Builder) AddASN1ObjectIdentifier(oid encoding_asn1.ObjectIdentifier) { - b.AddASN1(asn1.OBJECT_IDENTIFIER, func { b | + b.AddASN1(asn1.OBJECT_IDENTIFIER, func { b -> if !isValidOID(oid) { b.err = fmt.Errorf("cryptobyte: invalid OID: %v", oid) return @@ -189,7 +189,7 @@ func (b *Builder) AddASN1ObjectIdentifier(oid encoding_asn1.ObjectIdentifier) { } func (b *Builder) AddASN1Boolean(v bool) { - b.AddASN1(asn1.BOOLEAN, func { b | if v { + b.AddASN1(asn1.BOOLEAN, func { b -> if v { b.AddUint8(0xff) } else { b.AddUint8(0) diff --git a/src/vendor/golang.org/x/net/http2/hpack/hpack.go b/src/vendor/golang.org/x/net/http2/hpack/hpack.go index 4b08e6ed2fad2..7567879e8f65c 100644 --- a/src/vendor/golang.org/x/net/http2/hpack/hpack.go +++ b/src/vendor/golang.org/x/net/http2/hpack/hpack.go @@ -219,7 +219,7 @@ func (d *Decoder) DecodeFull(p []byte) ([]HeaderField, error) { var hf []HeaderField saveFunc := d.emit defer func() { d.emit = saveFunc }() - d.emit = func { f | hf = append(hf, f) } + d.emit = func { f -> hf = append(hf, f) } if _, err := d.Write(p); err != nil { return nil, err } diff --git a/src/vendor/golang.org/x/net/nettest/conntest.go b/src/vendor/golang.org/x/net/nettest/conntest.go index 321b8814b9ae1..bb75fbdcf7065 100644 --- a/src/vendor/golang.org/x/net/nettest/conntest.go +++ b/src/vendor/golang.org/x/net/nettest/conntest.go @@ -28,17 +28,17 @@ type MakePipe func() (c1, c2 net.Conn, stop func(), err error) // run multiple times. For maximal effectiveness, run the tests under the // race detector. func TestConn(t *testing.T, mp MakePipe) { - t.Run("BasicIO", func { t | timeoutWrapper(t, mp, testBasicIO) }) - t.Run("PingPong", func { t | timeoutWrapper(t, mp, testPingPong) }) - t.Run("RacyRead", func { t | timeoutWrapper(t, mp, testRacyRead) }) - t.Run("RacyWrite", func { t | timeoutWrapper(t, mp, testRacyWrite) }) - t.Run("ReadTimeout", func { t | timeoutWrapper(t, mp, testReadTimeout) }) - t.Run("WriteTimeout", func { t | timeoutWrapper(t, mp, testWriteTimeout) }) - t.Run("PastTimeout", func { t | timeoutWrapper(t, mp, testPastTimeout) }) - t.Run("PresentTimeout", func { t | timeoutWrapper(t, mp, testPresentTimeout) }) - t.Run("FutureTimeout", func { t | timeoutWrapper(t, mp, testFutureTimeout) }) - t.Run("CloseTimeout", func { t | timeoutWrapper(t, mp, testCloseTimeout) }) - t.Run("ConcurrentMethods", func { t | timeoutWrapper(t, mp, testConcurrentMethods) }) + t.Run("BasicIO", func { t -> timeoutWrapper(t, mp, testBasicIO) }) + t.Run("PingPong", func { t -> timeoutWrapper(t, mp, testPingPong) }) + t.Run("RacyRead", func { t -> timeoutWrapper(t, mp, testRacyRead) }) + t.Run("RacyWrite", func { t -> timeoutWrapper(t, mp, testRacyWrite) }) + t.Run("ReadTimeout", func { t -> timeoutWrapper(t, mp, testReadTimeout) }) + t.Run("WriteTimeout", func { t -> timeoutWrapper(t, mp, testWriteTimeout) }) + t.Run("PastTimeout", func { t -> timeoutWrapper(t, mp, testPastTimeout) }) + t.Run("PresentTimeout", func { t -> timeoutWrapper(t, mp, testPresentTimeout) }) + t.Run("FutureTimeout", func { t -> timeoutWrapper(t, mp, testFutureTimeout) }) + t.Run("CloseTimeout", func { t -> timeoutWrapper(t, mp, testCloseTimeout) }) + t.Run("ConcurrentMethods", func { t -> timeoutWrapper(t, mp, testConcurrentMethods) }) } type connTester func(t *testing.T, c1, c2 net.Conn) diff --git a/src/vendor/golang.org/x/text/unicode/norm/normalize.go b/src/vendor/golang.org/x/text/unicode/norm/normalize.go index cbfbc461b0e32..89691bee7711e 100644 --- a/src/vendor/golang.org/x/text/unicode/norm/normalize.go +++ b/src/vendor/golang.org/x/text/unicode/norm/normalize.go @@ -117,7 +117,7 @@ func (f Form) IsNormalString(s string) bool { return true } rb := reorderBuffer{f: *ft, src: src, nsrc: len(s)} - rb.setFlusher(nil, func { rb | + rb.setFlusher(nil, func { rb -> for i := 0; i < rb.nrune; i++ { info := rb.rune[i] if bp+int(info.size) > len(s) {