You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
419 B

4 years ago
  1. package main
  2. import (
  3. "github.com/spf13/viper"
  4. )
  5. type Config struct {
  6. Currencies map[string]float64
  7. }
  8. var C Config
  9. func MustRead(configPath string) error {
  10. viper.SetConfigType("yaml")
  11. viper.SetConfigName("config")
  12. viper.AddConfigPath(".")
  13. viper.SetConfigFile(configPath)
  14. if err := viper.ReadInConfig(); err != nil {
  15. return err
  16. }
  17. err := viper.Unmarshal(&C)
  18. if err != nil {
  19. return err
  20. }
  21. return nil
  22. }