load.go 435 B

12345678910111213141516171819
  1. package initialize
  2. import (
  3. "AIT/global"
  4. "fmt"
  5. "github.com/spf13/viper"
  6. )
  7. func LoadConfig() {
  8. viper.AddConfigPath("./")
  9. viper.SetConfigName("config")
  10. viper.SetConfigType("yaml")
  11. if err := viper.ReadInConfig(); err != nil {
  12. fmt.Printf("Fatal error resource file: %s \n\n", err.Error())
  13. }
  14. if err := viper.Unmarshal(&global.Config); err != nil {
  15. fmt.Printf("Unable to decode into structure Config %s \n", err.Error())
  16. }
  17. }