aboutsummaryrefslogtreecommitdiff
path: root/src/conf/conf.go
diff options
context:
space:
mode:
authorAlexander Kavon <hawk@alexkavon.com>2023-11-13 23:30:18 -0500
committerAlexander Kavon <hawk@alexkavon.com>2023-11-13 23:30:18 -0500
commit699e1edf05207f906583659fb250269ad5ec1f36 (patch)
treee18c7137f3f710fc25045e68f63d0e7a1acd3930 /src/conf/conf.go
parentfa63d31876bb522d6bd3dd2322c6f55f5c667a9c (diff)
scaffolding
Diffstat (limited to 'src/conf/conf.go')
-rw-r--r--src/conf/conf.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/conf/conf.go b/src/conf/conf.go
new file mode 100644
index 0000000..d135fcb
--- /dev/null
+++ b/src/conf/conf.go
@@ -0,0 +1,35 @@
+package conf
+
+import (
+ "log"
+ "os"
+ "github.com/BurntSushi/toml"
+)
+
+type Conf struct {
+ DbAdapter string `toml:"DB_ADAPTER"`
+ DbUser string `toml:"DB_USER"`
+ DbPassword string `toml:"DB_PASS"`
+}
+
+func Load() *Conf {
+
+ filepath := os.Getenv("NEWSSTAND_CONFIG_PATH")
+ if filepath == "" {
+ workingdir, err := os.Getwd()
+ if err != nil {
+ log.Fatal(err)
+ }
+ filepath = workingdir + "/.newsstandrc.toml"
+ }
+ log.Printf("Config file path: %s", filepath)
+
+ var c Conf
+ _, err := toml.DecodeFile(filepath, &c)
+ if err != nil {
+ log.Fatalln(err)
+ }
+ log.Println(c.DbAdapter)
+
+ return &c
+}