package grconfig import ( "fmt" "log" "lot.gaore.com/library/common" "testing" ) type Config struct { ServerUrl string `yaml:"server_url"` AccessKey string `yaml:"access_key"` SecretKey string `yaml:"secret_key"` InstanceId string `yaml:"instance_id"` } func TestNewConfig(t *testing.T) { var m1 Config var m2 Config c := New(common.GetCwd("conf")) err := c.Item("mqtt.default", &m1) log.Println(fmt.Sprintf("%+v", m1.ServerUrl)) if err != nil { t.Error(err) } err = c.Item("mqtt.backup", &m2) log.Println(fmt.Sprintf("%+v", m2.ServerUrl)) if err != nil { t.Error(err) } if c.String("mqtt.default.instance_id") == "" { t.Error("Empty String") } log.Println(c.String("mqtt.default.instance_id")) }