Skip to content

Commit 8e9ec60

Browse files
committed
Ignore group lookup errors, fixes #65
1 parent ba708eb commit 8e9ec60

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cmd/cmd.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,12 @@ func getDefaultData() (map[string]interface{}, error) {
113113
}
114114
data["username"] = currentUser.Username
115115

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

122123
homedir, err := homedir.Dir()
123124
if err != nil {

0 commit comments

Comments
 (0)