DEV Community

Cover image for Configure Go Programs Using the Viper Package 🐍
Donald Feury
Donald Feury

Posted on • Updated on • Originally published at donaldfeury.xyz

Configure Go Programs Using the Viper Package 🐍

Shout out to my wife who makes these hilarious thumbnails, follow her on twitter and instagram for more art stuff.

You can get quite far configuring your go programs with the standard library. You can read in your config file, or pass in arguments and parse them with the flag package. However, what you wanted to do all these things interchangeably and with much more ease?

Enter viper, go configuration with fangs as they say! With viper, you can do ALL of the following:

  • setting default values for your configuration
  • read from popular config file formats, such as JSON, TOML, and YAML
  • watch your config file and live reload any changes
  • reading from environment variables
  • reading from remote config systems, such as etcd
  • reading from command line flags
  • reading from buffer
  • setting explicit values

Check out the video to see an example of some of things you can do with viper.

If you liked it and want to know when I post more, be sure to subscribe and thank ya'll again for your time!

Latest comments (0)