aboutsummaryrefslogtreecommitdiff
path: root/pkg/config/config.go
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-07-04 02:56:14 -0700
committerFuwn <[email protected]>2021-07-04 02:56:14 -0700
commit38ddbd97122ca71777c500df101f1274b3f11900 (patch)
tree9ff64f8446646413a4832fd666d94454ad01f603 /pkg/config/config.go
downloadmunch-38ddbd97122ca71777c500df101f1274b3f11900.tar.xz
munch-38ddbd97122ca71777c500df101f1274b3f11900.zip
feat(munch): :star:
Diffstat (limited to 'pkg/config/config.go')
-rw-r--r--pkg/config/config.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/pkg/config/config.go b/pkg/config/config.go
new file mode 100644
index 0000000..b3a3314
--- /dev/null
+++ b/pkg/config/config.go
@@ -0,0 +1,25 @@
+// Copyright (C) 2021-2021 The Whirlsplash Collective
+// SPDX-License-Identifier: GPL-3.0-only
+
+package config
+
+import (
+ "github.com/spf13/viper"
+ "log"
+)
+
+func Setup() {
+ viper.SetConfigName("config.yml")
+ viper.SetConfigType("yaml")
+ viper.AddConfigPath(".")
+
+ if err := viper.ReadInConfig(); err != nil {
+ if _, ok := err.(viper.ConfigFileNotFoundError); ok {
+ log.Panicln("Cannot read configuration file:", err)
+ } else {
+ log.Panicln("Read configuration file but an error occurred anyway:", err)
+ }
+ }
+
+ viper.WatchConfig()
+}