GoRacerr/config.go
2024-08-30 12:36:37 +07:00

28 lines
491 B
Go

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
}