37 lines
500 B
Go
37 lines
500 B
Go
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
|
|
}
|