On unix systems, user.Lookup returns most passwd fields, but not shell:
|
u := &User{ |
|
Username: parts[0], |
|
Uid: parts[2], |
|
Gid: parts[3], |
|
Name: parts[4], |
|
HomeDir: parts[5], |
|
} |
It can be desired to look up a user's shell in some cases, and it should be a small non-intrusive change:
- Add a
Shell string field to user.User.
- For the Cgo case, read
pw_shell from the passwd struct
- For the non-Cgo case, read
parts[6]
- Leave the field blank on Windows systems
On unix systems,
user.Lookupreturns most passwd fields, but not shell:go/src/os/user/lookup_unix.go
Lines 162 to 168 in 20e9b7f
It can be desired to look up a user's shell in some cases, and it should be a small non-intrusive change:
Shell stringfield touser.User.pw_shellfrom the passwd structparts[6]