Skip to content

Commit 3e58ba0

Browse files
committed
feat: update gofmt code from go1.24.4
1 parent f2e10e0 commit 3e58ba0

Some content is hidden

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

49 files changed

+1242
-213
lines changed

go.mod

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
module github.com/golangci/gofmt
22

3-
go 1.22.0
3+
go 1.23.0
44

55
require (
6-
github.com/rogpeppe/go-internal v1.13.1
7-
golang.org/x/sync v0.10.0
8-
golang.org/x/tools v0.28.0
6+
github.com/rogpeppe/go-internal v1.14.1
7+
golang.org/x/sync v0.15.0
98
)
109

11-
require golang.org/x/mod v0.22.0 // indirect
10+
require golang.org/x/tools v0.34.0 // indirect

go.sum

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
2-
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
3-
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
4-
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
5-
golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4=
6-
golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY=
7-
golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ=
8-
golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
9-
golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8=
10-
golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw=
1+
github.com/rogpeppe/go-internal v1.14.1 h1:UQB4HGPB6osV0SQTLymcB4TgvyWu6ZyliaW0tI/otEQ=
2+
github.com/rogpeppe/go-internal v1.14.1/go.mod h1:MaRKkUm5W0goXpeCfT7UZI6fk/L7L7so1lCWt35ZSgc=
3+
golang.org/x/sync v0.15.0 h1:KWH3jNZsfyT6xfAfKiz6MRNmd46ByHDYaZ7KSkCtdW8=
4+
golang.org/x/sync v0.15.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
5+
golang.org/x/tools v0.26.0 h1:v/60pFQmzmT9ExmjDv2gGIfi3OqfKoEP6I5+umXlbnQ=
6+
golang.org/x/tools v0.26.0/go.mod h1:TPVVj70c7JJ3WCazhD8OdXcZg/og+b9+tH/KxylGwH0=

gofmt/internal/cfg/cfg.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,14 @@ const KnownEnv = `
3737
GOARCH
3838
GOARM
3939
GOARM64
40+
GOAUTH
4041
GOBIN
4142
GOCACHE
4243
GOCACHEPROG
4344
GOENV
4445
GOEXE
4546
GOEXPERIMENT
47+
GOFIPS140
4648
GOFLAGS
4749
GOGCCFLAGS
4850
GOHOSTARCH

gofmt/internal/goarch/gengoarch.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2014 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build ignore
6+
7+
package main
8+
9+
import (
10+
"bytes"
11+
"fmt"
12+
"log"
13+
"os"
14+
"strings"
15+
)
16+
17+
var goarches []string
18+
19+
func main() {
20+
data, err := os.ReadFile("../../internal/syslist/syslist.go")
21+
if err != nil {
22+
log.Fatal(err)
23+
}
24+
const goarchPrefix = `var KnownArch = map[string]bool{`
25+
inGOARCH := false
26+
for _, line := range strings.Split(string(data), "\n") {
27+
if strings.HasPrefix(line, goarchPrefix) {
28+
inGOARCH = true
29+
} else if inGOARCH && strings.HasPrefix(line, "}") {
30+
break
31+
} else if inGOARCH {
32+
goarch := strings.Fields(line)[0]
33+
goarch = strings.TrimPrefix(goarch, `"`)
34+
goarch = strings.TrimSuffix(goarch, `":`)
35+
goarches = append(goarches, goarch)
36+
}
37+
}
38+
39+
for _, target := range goarches {
40+
if target == "amd64p32" {
41+
continue
42+
}
43+
var buf bytes.Buffer
44+
fmt.Fprintf(&buf, "// Code generated by gengoarch.go using 'go generate'. DO NOT EDIT.\n\n")
45+
fmt.Fprintf(&buf, "//go:build %s\n\n", target) // must explicitly include target for bootstrapping purposes
46+
fmt.Fprintf(&buf, "package goarch\n\n")
47+
fmt.Fprintf(&buf, "const GOARCH = `%s`\n\n", target)
48+
for _, goarch := range goarches {
49+
value := 0
50+
if goarch == target {
51+
value = 1
52+
}
53+
fmt.Fprintf(&buf, "const Is%s = %d\n", strings.Title(goarch), value)
54+
}
55+
err := os.WriteFile("zgoarch_"+target+".go", buf.Bytes(), 0666)
56+
if err != nil {
57+
log.Fatal(err)
58+
}
59+
}
60+
}

