Skip to content

Commit f2e10e0

Browse files
committed
feat: update gofmt code from go1.23.8
1 parent d62b90e commit f2e10e0

File tree

6 files changed

+51
-7
lines changed

6 files changed

+51
-7
lines changed

gofmt/gofmt.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ func backupFile(filename string, data []byte, perm fs.FileMode) (string, error)
555555
if err == nil {
556556
break
557557
}
558-
if err != nil && !os.IsExist(err) {
558+
if !os.IsExist(err) {
559559
return "", err
560560
}
561561
}

gofmt/internal/cfg/cfg.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ const KnownEnv = `
3636
GOAMD64
3737
GOARCH
3838
GOARM
39+
GOARM64
3940
GOBIN
4041
GOCACHE
4142
GOCACHEPROG
@@ -57,6 +58,7 @@ const KnownEnv = `
5758
GOPPC64
5859
GOPRIVATE
5960
GOPROXY
61+
GORISCV64
6062
GOROOT
6163
GOSUMDB
6264
GOTMPDIR

gofmt/internal/platform/supported.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func RaceDetectorSupported(goos, goarch string) bool {
2626
return goarch == "amd64" || goarch == "ppc64le" || goarch == "arm64" || goarch == "s390x"
2727
case "darwin":
2828
return goarch == "amd64" || goarch == "arm64"
29-
case "freebsd", "netbsd", "openbsd", "windows":
29+
case "freebsd", "netbsd", "windows":
3030
return goarch == "amd64"
3131
default:
3232
return false
@@ -192,6 +192,7 @@ func BuildModeSupported(compiler, buildmode, goos, goarch string) bool {
192192
"darwin/amd64", "darwin/arm64",
193193
"ios/amd64", "ios/arm64",
194194
"aix/ppc64",
195+
"openbsd/arm64",
195196
"windows/386", "windows/amd64", "windows/arm", "windows/arm64":
196197
return true
197198
}

gofmt/internal/platform/zosarch.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gofmt/internal/testenv/testenv.go

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,13 @@ func findGOROOT() (string, error) {
190190
// If runtime.GOROOT() is non-empty, assume that it is valid.
191191
//
192192
// (It might not be: for example, the user may have explicitly set GOROOT
193-
// to the wrong directory, or explicitly set GOROOT_FINAL but not GOROOT
194-
// and hasn't moved the tree to GOROOT_FINAL yet. But those cases are
193+
// to the wrong directory. But this case is
195194
// rare, and if that happens the user can fix what they broke.)
196195
return
197196
}
198197

199198
// runtime.GOROOT doesn't know where GOROOT is (perhaps because the test
200-
// binary was built with -trimpath, or perhaps because GOROOT_FINAL was set
201-
// without GOROOT and the tree hasn't been moved there yet).
199+
// binary was built with -trimpath).
202200
//
203201
// Since this is internal/testenv, we can cheat and assume that the caller
204202
// is a test of some package in a subdirectory of GOROOT/src. ('go test'
@@ -372,6 +370,15 @@ func MustInternalLink(t testing.TB, withCgo bool) {
372370
}
373371
}
374372

373+
// MustInternalLinkPIE checks whether the current system can link PIE binary using
374+
// internal linking.
375+
// If not, MustInternalLinkPIE calls t.Skip with an explanation.
376+
func MustInternalLinkPIE(t testing.TB) {
377+
if !platform.InternalLinkPIESupported(runtime.GOOS, runtime.GOARCH) {
378+
t.Skipf("skipping test: internal linking for buildmode=pie on %s/%s is not supported", runtime.GOOS, runtime.GOARCH)
379+
}
380+
}
381+
375382
// MustHaveBuildMode reports whether the current system can build programs in
376383
// the given build mode.
377384
// If not, MustHaveBuildMode calls t.Skip with an explanation.
@@ -505,3 +512,36 @@ func WriteImportcfg(t testing.TB, dstPath string, packageFiles map[string]string
505512
func SyscallIsNotSupported(err error) bool {
506513
return syscallIsNotSupported(err)
507514
}
515+
516+
// ParallelOn64Bit calls t.Parallel() unless there is a case that cannot be parallel.
517+
// This function should be used when it is necessary to avoid t.Parallel on
518+
// 32-bit machines, typically because the test uses lots of memory.
519+
func ParallelOn64Bit(t *testing.T) {
520+
if goarch.PtrSize == 4 {
521+
return
522+
}
523+
t.Parallel()
524+
}
525+
526+
// CPUProfilingBroken returns true if CPU profiling has known issues on this
527+
// platform.
528+
func CPUProfilingBroken() bool {
529+
switch runtime.GOOS {
530+
case "plan9":
531+
// Profiling unimplemented.
532+
return true
533+
case "aix":
534+
// See https://golang.org/issue/45170.
535+
return true
536+
case "ios", "dragonfly", "netbsd", "illumos", "solaris":
537+
// See https://golang.org/issue/13841.
538+
return true
539+
case "openbsd":
540+
if runtime.GOARCH == "arm" || runtime.GOARCH == "arm64" {
541+
// See https://golang.org/issue/13841.
542+
return true
543+
}
544+
}
545+
546+
return false
547+
}

gofmt/readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
## Updates
1010

11+
- 2025-04-14: Sync with go1.23.8
1112
- 2024-08-17: Sync with go1.22.6
1213
- 2023-02-28: Sync with go1.21.7
1314
- 2023-10-04: Sync with go1.20.8

0 commit comments

Comments
 (0)