The viper package
Flags are specially formatted strings that are passed into a program to control its behavior. Dealing with flags on your own might become very frustrating if you want to support multiple flags and options. Go offers the flag
package for working with command-line options, parameters, and flags. Although flag
can do many things, it is not as capable as other external Go packages. Thus, if you are developing simple UNIX system command-line utilities, you might find the flag
package very interesting and useful. But you are not reading this book to create simple command-line utilities! Therefore, I'll skip the flag
package and introduce you to an external package named viper
, which is a powerful Go package that supports a plethora of options. viper
uses the pflag
package instead of flag
, which is also illustrated in the code we will look at in the following sections.
All viper
projects follow a pattern. First, you initialize viper
and then you define the elements...