Skip to content

kelseyhightower/passwd

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

passwd

Build Status GoDoc

Drop in replacement for the os/user package. Useful when building without cgo and want to fallback to /etc/passwd.

Usage

package main

import (
	"fmt"
	"log"

	"github.com/kelseyhightower/passwd/user"
)

func main() {
	u, err := user.Current()
	if err != nil {
		log.Fatal(err)
	}
	u, err = user.Lookup("root")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s:%s:%s:%s:%s\n",
		u.Username, u.Uid, u.Gid, u.Name, u.HomeDir)
	u, err = user.LookupId("0")
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("%s:%s:%s:%s:%s\n",
		u.Username, u.Uid, u.Gid, u.Name, u.HomeDir)
}

About

Package passwd allows user account lookups by name or id from /etc/passwd

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages