DEV Community

Read YAMLy config with a few lines of code

Dmitry Yakimenko on February 25, 2019

Originally posted on detunized.net I was working on a C# library and in a simple example application I needed to load a config file. It didn't h...
Collapse
 
victoravelar profile image
Victor Avelar

Steve Francia has the answer

spf13 / viper

Go configuration with fangs

viper logo

Go configuration with fangs!

Many Go projects are built using Viper including:

Build Status Join the chat at https://gitter.im/spf13/viper GoDoc

What is Viper?

Viper is a complete configuration solution for Go applications including 12-Factor apps. It is designed to work within an application, and can handle all types of configuration needs and formats. It supports:

  • setting defaults
  • reading from JSON, TOML, YAML, HCL, and Java properties config files
  • live watching and re-reading of config files (optional)
  • reading from environment variables
  • reading from remote config systems (etcd or Consul), and watching changes
  • reading from command line flags
  • reading from buffer
  • setting explicit values

Viper can be thought of as a registry for all of your applications configuration needs.

Why Viper?

When building a modern application, you don’t want to worry about configuration file formats; you want to focus on building awesome software Viper is here to…

Collapse
 
detunized profile image
Dmitry Yakimenko • Edited

This post is about the power of programming languages and not really about reading config files =) Thanks for the link, though