Flags are specially-formatted strings that are passed into a program to control its behavior. Dealing with flags on your own might become very difficult if you want to support multiple flags. Thus, if you are developing UNIX system command-line utilities, you will find the flag package very interesting and useful.
The flag package makes no assumptions about the order of command-line arguments and options, and it prints helpful messages in case there was an error in the way the command-line utility was executed.
The biggest advantage of the flag package is that it is part of the standard Go library, which means that it has been extensively tested and debugged.
I will present two Go programs that use the flag package: a simple one and a more advanced one. The first one, named simpleFlag.go, will be offered in four parts. The simpleFlag.go program will recognize...