Skip to content

Commit

Permalink
reset configfile
Browse files Browse the repository at this point in the history
  • Loading branch information
leonz789 committed Sep 9, 2024
1 parent 7169414 commit 1c6c519
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 26 deletions.
23 changes: 0 additions & 23 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,6 @@ func init() {

// initConfig reads in config file and ENV variables if set.
func initConfig() {
// v := viper.New()
// if cfgFile != "" {
// // Use config file from the flag.
// v.SetConfigFile(cfgFile)
// } else {
// // Find home directory.
// home, err := os.UserHomeDir()
// cobra.CheckErr(err)
//
// cfgFile = path.Join(home, ".price-feeder")
// // Search config in home directory with name ".price-feeder" (without extension).
// // v.AddConfigPath(home)
// // v.SetConfigType("yaml")
// // v.SetConfigName(".price-feeder")
// }
if len(cfgFile) == 0 {
// Find home directory.
home, err := os.UserHomeDir()
Expand All @@ -85,12 +70,4 @@ func initConfig() {

types.ConfigFile = cfgFile
conf = types.InitConfig(cfgFile)

// // If a config file is found, read it in.
//
// if err := v.ReadInConfig(); err == nil {
// fmt.Fprintln(os.Stderr, "Using config file:", v.ConfigFileUsed())
// }
//
// v.Unmarshal(&conf)
}
5 changes: 2 additions & 3 deletions types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ var (
func InitConfig(cfgFile string) Config {
if v == nil {
v = viper.New()
v.SetConfigFile(cfgFile)
v.SetConfigType("yaml")
}

v.SetConfigFile(cfgFile)
v.SetConfigType("yaml")
// If a config file is found, read it in.
if err := v.ReadInConfig(); err == nil {
fmt.Fprintln(os.Stderr, "Using config file:", v.ConfigFileUsed())
Expand Down

0 comments on commit 1c6c519

Please sign in to comment.