Skip to content

larjudge/viper-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Viper-Config

Viper-Config is a really simple demo application that uses viper to parse both config files and command line flags

Running with flags:

go run main.go --spec.intConfig=1 --spec.stringConfig="hello world" --spec.boolConfig=true

Running with config file:

go run main.go --config "$PWD/config/local.yaml"

Running with both:

go run main.go --config "$PWD/config/local.yaml" --spec.stringConfig="yaml and flags"

We can also use short flags to avoid spec.foo

go run main.go --config "$PWD/config/local.yaml" -s="short flag"

Finally

If you pay close attention to the yaml file you can see that intConfig is commented out. This gives us the ability to not have to write full yaml files if we only want to change a couple of fields

About

Playing with Viper and overriding config

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages