libct/seccomp: use maps and slices pkgs

Since we have now switched to Go 1.23, we can use maps and slices pkgs

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
Kir Kolyshkin
2025-03-21 15:50:43 -07:00
parent 370733b7d9
commit bc96bc8558
+5 -19
View File
@@ -2,7 +2,8 @@ package seccomp
import (
"fmt"
"sort"
"maps"
"slices"
"github.com/opencontainers/runc/libcontainer/configs"
"github.com/opencontainers/runtime-spec/specs-go"
@@ -25,12 +26,7 @@ var operators = map[string]configs.Operator{
// KnownOperators returns the list of the known operations.
// Used by `runc features`.
func KnownOperators() []string {
var res []string
for k := range operators {
res = append(res, k)
}
sort.Strings(res)
return res
return slices.Sorted(maps.Keys(operators))
}
var actions = map[string]configs.Action{
@@ -48,12 +44,7 @@ var actions = map[string]configs.Action{
// KnownActions returns the list of the known actions.
// Used by `runc features`.
func KnownActions() []string {
var res []string
for k := range actions {
res = append(res, k)
}
sort.Strings(res)
return res
return slices.Sorted(maps.Keys(actions))
}
var archs = map[string]string{
@@ -79,12 +70,7 @@ var archs = map[string]string{
// KnownArchs returns the list of the known archs.
// Used by `runc features`.
func KnownArchs() []string {
var res []string
for k := range archs {
res = append(res, k)
}
sort.Strings(res)
return res
return slices.Sorted(maps.Keys(archs))
}
// ConvertStringToOperator converts a string into a Seccomp comparison operator.