You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
logName(): lazily lookup userName instead of on init()
Commit c46b9e1 implemented
a workaround for situations on Windows where `user.Current()`
was not available.
On Linux/Unix ennvironments, `user.Current()` may be calling
(among others) `getgrnam_r` (https://linux.die.net/man/3/getgrgid_r),
which:
> Returns a pointer to a structure containing the broken-out fields of
> the record in the group database (e.g., the local group file /etc/group,
> NIS, and LDAP) that matches the group name name.
This means that the `init()` function might be making network connections,
which is not desirable.
This patch changes the lookup to be performed lazily. A `sync.Once` was
added so that lookup is only performed once (to keep the behavior that
was previously provided by using `init()`.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
0 commit comments