Configure Go Programs Using the Viper Package 🐍

Shout out to my wife who makes these hilarious thumbnails, follow her on Twitter 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 the things you can do with viper.

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


Did you find this information useful? If so, consider heading over to my donation page and drop me some support.

Want to ask a question or just chat? Contact me here