From c28602eba84c8c5ecfd267187ff103bb5e9d2091 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Wed, 9 May 2018 19:25:24 -0700 Subject: viper config --- golang/cmd/fatcatd/main.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'golang/cmd/fatcatd/main.go') diff --git a/golang/cmd/fatcatd/main.go b/golang/cmd/fatcatd/main.go index c0668ed1..e98e0f79 100644 --- a/golang/cmd/fatcatd/main.go +++ b/golang/cmd/fatcatd/main.go @@ -7,6 +7,7 @@ import ( log "github.com/sirupsen/logrus" loads "github.com/go-openapi/loads" flags "github.com/jessevdk/go-flags" + "github.com/spf13/viper" "git.archive.org/bnewbold/fatcat/golang/restapi" "git.archive.org/bnewbold/fatcat/golang/restapi/operations" @@ -14,6 +15,18 @@ import ( func init() { + viper.SetEnvPrefix("FATCAT") + viper.AutomaticEnv() + viper.SetDefault("Port", 9411) + viper.SetDefault("Verbose", true) + + viper.SetConfigName("fatcatd.toml") + viper.AddConfigPath(".") + err := viper.ReadInConfig() + if err != nil { + log.Fatalf("Fatal error config file: %s \n", err) + } + // not default of stderr log.SetOutput(os.Stdout); -- cgit v1.2.3