How it works…
For the flag definition in code, the flag package defines two types of functions.
The first type is the simple name of the flag type such as Int. This function will return the pointer to the integer variable where the value of the parsed flag is.
The XXXVar functions are the second type. These provide the same functionality, but you need to provide the pointer to the variable. The parsed flag value will be stored in the given variable.
The Go library also supports a custom flag type. The custom type must implement the Value interface from the flag package.
As an example, let's say the flag retry defines the retry limit for reconnecting to the endpoint, the prefix flag defines the prefix of each row in a log, and the array is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access