MCPcopy Create free account
hub / github.com/devfullcycle/goexpert / LoadConfig

Function LoadConfig

9-APIs/configs/config.go:21–38  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

19}
20
21func LoadConfig(path string) (*conf, error) {
22 var cfg *conf
23 viper.SetConfigName("app_config")
24 viper.SetConfigType("env")
25 viper.AddConfigPath(path)
26 viper.SetConfigFile(".env")
27 viper.AutomaticEnv()
28 err := viper.ReadInConfig()
29 if err != nil {
30 panic(err)
31 }
32 err = viper.Unmarshal(&cfg)
33 if err != nil {
34 panic(err)
35 }
36 cfg.TokenAuth = jwtauth.New("HS256", []byte(cfg.JWTSecret), nil)
37 return cfg, err
38}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected