load.go 605 B

1234567891011121314151617181920212223
  1. package initialize
  2. import (
  3. "confrontation-training/global"
  4. "fmt"
  5. "github.com/gohutool/log4go"
  6. "github.com/spf13/viper"
  7. )
  8. func LoadConfig() {
  9. viper.AddConfigPath("./config")
  10. viper.SetConfigName("application")
  11. viper.SetConfigType("yaml")
  12. if err := viper.ReadInConfig(); err != nil {
  13. fmt.Printf("Fatal error resource file: %s \n\n", err.Error())
  14. }
  15. if err := viper.Unmarshal(&global.Config); err != nil {
  16. fmt.Printf("Unable to decode into structure Config %s \n", err.Error())
  17. }
  18. global.Log4J = log4go.LoggerManager.GetLogger("ct")
  19. log4go.LoggerManager.InitWithXML("./config/log4j.xml")
  20. }