I'm a newbie with Golang. I want to write a program to manage my Redis instances so that I can create a Redis connection with specific config file. But I don't know how to create the config file for Redis instances elegantly.
I found "text/template" before, is that a good idea?
It depends on the file format you want to support for those configs.
One library able to read most of those format (from a simple ini file to a JSON one) would be spf13/viper:
Viper is a complete configuration solution for go applications. It has been designed to work within an application to handle all types of configuration. It supports
- setting defaults
- reading from yaml, toml and json config files
- reading from environment variables
- reading from remote config systems (Etcd or Consul)
- reading from command line flags
- setting explicit values
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With