The way I did this was to find the number of bytes to read (size guint32 * oid_len), then made a binary .Read () by the number of bytes, and then looped through the bytes in chunks of size, Easy in retrospect; the hard part got type conversions that worked like Go, more stringent than C.
, Go guint32 * Go ( OID SNMP):
func gIntArrayOidString(oid *_Ctype_guint32, oid_len _Ctype_gsize) (result string) {
size := int(unsafe.Sizeof(*oid))
length := int(oid_len)
gbytes := C.GoBytes(unsafe.Pointer(oid), (_Ctype_int)(size*length))
buf := bytes.NewBuffer(gbytes)
for i := 0; i < length; i++ {
var out uint32
if err := binary.Read(buf, binary.LittleEndian, &out); err == nil {
result += fmt.Sprintf(".%d", out)
} else {
return "<error converting oid>"
}
}
if len(result) > 1 {
return result[1:]
}
return "<error converting oid>"
}
?
: gsnmpgo.