MCPcopy Create free account
hub / github.com/LockGit/gochat / Init

Function Init

config/config.go:57–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

55}
56
57func Init() {
58 once.Do(func() {
59 env := GetMode()
60 //realPath, _ := filepath.Abs("./")
61 realPath := getCurrentDir()
62 configFilePath := realPath + "/" + env + "/"
63 viper.SetConfigType("toml")
64 viper.SetConfigName("/connect")
65 viper.AddConfigPath(configFilePath)
66 err := viper.ReadInConfig()
67 if err != nil {
68 panic(err)
69 }
70 viper.SetConfigName("/common")
71 err = viper.MergeInConfig()
72 if err != nil {
73 panic(err)
74 }
75 viper.SetConfigName("/task")
76 err = viper.MergeInConfig()
77 if err != nil {
78 panic(err)
79 }
80 viper.SetConfigName("/logic")
81 err = viper.MergeInConfig()
82 if err != nil {
83 panic(err)
84 }
85 viper.SetConfigName("/api")
86 err = viper.MergeInConfig()
87 if err != nil {
88 panic(err)
89 }
90 viper.SetConfigName("/site")
91 err = viper.MergeInConfig()
92 if err != nil {
93 panic(err)
94 }
95 Conf = new(Config)
96 viper.Unmarshal(&Conf.Common)
97 viper.Unmarshal(&Conf.Connect)
98 viper.Unmarshal(&Conf.Task)
99 viper.Unmarshal(&Conf.Logic)
100 viper.Unmarshal(&Conf.Api)
101 viper.Unmarshal(&Conf.Site)
102 })
103}
104
105func GetMode() string {
106 env := os.Getenv("RUN_MODE")

Callers 1

initFunction · 0.85

Calls 2

GetModeFunction · 0.85
getCurrentDirFunction · 0.85

Tested by

no test coverage detected