health-go/config/readConfig.go
2024-10-20 16:31:37 +08:00

32 lines
552 B
Go

package config
import "github.com/BurntSushi/toml"
type Config struct {
Server ServerConfig `toml:"server"`
DB DBConfig `toml:"db"`
}
type ServerConfig struct {
Port int `toml:"port"`
}
type DBConfig struct {
Host string `toml:"host"`
Port int `toml:"port"`
Database string `toml:"database"`
User string `toml:"user"`
Passwd string `toml:"passwd"`
}
var Conf *Config
func ReadConfig(path string) error {
var c Config
if _, err := toml.DecodeFile(path, &c); err != nil {
return err
}
Conf = &c
return nil
}