Code maintenance: OS user abstraction interface
This commit is contained in:
24
internal/os/user/user.go
Normal file
24
internal/os/user/user.go
Normal file
@@ -0,0 +1,24 @@
|
||||
package user
|
||||
|
||||
import osuser "os/user"
|
||||
|
||||
//go:generate mockgen -destination=mock_$GOPACKAGE/$GOFILE . OSUser
|
||||
|
||||
type OSUser interface {
|
||||
LookupID(uid string) (*osuser.User, error)
|
||||
Lookup(username string) (*osuser.User, error)
|
||||
}
|
||||
|
||||
func New() OSUser {
|
||||
return &osUser{}
|
||||
}
|
||||
|
||||
type osUser struct{}
|
||||
|
||||
func (u *osUser) LookupID(uid string) (*osuser.User, error) {
|
||||
return osuser.LookupId(uid)
|
||||
}
|
||||
|
||||
func (u *osUser) Lookup(username string) (*osuser.User, error) {
|
||||
return osuser.Lookup(username)
|
||||
}
|
||||
Reference in New Issue
Block a user