go1.23: use std maps package

With go 1.23 the maps package was added in the std library. The linter
now wants us to use that. However the API chnaged as it returns an
iterator, thus we also have to use slices.Collect().

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
This commit is contained in:
Paul Holzinger 2025-03-11 17:06:23 +01:00
parent b23249635d
commit 56e62948f7
No known key found for this signature in database
GPG Key ID: EB145DD938A3CAF2
2 changed files with 5 additions and 5 deletions

2
go.mod
View File

@ -72,7 +72,6 @@ require (
github.com/vishvananda/netlink v1.3.1-0.20250221194427-0af32151e72b
go.etcd.io/bbolt v1.3.11
golang.org/x/crypto v0.36.0
golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c
golang.org/x/net v0.35.0
golang.org/x/sync v0.12.0
golang.org/x/sys v0.31.0
@ -221,6 +220,7 @@ require (
go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect
golang.org/x/arch v0.8.0 // indirect
golang.org/x/exp v0.0.0-20250128182459-e0ece0dbea4c // indirect
golang.org/x/mod v0.22.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect
golang.org/x/time v0.9.0 // indirect

View File

@ -2,10 +2,10 @@ package trust
import (
"fmt"
"maps"
"slices"
"sort"
"strings"
"golang.org/x/exp/maps"
)
// Policy describes a basic trust policy configuration
@ -53,7 +53,7 @@ func getPolicyShowOutput(policyContentStruct policyContent, systemRegistriesDirP
}
output = append(output, descriptionsOfPolicyRequirements(policyContentStruct.Default, template, registryConfigs, "", idReader)...)
}
transports := maps.Keys(policyContentStruct.Transports)
transports := slices.Collect(maps.Keys(policyContentStruct.Transports))
sort.Strings(transports)
for _, transport := range transports {
transval := policyContentStruct.Transports[transport]
@ -61,7 +61,7 @@ func getPolicyShowOutput(policyContentStruct policyContent, systemRegistriesDirP
transport = "repository"
}
scopes := maps.Keys(transval)
scopes := slices.Collect(maps.Keys(transval))
sort.Strings(scopes)
for _, repo := range scopes {
repoval := transval[repo]