fix: staticcheck and deadcode findings repo-wide, modernize counting loops

This commit is contained in:
2026-08-29 15:25:15 +02:00
parent 9a34733615
commit eacf33d0f7
33 changed files with 88 additions and 250 deletions
+15 -1
View File
@@ -38,6 +38,17 @@ func GroundTruthLOONG64(path string) (map[string][]byte, error) {
return groundTruthArch(path, "loong64")
}
// goRoot locates the GOROOT of the `go` binary on PATH: the build-time
// runtime.GOROOT is meaningless for a relocated binary, so the toolchain is
// asked directly.
func goRoot() (string, error) {
out, err := exec.Command("go", "env", "GOROOT").Output()
if err != nil {
return "", fmt.Errorf("verify: go env GOROOT: %w", err)
}
return strings.TrimSpace(string(out)), nil
}
// GroundTruthARM64 assembles the given .s file with the Go toolchain in
// AArch64 cross-assembly mode (GOARCH=arm64).
func GroundTruthARM64(path string) (map[string][]byte, error) {
@@ -45,7 +56,10 @@ func GroundTruthARM64(path string) (map[string][]byte, error) {
}
func groundTruthArch(path, goarch string) (map[string][]byte, error) {
goroot := runtime.GOROOT()
goroot, err := goRoot()
if err != nil {
return nil, err
}
asmBin := filepath.Join(goroot, "pkg", "tool", runtime.GOOS+"_"+runtime.GOARCH, "asm")
if _, err := os.Stat(asmBin); err != nil {
return nil, fmt.Errorf("verify: go tool asm not found at %s: %w", asmBin, err)