Skip to content

Commit 0165130

Browse files
committed
modernize --fix
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent f453a3a commit 0165130

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

platforms.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -372,18 +372,19 @@ func FormatAll(platform specs.Platform) string {
372372
return "unknown"
373373
}
374374

375-
osOptions := encodeOSOption(platform.OSVersion)
375+
var b strings.Builder
376+
b.WriteString(encodeOSOption(platform.OSVersion))
376377
features := platform.OSFeatures
377378
if !slices.IsSorted(features) {
378379
features = slices.Clone(features)
379380
slices.Sort(features)
380381
}
381382
for _, f := range features {
382-
osOptions += "+" + encodeOSOption(f)
383+
b.WriteString("+" + encodeOSOption(f))
383384
}
384-
if osOptions != "" {
385-
OSAndVersion := fmt.Sprintf("%s(%s)", platform.OS, osOptions)
386-
return path.Join(OSAndVersion, platform.Architecture, platform.Variant)
385+
if b.Len() > 0 {
386+
osAndVersion := platform.OS + "(" + b.String() + ")"
387+
return path.Join(osAndVersion, platform.Architecture, platform.Variant)
387388
}
388389
return path.Join(platform.OS, platform.Architecture, platform.Variant)
389390
}

platforms_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ func BenchmarkParseOSOptions(b *testing.B) {
633633
b.ResetTimer()
634634
for _, bm := range benchmarks {
635635
b.Run(bm.doc, func(b *testing.B) {
636-
for i := 0; i < b.N; i++ {
636+
for range b.N {
637637
_, _ = Parse(bm.input)
638638
}
639639
})
@@ -668,7 +668,7 @@ func BenchmarkFormatAllOSFeatures(b *testing.B) {
668668
platform: specs.Platform{
669669
OS: "linux",
670670
OSFeatures: func() (out []string) {
671-
for i := 0; i <= maxFeatures; i++ {
671+
for range maxFeatures {
672672
out = append(out, "feature")
673673
}
674674
return out
@@ -725,7 +725,7 @@ func BenchmarkFormatAllOSFeatures(b *testing.B) {
725725
b.ResetTimer()
726726
for _, bm := range benchmarks {
727727
b.Run(bm.doc, func(b *testing.B) {
728-
for i := 0; i < b.N; i++ {
728+
for range b.N {
729729
_ = FormatAll(bm.platform)
730730
}
731731
})

0 commit comments

Comments
 (0)