diff --git a/user/go.mod b/user/go.mod index ad6231c..c494b18 100644 --- a/user/go.mod +++ b/user/go.mod @@ -1,6 +1,6 @@ module github.com/moby/sys/user -go 1.18 +go 1.24 require golang.org/x/sys v0.1.0 diff --git a/user/idtools_unix_test.go b/user/idtools_unix_test.go index ef10085..c6cc5ca 100644 --- a/user/idtools_unix_test.go +++ b/user/idtools_unix_test.go @@ -5,6 +5,7 @@ package user import ( "errors" "fmt" + "maps" "os" "path/filepath" "testing" @@ -292,9 +293,7 @@ func readTree(base, root string) (map[string]node, error) { if err != nil { return nil, err } - for path, nodeinfo := range subtree { - tree[path] = nodeinfo - } + maps.Copy(tree, subtree) } } return tree, nil diff --git a/user/user.go b/user/user.go index e747767..48c34a8 100644 --- a/user/user.go +++ b/user/user.go @@ -7,6 +7,7 @@ import ( "fmt" "io" "os" + "slices" "strconv" "strings" ) @@ -352,12 +353,7 @@ func GetExecUser(userSpec string, defaults *ExecUser, passwd, group io.Reader) ( // If the group argument isn't explicit, we'll just search for it. if groupArg == nil { // Check if user is a member of this group. - for _, u := range g.List { - if u == matchedUserName { - return true - } - } - return false + return slices.Contains(g.List, matchedUserName) } return groupArg.matches(g) })