Code maintenance: OS user abstraction interface

This commit is contained in:
Quentin McGaw
2020-12-29 01:16:53 +00:00
parent da4e410bb7
commit f55fb4055f
6 changed files with 108 additions and 14 deletions

24
internal/os/user/user.go Normal file
View 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)
}