yans/internal/config/config.go

34 lines
588 B
Go
Raw Normal View History

2022-01-17 22:38:56 +00:00
package config
import (
"github.com/BurntSushi/toml"
"os"
)
2022-01-19 19:51:08 +00:00
const (
SQLiteBackendType = "sqlite"
)
2022-01-17 22:38:56 +00:00
type Config struct {
2022-01-19 19:51:08 +00:00
Address string `toml:"address"`
Port int `toml:"port"`
BackendType string `toml:"backend_type"`
SQLite SQLiteBackendConfig `toml:"sqlite"`
}
type SQLiteBackendConfig struct {
Path string `toml:"path"`
2022-01-17 22:38:56 +00:00
}
func ParseConfig(path string) (Config, error) {
cfg := Config{}
data, _ := os.ReadFile(path)
err := toml.Unmarshal(data, &cfg)
if err != nil {
return Config{}, err
}
return cfg, nil
}