mirror of
https://github.com/ChronosX88/yans.git
synced 2024-11-08 14:50:59 +00:00
34 lines
588 B
Go
34 lines
588 B
Go
package config
|
|
|
|
import (
|
|
"github.com/BurntSushi/toml"
|
|
"os"
|
|
)
|
|
|
|
const (
|
|
SQLiteBackendType = "sqlite"
|
|
)
|
|
|
|
type Config struct {
|
|
Address string `toml:"address"`
|
|
Port int `toml:"port"`
|
|
BackendType string `toml:"backend_type"`
|
|
SQLite SQLiteBackendConfig `toml:"sqlite"`
|
|
}
|
|
|
|
type SQLiteBackendConfig struct {
|
|
Path string `toml:"path"`
|
|
}
|
|
|
|
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
|
|
}
|