August 2019
Beginner to intermediate
798 pages
17h 2m
English
YAML is another popular text-based format that is used for configuration files. In this subsection, you will learn how to read YAML configuration files with the viper package.
However, this time, the filename of the YAML configuration file will be given as a command-line argument to the utility. Additionally, the utility will use the viper.AddConfigPath() function to add three search paths, which are places where viper will automatically look for configuration files. The name of the utility, which will be presented in four parts, is readYAML.go.
The first part of readYAML.go is as follows:
package main
import (
"fmt"
flag "github.com/spf13/pflag"
"github.com/spf13/viper"
"os"
)
In the preamble of the program, ...
Read now
Unlock full access