-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Mastering Go – Third Edition - Third Edition
By :

The functionality that is added to this new version of the phone book utility is the following:
PHONEBOOK
list
command sorts the output based on the surname fieldAlthough we could have given the path of the CSV file as a command-line argument instead of the value of an environment variable, it would have complicated the code, especially if that argument was made optional. More advanced Go packages such as viper
, which is presented in Chapter 6, Telling a UNIX System What to Do, simplify the process of parsing command-line arguments with the use of command-line options such as -f
followed by a file path or --filepath
.
The current default value of CSVFILE
is set to my home directory on a macOS Big Sur machine—you should change that default value to fit your needs or use a proper value for the PHONEBOOK
environment variable.