Add config defaults and run go fmt

This commit is contained in:
2021-08-24 08:54:08 -07:00
parent 91f7132d5e
commit 6e16aa7a7a
5 changed files with 55 additions and 25 deletions

21
main.go
View File

@@ -19,11 +19,8 @@
package main
import (
"os"
"strings"
"time"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"github.com/spf13/viper"
"go.arsenm.dev/infinitime"
@@ -31,24 +28,6 @@ import (
var firmwareUpdating = false
func init() {
// Set up logger
log.Logger = log.Output(zerolog.ConsoleWriter{Out: os.Stderr})
// Set config settings
viper.AddConfigPath("$HOME/.config")
viper.AddConfigPath("/etc")
viper.SetConfigName("itd")
viper.SetConfigType("toml")
viper.WatchConfig()
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.SetEnvPrefix("itd")
if err := viper.ReadInConfig(); err != nil {
log.Warn().Err(err).Msg("Could not read in config")
}
viper.AutomaticEnv()
}
func main() {
if viper.GetInt("cfg.version") != 2 {
log.Fatal().Msg("Please update your config to the newest format, only v2 configs supported.")