diff options
| author | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-03-03 11:05:58 +0100 |
|---|---|---|
| committer | Anhgelus Morhtuuzh <anhgelus@anhgelus.world> | 2025-03-03 11:05:58 +0100 |
| commit | 69ab8022bd8efff2cc5eec5f97af977642e297d8 (patch) | |
| tree | c21c93999bc57639a4b6947f751d273395668df8 /main.go | |
| parent | 9ea75094dec2e70c3a4304d54d3cd427cbc5ca51 (diff) | |
feat(config): supports toml config files
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -4,10 +4,12 @@ import ( "embed" "encoding/json" "flag" + "github.com/BurntSushi/toml" "github.com/anhgelus/golatt" "log/slog" "net/http" "os" + "strings" ) var ( @@ -49,8 +51,15 @@ func main() { if err != nil { panic(err) } + var cfg Config - err = json.Unmarshal(b, &cfg) + if strings.HasSuffix(configPath, ".json") { + err = json.Unmarshal(b, &cfg) + } else if strings.HasSuffix(configPath, ".toml") { + err = toml.Unmarshal(b, &cfg) + } else { + panic("config file must be .json or .toml") + } if err != nil { panic(err) } @@ -58,6 +67,7 @@ func main() { if err != nil { panic(err) } + var g *golatt.Golatt if dev { g = golatt.New(golatt.UsableEmbedFS("templates", templates), os.DirFS("public"), os.DirFS("dist")) |
