Beispiel #1
0
func ParseFile(filename string) (*ConfStruct, error) {
	var err error
	var content []byte
	var raw map[interface{}]interface{}
	var cs *ConfStruct

	utils.BUG_ON(!filepath.IsAbs(filename), "filename is not abs path")

	content, err = ioutil.ReadFile(filename)
	if err != nil {
		goto e
	}

	err = goyaml.Unmarshal(content, &raw)
	if err != nil {
		goto e
	}

	cs, err = parseContent(raw)
	if err != nil {
		goto e
	}

	cs.Filename = filename
	return cs, nil

e:
	return nil, err
}
Beispiel #2
0
func parseChannels(raw []interface{}, name string) ([]ChannelConf, error) {
	ccs := make([]ChannelConf, 0, 5)
	for _, v := range raw {
		value := v.(map[interface{}]interface{})
		if name != "" && name != value["name"] {
			continue
		}
		cc, _ := parseOneChannel(value)
		ccs = append(ccs, cc)

	}

	utils.BUG_ON((name != "" && len(ccs) != 1), "name special channel parse not return 1 channel")

	return ccs, nil
}