conf.go 349 B

1234567891011121314151617181920212223
  1. package cnf
  2. /**
  3. DEPRECATED:
  4. Read config file from dist. use viper which support many types of configure files.
  5. */
  6. import (
  7. "github.com/spf13/viper"
  8. )
  9. func Load(file string) error {
  10. v := viper.New();
  11. v.AddConfigPath(".")
  12. v.SetConfigType("json")
  13. v.SetConfigFile(file)
  14. err := v.ReadInConfig()
  15. if err != nil {
  16. return err
  17. }
  18. return nil
  19. }