Searching files revisited
This section will teach you how to find files using criteria such as user ID, group ID, and file permissions. Although this section could have been included in Chapter 5, Files and Directories, I decided to put it here, because there are times when you will want to use this kind of information in order to inform a system administrator that there is something wrong with the system.
Finding the user ID of a user
This subsection will present a program that shows the user ID of a user, given their username, which is more or less the output of the id -u
utility:
$ id -u33$ id -u root0
The fact that there exists a Go package named user
, which can be found under the os
package that can help you implement the desired task, should not come as surprise to you. The name of the program will be userID.go
, and it will be presented in two parts. If you give no command-line arguments to userID.go
, it will print the user ID of the current user; otherwise, it will print the user ID of...