- From your Terminal or console application,createa new directory called~/projects/go-programming-cookbook/chapter2/envvar.
- Navigate to this directory.
- Run the following command:
Environment variables are another way that you can pass state into an application beyond reading data in from a file or passing it explicitly over the command line. This recipe will explore some very basic getting and setting of environment variables and then work with the highly useful third-party library envconfig (https://github.com/kelseyhightower/envconfig).
We'll build an application that can read a config file via JSON or through environment variables. The next recipe will explore alternative formats, including TOML and YAML.
How to do it...
These steps cover writing and running your application:
$ go mod init github.com/PacktPublishing/Go-Programming-Cookbook...