You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
407 B
28 lines
407 B
package config
|
|
|
|
import (
|
|
"gopkg.in/yaml.v2"
|
|
"os"
|
|
)
|
|
|
|
var root Config
|
|
|
|
type Config struct {
|
|
Database Database `yaml:"database"`
|
|
Users Users `yaml:"users"`
|
|
Server Server `yaml:"server"`
|
|
}
|
|
|
|
func Get() Config {
|
|
return root
|
|
}
|
|
|
|
func Load(path string) (Config, error) {
|
|
f, err := os.Open(path)
|
|
if err != nil {
|
|
return Config{}, err
|
|
}
|
|
|
|
err = yaml.NewDecoder(f).Decode(&root)
|
|
return root, err
|
|
}
|