summaryrefslogtreecommitdiff
path: root/config.go
diff options
context:
space:
mode:
authorxengineering <me@xengineering.eu>2024-05-01 13:58:54 +0200
committerxengineering <me@xengineering.eu>2024-05-01 13:58:54 +0200
commit1e2a3377e43786e25dc03b8612513d47f8dfb3c6 (patch)
treeb1dbe786260a9cd47e9a9af3549e95df27184179 /config.go
parent390642f9bbc12f0b435f343fc35f4a47c5ec7680 (diff)
downloadceres-1e2a3377e43786e25dc03b8612513d47f8dfb3c6.tar
ceres-1e2a3377e43786e25dc03b8612513d47f8dfb3c6.tar.zst
ceres-1e2a3377e43786e25dc03b8612513d47f8dfb3c6.zip
Add --config flag
This re-enables config file support.
Diffstat (limited to 'config.go')
-rw-r--r--config.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/config.go b/config.go
index f97f2a3..0527294 100644
--- a/config.go
+++ b/config.go
@@ -4,12 +4,14 @@ import (
_ "embed"
"encoding/json"
"log"
+ "os"
)
//go:embed default_config.json
var defaultConfig string
type CeresConfig struct {
+ Path string
HttpAddress string `json:"http_address"`
StorageFilePath string `json:"storage_file_path"`
}
@@ -22,3 +24,15 @@ func init() {
log.Fatal(err)
}
}
+
+func (c *CeresConfig) Read() {
+ data, err := os.ReadFile(c.Path)
+ if err != nil {
+ log.Fatal(err)
+ }
+
+ err = json.Unmarshal(data, &c)
+ if err != nil {
+ log.Fatal(err)
+ }
+}