9
"github.com/spf13/viper"
12
func getHomeDir() string {
13
usr, err := user.Current()
15
output.GetOutError("Error retrieving user data")
18
return usr.HomeDir + DirectionApp
21
func existOrCreateConfig(configPath string) {
22
err := viper.ReadInConfig()
24
file.CreateFile(configPath)
26
err = viper.ReadInConfig()
28
output.GetOutError("File creation error")
33
func setConfigVariable() {
34
viper.Set("NameFileConnects", NameFileConnects)
35
viper.Set("NameFileCryptKey", NameFileCryptKey)
36
viper.Set("FullPathConfig", getHomeDir())
37
viper.Set("Separator", Separator)
38
viper.Set("Space", Space)
40
err := viper.WriteConfig()
42
output.GetOutError("Error writing to configuration file")
49
viper.SetConfigName(NameFileConfig)
50
viper.SetConfigType(TypeFileConfig)
51
viper.AddConfigPath(getHomeDir())
53
err := viper.ReadInConfig()
55
configPath := getHomeDir() + FullNameFileConfig
56
existOrCreateConfig(configPath)