Loading values from the environment into variables is a way to configure processes at startup. Alternatives are to define a command-line interface or parsing configuration files.
Each of these methods has its advantage but loading values from the environment has a shortcoming. As an operator you have to refer to the documentation of the tool as there is no interface to query what the process expects.
This is possible when using a command line interface as libraries have implemented a default -h/--help flag that will print what is expected. It is also possible to use a format for configuration files that supports comments to document the values supported.
I have adapted the flag package for this purpose and it is available here. I would like to thank the Go authors for the flag package’s design. It was fairly easy to adapt it and all the errors you may find are my own.
This is a minimal example to see how the package can be used to load values from the environment in program variables and get a description of the variables the program expects.