Exemple #1
0
// lookup maps oids in their symbolic format into numeric format.
func lookup(oids ...string) []asn1.ObjectIdentifier {
	list := make([]asn1.ObjectIdentifier, 0, len(oids))
	for _, o := range oids {
		oid, err := mib.Lookup(o)
		if err != nil {
			panic(err)
		}
		list = append(list, oid)
	}
	return list
}
Exemple #2
0
// fromPairs creates bindings from the (name, value) pairs.
func fromPairs(nameval []interface{}) ([]binding, error) {
	var bindings []binding
	for i := 0; i < len(nameval); i += 2 {
		s, ok := nameval[i].(string)
		if !ok {
			panic("pair name not a string")
		}
		oid, err := mib.Lookup(s)
		if err != nil {
			return nil, err
		}
		bindings = append(bindings, binding{Name: oid})
	}
	return bindings, nil
}