File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,13 +2,15 @@ package user
22
33import (
44 "errors"
5- "fmt"
65 "syscall"
76)
87
98var (
109 // The current operating system does not provide the required data for user lookups.
1110 ErrUnsupported = errors .New ("user lookup: operating system does not provide passwd-formatted data" )
11+ // No matching entries found in file.
12+ ErrNoPasswdEntries = errors .New ("no matching entries in passwd file" )
13+ ErrNoGroupEntries = errors .New ("no matching entries in group file" )
1214)
1315
1416func lookupUser (filter func (u User ) bool ) (User , error ) {
@@ -27,7 +29,7 @@ func lookupUser(filter func(u User) bool) (User, error) {
2729
2830 // No user entries found.
2931 if len (users ) == 0 {
30- return User {}, fmt . Errorf ( "no matching entries in passwd file" )
32+ return User {}, ErrNoPasswdEntries
3133 }
3234
3335 // Assume the first entry is the "correct" one.
@@ -75,7 +77,7 @@ func lookupGroup(filter func(g Group) bool) (Group, error) {
7577
7678 // No user entries found.
7779 if len (groups ) == 0 {
78- return Group {}, fmt . Errorf ( "no matching entries in group file" )
80+ return Group {}, ErrNoGroupEntries
7981 }
8082
8183 // Assume the first entry is the "correct" one.
You can’t perform that action at this time.
0 commit comments