slimming/config.go

37 lines
500 B
Go
Raw Normal View History

2022-08-25 07:31:51 +00:00
package main
import (
"log"
"os"
"gopkg.in/yaml.v3"
)
type Node struct {
Real string `yaml:"real"`
Virt string `yaml:"virt"`
}
type Config struct {
Network struct {
Self Node `yaml:"self"`
Nodes []Node `yaml:"nodes"`
} `yaml:"network"`
}
var config = NewConfig()
func NewConfig() *Config {
cnf := &Config{}
f, err := os.Open("config.yaml")
if err != nil {
log.Panic(err)
}
dec := yaml.NewDecoder(f)
err = dec.Decode(cnf)
if err != nil {
log.Panic(err)
}
return cnf
}