September 2017
Intermediate to advanced
466 pages
9h 33m
English
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 -u 33 $ id -u root 0
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 the given username.
The first part of userID.go is the following:
package main import ( "fmt" "os" "os/user" ) func main() { arguments := os.Args if ...Read now
Unlock full access