master: ["10.10.11.8", "10.10.11.9", "10.10.11.0"]
data: ["10.10.11.6", "10.10.11.5", "10.10.11.6"]
kibana: ["10.10.11.10"]
pass: "root"
user: "root"
package main
import (
"fmt"
"io/ioutil"
"gopkg.in/yaml.v3"
)
func main() {
fmt.Println("start")
c, err := readYaml("./tets.yml")
if err != nil {
panic(err.Error())
}
fmt.Println(c.data, c.kibana, c.data, c.pass, c.user)
}
type ClusterEnv struct {
master []string `yaml:"master,flow"`
data []string `yaml:"data,flow"`
kibana []string `yaml:"kibana,flow"`
user string `yaml:"user"`
pass string `yaml:"pass"`
}
func readYaml(filename string) (*ClusterEnv, error) {
buf, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
c := &ClusterEnv{}
err = yaml.Unmarshal(buf, c)
if err != nil {
return nil, fmt.Errorf("in file %q: %v", filename, err)
}
fmt.Println(c.data, c.kibana, c.data, c.pass, c.user)
return c, nil
}
start
[] [] []
[] [] []
package main
import (
"fmt"
"io/ioutil"
"gopkg.in/yaml.v3"
)
func main() {
fmt.Println("start")
c, err := readYaml("./tets.yml")
if err != nil {
panic(err.Error())
}
fmt.Println(c.Master, c.Kibana, c.Data, c.Pass, c.User)
}
type ClusterEnv struct {
Master []string `yaml:"master,flow"`
Data []string `yaml:"data,flow"`
Kibana []string `yaml:"kibana,flow"`
User string `yaml:"user"`
Pass string `yaml:"pass"`
}
func readYaml(filename string) (*ClusterEnv, error) {
buf, err := ioutil.ReadFile(filename)
if err != nil {
return nil, err
}
c := &ClusterEnv{}
err = yaml.Unmarshal(buf, c)
if err != nil {
return nil, fmt.Errorf("in file %q: %v", filename, err)
}
return c, nil
}