Skip to content
This repository has been archived by the owner on Dec 20, 2019. It is now read-only.
/ passwduser Public archive

A cgo-free implementation of Golang's os/user for Unix

License

Notifications You must be signed in to change notification settings

glestaris/passwduser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Godoc Go Report Card Build Status

A cgo-free implementation of os/user that parses /etc/passwd

Golang's os/user is a great package that provides an API to access information for the current user/group. However, the Unix implementation relies in cgo since it uses getpwuid [1] to obtain the user/group information. This library is avoiding that by parsing the /etc/passwd file instead.

NOTICE this may not be enough for your application. getpwuid does also use LDAP and NIS databases to obtain the user information. If your system uses one of these technologies, this implementation is not for you and you unfortunately have to use cgo.

Work in progress

This package is currently only implementing the following methods:

  • Current() (*User, error)
  • Lookup(username string) (*User, error)
  • LookupId(uid string) (*User, error)

It does not yet implement:

  • (*User) GroupIds() ([]string, error)
  • LookupGroup(name string) (*Group, error)
  • LookupGroupId(gid string) (*Group, error)

[1] https://linux.die.net/man/3/getpwuid

About

A cgo-free implementation of Golang's os/user for Unix

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published