envordef is a Go module that tries to read a value from environment. If the environment variable in question is found, its value is returned in the type requested. If not, a default value, passed as the second argument, is returned.
go get gitlab.com/rbrt-weiler/go-module-envordef
(or update using the -u
flag) the module and start coding.
The module is fully commented, so documentation is available on GoDoc.
The original project is hosted at GitLab, with a copy over at GitHub for the folks over there.