Skip to content

Commit bf8589c

Browse files
committed
refactor(stdlib): replace deprecated functions with Go 1.26 equivalents
Replace sort.Strings with slices.Sort (Go 1.21+) for generic type-safe sorting and filepath.Walk with filepath.WalkDir (Go 1.16+) for improved performance by avoiding extra stat calls. - lib/fetch.go: replace sort.Strings with slices.Sort - internal/builder/libraries.go: replace filepath.Walk with filepath.WalkDir Signed-off-by: Martin Wimpress <code@wimpress.io>
1 parent 43dcf10 commit bf8589c

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

internal/builder/libraries.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,11 +907,11 @@ func touchAutomakeFiles(srcPath string) error {
907907
}
908908

909909
// Also touch any Makefile.in files in subdirectories
910-
filepath.Walk(srcPath, func(path string, info os.FileInfo, err error) error {
910+
filepath.WalkDir(srcPath, func(path string, d os.DirEntry, err error) error {
911911
if err != nil {
912912
return err
913913
}
914-
if !info.IsDir() && info.Name() == "Makefile.in" {
914+
if !d.IsDir() && d.Name() == "Makefile.in" {
915915
os.Chtimes(path, now, now)
916916
}
917917
return nil

lib/fetch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
"os"
1313
"path/filepath"
1414
"runtime"
15-
"sort"
15+
"slices"
1616
"strings"
1717
)
1818

@@ -161,7 +161,7 @@ func findViaAPI(prefix string) (string, error) {
161161
}
162162

163163
// Sort to find highest version (lib-8.0.0.0 < lib-8.0.0.1 < lib-8.0.0.3)
164-
sort.Strings(matchingReleases)
164+
slices.Sort(matchingReleases)
165165

166166
// Return the last (highest) version
167167
return matchingReleases[len(matchingReleases)-1], nil

0 commit comments

Comments
 (0)