health-go/config/readConfig.go

32 lines
552 B
Go
Raw Normal View History

2024-10-17 23:52:10 +08:00
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
}