Use the new maps.Keys and slices.Sorted

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2024-08-22 22:37:48 +02:00
parent 1f49b2c0c0
commit 8d000f4522
2 changed files with 4 additions and 5 deletions

View File

@ -6,7 +6,8 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"sort" "maps"
"slices"
"strings" "strings"
"github.com/containers/common/pkg/retry" "github.com/containers/common/pkg/retry"
@ -16,7 +17,6 @@ import (
"github.com/containers/image/v5/transports/alltransports" "github.com/containers/image/v5/transports/alltransports"
"github.com/containers/image/v5/types" "github.com/containers/image/v5/types"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"golang.org/x/exp/maps"
) )
// tagListOutput is the output format of (skopeo list-tags), primarily so that we can format it with a simple json.MarshalIndent. // tagListOutput is the output format of (skopeo list-tags), primarily so that we can format it with a simple json.MarshalIndent.
@ -38,8 +38,7 @@ var transportHandlers = map[string]func(ctx context.Context, sys *types.SystemCo
// supportedTransports returns all the supported transports // supportedTransports returns all the supported transports
func supportedTransports(joinStr string) string { func supportedTransports(joinStr string) string {
res := maps.Keys(transportHandlers) res := slices.Sorted(maps.Keys(transportHandlers))
sort.Strings(res)
return strings.Join(res, joinStr) return strings.Join(res, joinStr)
} }

2
go.mod
View File

@ -20,7 +20,6 @@ require (
github.com/spf13/cobra v1.9.1 github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.6 github.com/spf13/pflag v1.0.6
github.com/stretchr/testify v1.10.0 github.com/stretchr/testify v1.10.0
golang.org/x/exp v0.0.0-20250103183323-7d7fa50e5329
golang.org/x/term v0.30.0 golang.org/x/term v0.30.0
gopkg.in/yaml.v3 v3.0.1 gopkg.in/yaml.v3 v3.0.1
) )
@ -124,6 +123,7 @@ require (
go.opentelemetry.io/otel/metric v1.31.0 // indirect go.opentelemetry.io/otel/metric v1.31.0 // indirect
go.opentelemetry.io/otel/trace v1.31.0 // indirect go.opentelemetry.io/otel/trace v1.31.0 // indirect
golang.org/x/crypto v0.35.0 // indirect golang.org/x/crypto v0.35.0 // indirect
golang.org/x/exp v0.0.0-20250103183323-7d7fa50e5329 // indirect
golang.org/x/mod v0.22.0 // indirect golang.org/x/mod v0.22.0 // indirect
golang.org/x/net v0.36.0 // indirect golang.org/x/net v0.36.0 // indirect
golang.org/x/oauth2 v0.25.0 // indirect golang.org/x/oauth2 v0.25.0 // indirect