...

/

The viper Package: Reading JSON Configuration Files

The viper Package: Reading JSON Configuration Files

Let’s learn how to read JSON configuration files using the viper package.

We'll cover the following...

The viper package can read JSON files to get its configuration, and this lesson illustrates how. Using text files for storing configuration details can be very helpful when writing complex applications that require lots of data and setup. This is illustrated in jsonViper.go.

Once again, we need to put jsonViper.go inside ~/go/src/github.com/Educative-content/jsonViper—please adjust that command to fit your own GitHub username, although if you do not create a GitHub repository, you can use Educative-content.

Coding example

The code of jsonViper.go is as follows:

Access this course and 1400+ top-rated courses and projects.