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
Go v1.3
I'm writing a program that imitates, ls, and when printing files in long mode and
converting uids to usernames with user.LookupID(uid), it requires a significant amount
of computational time to complete.
An example is that it takes 250 milliseconds to process all of the entries in /usr/bin
versus 50 milliseconds without. When doing the same for /, it takes 1600 usec to convert
and print user/groupnames versus 300 usec printing uid/gid's directly.
Code is attached; you can switch from printing ids to names by modifying the getUID and
getGID functions, which return 'return fmt.Sprintf("%d",
file.Sys().(*syscall.Stat_t).Uid)' to 'return idToName(fmt.Sprintf("%d",
file.Sys().(*syscall.Stat_t).Uid))
user.LookupID is calling into the C library to convert user IDs to user names. This is
because many of the details of that conversion are system dependent, such as the
possible use of LDAP. If you are running on GNU/Linux, look at /etc/nsswitch.conf.
It is unlikely that there is anything we can do in this area. If you have specific
suggestions, we'd be happy to hear them.
Would it be possible to have it check for such situations beforehand, and obtain those
names based off what is available? Such as parsing /etc/group and /etc/passwd directly
without using a C library if LDAP is not in use?
by mmstickman:
Attachments:
The text was updated successfully, but these errors were encountered: