combluotion/config/load.go

41 lines
645 B
Go
Raw Normal View History

2024-09-14 23:07:28 -05:00
package config
import "github.com/BurntSushi/toml"
type confToml struct {
Name string
Env Env
BaseURL string `toml:"base_url"`
Stores storeSettings `toml:"stores"`
}
type storeSettings struct {
Store string
Settings map[string]toml.Primitive
}
func LoadFromToml(path string) (Config, error) {
var c confToml
md, err := toml.DecodeFile(path, &c)
if err != nil {
return nil, err
}
conf := config{
name: c.Name,
env: c.Env,
baseURL: c.BaseURL,
md: md,
}
st := stores{
store: c.Stores.Store,
settings: c.Stores.Settings,
conf: &conf,
}
conf.stores = st
return conf, nil
2024-09-14 23:07:28 -05:00
}