February 2018
Intermediate to advanced
340 pages
9h 43m
English
The core concept of the functional options pattern is that the configuration API contains the functional parameters. In this case, the NewClient function accepts a various number of ConfigFunc arguments, which are then applied one by one on the defaultClient struct. This way, the default configuration is modified with huge flexibility.
See the FromFile and FromEnv functions, which return the ConfigFunc, that is in fact, accessing the file or environmental variables.
Finally, you can check the output which applied both the configuration options and resulting Client struct that contains the values from the file and environmental variables.
Read now
Unlock full access