Skip to content

Instantly share code, notes, and snippets.

@mehmetcemyucel
Created April 29, 2022 09:14
Show Gist options
  • Select an option

  • Save mehmetcemyucel/9e5ba7a1a7324beaccb0015a42a5fd21 to your computer and use it in GitHub Desktop.

Select an option

Save mehmetcemyucel/9e5ba7a1a7324beaccb0015a42a5fd21 to your computer and use it in GitHub Desktop.
package config
import (
"fmt"
"github.com/spf13/viper"
)
var readFromLocalAppYml = func(v *viper.Viper) *viper.Viper {
fmt.Println("Reading application yml configuration")
v.SetConfigName(defaultConfigFileName)
v.SetTypeByDefaultValue(true)
v.SetConfigType(defaultConfigFileType)
v.AddConfigPath("./" + defaultConfigPath)
if err := v.ReadInConfig(); err != nil {
fmt.Printf("Viper read config has an error; %e\n", err)
}
return v
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment