Skip to content

Commit 254258c

Browse files
committed
refactor(builder): use slices.Contains for platform check in ShouldBuild
Replace manual loop with stdlib slices.Contains for clearer intent.
1 parent a91a09a commit 254258c

1 file changed

Lines changed: 2 additions & 7 deletions

File tree

internal/builder/library.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os/exec"
99
"path/filepath"
1010
"runtime"
11+
"slices"
1112
"strings"
1213
)
1314

@@ -43,13 +44,7 @@ func (lib *Library) ShouldBuild() bool {
4344
if len(lib.Platform) == 0 {
4445
return true // no platform restriction = build everywhere
4546
}
46-
currentOS := runtime.GOOS
47-
for _, platform := range lib.Platform {
48-
if platform == currentOS {
49-
return true
50-
}
51-
}
52-
return false
47+
return slices.Contains(lib.Platform, runtime.GOOS)
5348
}
5449

5550
// ArchiveType derives the archive type from the URL

0 commit comments

Comments
 (0)