From 0fa3b1f43f1202ad8a735ace537bc591e03da669 Mon Sep 17 00:00:00 2001 From: rouggy Date: Fri, 30 Aug 2024 12:36:37 +0700 Subject: [PATCH] update --- config.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 config.go diff --git a/config.go b/config.go new file mode 100644 index 0000000..db9739d --- /dev/null +++ b/config.go @@ -0,0 +1,27 @@ +package main + +import ( + "log" + "os" + "path/filepath" + + "github.com/BurntSushi/toml" +) + +type Config struct { + Host string `toml:"host"` + TMDBApiKey string `toml:"tmdbApiKey"` + DBName string `toml:"dbName"` + UploadFolder string `toml:"uploadFolder"` +} + +func NewConfig(path string) Config { + var c Config + f := filepath.Join(path, "config.toml") + _, err := toml.DecodeFile(f, &c) + if err != nil { + log.Println("Could not read the config file", err) + os.Exit(1) + } + return c +}