yans/internal/config/config.go

24 lines
321 B
Go
Raw Normal View History

2022-01-17 22:38:56 +00:00
package config
import (
"github.com/BurntSushi/toml"
"os"
)
type Config struct {
Port int
DatabasePath string
}
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
}