MCPcopy Create free account
hub / github.com/codeedu/fc2-arquitetura-hexagonal / initConfig

Function initConfig

cmd/root.go:72–92  ·  view source on GitHub ↗

initConfig reads in config file and ENV variables if set.

()

Source from the content-addressed store, hash-verified

70
71// initConfig reads in config file and ENV variables if set.
72func initConfig() {
73 if cfgFile != "" {
74 // Use config file from the flag.
75 viper.SetConfigFile(cfgFile)
76 } else {
77 // Find home directory.
78 home, err := homedir.Dir()
79 cobra.CheckErr(err)
80
81 // Search config in home directory with name ".go-hexagonal" (without extension).
82 viper.AddConfigPath(home)
83 viper.SetConfigName(".go-hexagonal")
84 }
85
86 viper.AutomaticEnv() // read in environment variables that match
87
88 // If a config file is found, read it in.
89 if err := viper.ReadInConfig(); err == nil {
90 fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed())
91 }
92}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected