32 lines
552 B
Go
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
|
|
}
|