Simple unix account parser for go.
Go to file
2023-08-13 21:32:29 -05:00
test Initial commit 2023-08-13 21:32:29 -05:00
go.mod Initial commit 2023-08-13 21:32:29 -05:00
License.txt Initial commit 2023-08-13 21:32:29 -05:00
README.md Initial commit 2023-08-13 21:32:29 -05:00
unixAccounts_test.go Initial commit 2023-08-13 21:32:29 -05:00
unixAccounts.go Initial commit 2023-08-13 21:32:29 -05:00

go-unixaccounts

A simple UNIX account information parser of /etc/passwd and /etc/group for GoLang.

Install

go get github.com/grmrgecko/go-unixaccounts

Example

import (
    "fmt"
    UNIXAccounts "github.com/grmrgecko/go-unixaccounts"
)

func main() {
    accounts := UNIXAccounts.NewUNIXAccounts()

    user := accounts.UserWithName("root")
    groups := accounts.UserMemberOf(user)

    var groupNames []string
    for _, group := range groups {
        groupNames = append(groupNames, group.Name)
    }

    fmt.Println("Found groups root is a member of:", groupNames)
}