Skip to content

Commit f494c27

Browse files
committed
Add missing error checks
1 parent 815d102 commit f494c27

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

cmd/root.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"os"
66
"strings"
77

8+
log "github.com/sirupsen/logrus"
89
"github.com/spf13/cobra"
910
"github.com/spf13/viper"
1011
)
@@ -40,9 +41,18 @@ func init() {
4041
rootCmd.PersistentFlags().StringVar(&maxmindDBPath, "maxmind-db-path", "", "Path to the maxmind database file")
4142
rootCmd.PersistentFlags().StringVar(&logLevel, "log-level", "info", "How verbose the logs should be. panic, fatal, error, warn, info, debug, trace")
4243

43-
viper.BindPFlag("metrics-port", rootCmd.PersistentFlags().Lookup("metrics-port"))
44-
viper.BindPFlag("maxmind-db-path", rootCmd.PersistentFlags().Lookup("maxmind-db-path"))
45-
viper.BindPFlag("log-level", rootCmd.PersistentFlags().Lookup("log-level"))
44+
err := viper.BindPFlag("metrics-port", rootCmd.PersistentFlags().Lookup("metrics-port"))
45+
if err != nil {
46+
log.Fatalln(err.Error())
47+
}
48+
err = viper.BindPFlag("maxmind-db-path", rootCmd.PersistentFlags().Lookup("maxmind-db-path"))
49+
if err != nil {
50+
log.Fatalln(err.Error())
51+
}
52+
err = viper.BindPFlag("log-level", rootCmd.PersistentFlags().Lookup("log-level"))
53+
if err != nil {
54+
log.Fatalln(err.Error())
55+
}
4656
}
4757

4858
// initConfig reads in config file and ENV variables if set.

0 commit comments

Comments
 (0)