gofmt/internal/goarch/goarch.go

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Copyright 2021 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// package goarch contains GOARCH-specific constants.
6+
package goarch
7+
8+
// The next line makes 'go generate' write the zgoarch*.go files with
9+
// per-arch information, including constants named $GOARCH for every
10+
// GOARCH. The constant is 1 on the current system, 0 otherwise; multiplying
11+
// by them is useful for defining GOARCH-specific constants.
12+
//
13+
//go:generate go run gengoarch.go
14+
15+
type ArchFamilyType int
16+
17+
const (
18+
AMD64 ArchFamilyType = iota
19+
ARM
20+
ARM64
21+
I386
22+
LOONG64
23+
MIPS
24+
MIPS64
25+
PPC64
26+
RISCV64
27+
S390X
28+
WASM
29+
)
30+
31+
// PtrSize is the size of a pointer in bytes - unsafe.Sizeof(uintptr(0)) but as an ideal constant.
32+
// It is also the size of the machine's native word size (that is, 4 on 32-bit systems, 8 on 64-bit).
33+
const PtrSize = 4 << (^uintptr(0) >> 63)
34+
35+
// ArchFamily is the architecture family (AMD64, ARM, ...)
36+
const ArchFamily ArchFamilyType = _ArchFamily
37+
38+
// BigEndian reports whether the architecture is big-endian.
39+
const BigEndian = IsArmbe|IsArm64be|IsMips|IsMips64|IsPpc|IsPpc64|IsS390|IsS390x|IsSparc|IsSparc64 == 1
40+
41+
// DefaultPhysPageSize is the default physical page size.
42+
const DefaultPhysPageSize = _DefaultPhysPageSize
43+
44+
// PCQuantum is the minimal unit for a program counter (1 on x86, 4 on most other systems).
45+
// The various PC tables record PC deltas pre-divided by PCQuantum.
46+
const PCQuantum = _PCQuantum
47+
48+
// Int64Align is the required alignment for a 64-bit integer (4 on 32-bit systems, 8 on 64-bit).
49+
const Int64Align = PtrSize
50+
51+
// MinFrameSize is the size of the system-reserved words at the bottom
52+
// of a frame (just above the architectural stack pointer).
53+
// It is zero on x86 and PtrSize on most non-x86 (LR-based) systems.
54+
// On PowerPC it is larger, to cover three more reserved words:
55+
// the compiler word, the link editor word, and the TOC save word.
56+
const MinFrameSize = _MinFrameSize
57+
58+
// StackAlign is the required alignment of the SP register.
59+
// The stack must be at least word aligned, but some architectures require more.
60+
const StackAlign = _StackAlign
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package goarch
6+
7+
const (
8+
_ArchFamily = I386
9+
_DefaultPhysPageSize = 4096
10+
_PCQuantum = 1
11+
_MinFrameSize = 0
12+
_StackAlign = PtrSize
13+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package goarch
6+
7+
const (
8+
_ArchFamily = AMD64
9+
_DefaultPhysPageSize = 4096
10+
_PCQuantum = 1
11+
_MinFrameSize = 0
12+
_StackAlign = PtrSize
13+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package goarch
6+
7+
const (
8+
_ArchFamily = ARM
9+
_DefaultPhysPageSize = 65536
10+
_PCQuantum = 4
11+
_MinFrameSize = 4
12+
_StackAlign = PtrSize
13+
)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2014 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package goarch
6+
7+
const (
8+
_ArchFamily = ARM64
9+
_DefaultPhysPageSize = 65536
10+
_PCQuantum = 4
11+
_MinFrameSize = 8
12+
_StackAlign = 16
13+
)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Copyright 2022 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
//go:build loong64
6+
7+
package goarch
8+
9+
const (
10+
_ArchFamily = LOONG64
11+
_DefaultPhysPageSize = 16384
12+
_PCQuantum = 4
13+
_MinFrameSize = 8
14+
_StackAlign = PtrSize
15+
)

0 commit comments

Comments
 (0)