From bf4a0c8d4a470a78483752d67862a55b1e715bb7 Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Fri, 17 Dec 2021 16:42:55 +0100 Subject: [PATCH] automatically update config file permissions --- cmd/root.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index c139eea..8e49bb1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -84,7 +84,11 @@ func initConfig() { viper.AutomaticEnv() // read in environment variables that match // If a config file is found, read it in. - if err := viper.ReadInConfig(); err == nil && viper.GetBool("debug") { - fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed()) + if err := viper.ReadInConfig(); err == nil { + if viper.GetBool("debug") { + fmt.Fprintln(os.Stderr, "Using config file:", viper.ConfigFileUsed()) + } + // update Config file Permissions + os.Chmod(viper.ConfigFileUsed(), 0600) } }