Skip to content

Commit

Permalink
Merge pull request #72 from twpayne/ignore-group-lookup-errors
Browse files Browse the repository at this point in the history
Ignore group lookup errors, fixes #65
  • Loading branch information
twpayne authored Dec 14, 2018
2 parents ba708eb + 8e9ec60 commit bdecf50
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,12 @@ func getDefaultData() (map[string]interface{}, error) {
}
data["username"] = currentUser.Username

group, err := user.LookupGroupId(currentUser.Gid)
if err != nil {
return nil, err
// user.LookupGroupId reads /etc/group, which is not populated on some
// systems, causing lookup to fail. Instead of returning the error, simply
// ignore it and only set group if lookup succeeds.
if group, err := user.LookupGroupId(currentUser.Gid); err == nil {
data["group"] = group.Name
}
data["group"] = group.Name

homedir, err := homedir.Dir()
if err != nil {
Expand Down

0 comments on commit bdecf50

Please sign in to comment.