mirror of
https://git.sr.ht/~phw/scotty
synced 2025-04-29 21:27:05 +02:00
Code cleanup and missing error checks
This commit is contained in:
parent
6eaef18188
commit
c4193f42a1
7 changed files with 23 additions and 19 deletions
|
@ -61,7 +61,8 @@ func InitConfig(cfgFile string) error {
|
|||
// Create global config if it does not exist
|
||||
if viper.ConfigFileUsed() == "" && cfgFile == "" {
|
||||
if err := os.MkdirAll(configDir, 0750); err == nil {
|
||||
viper.SafeWriteConfig()
|
||||
// This call is expected to return an error if the file already exists
|
||||
viper.SafeWriteConfig() //nolint:errcheck
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -82,7 +83,7 @@ func WriteConfig(removedKeys ...string) error {
|
|||
configMap := viper.AllSettings()
|
||||
for _, key := range removedKeys {
|
||||
c := configMap
|
||||
ok := true
|
||||
var ok bool
|
||||
subKeys := strings.Split(key, ".")
|
||||
keyLen := len(subKeys)
|
||||
// Deep search the key in the config and delete the deepest key, if it exists
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue