if e.ptrLevel++; e.ptrLevel > startDetectingCyclesAfter {
// We're a large number of nested ptrEncoder.encode calls deep;
// start checking if we've run into a pointer cycle.
- ptr := v.Pointer()
+ ptr := v.UnsafePointer()
if _, ok := e.ptrSeen[ptr]; ok {
e.error(&UnsupportedValueError{v, fmt.Sprintf("encountered a cycle via %s", v.Type())})
}
// Here we use a struct to memorize the pointer to the first element of the slice
// and its length.
ptr := struct {
- ptr uintptr
+ ptr interface{} // always an unsafe.Pointer, but avoids a dependency on package unsafe
len int
- }{v.Pointer(), v.Len()}
+ }{v.UnsafePointer(), v.Len()}
if _, ok := e.ptrSeen[ptr]; ok {
e.error(&UnsupportedValueError{v, fmt.Sprintf("encountered a cycle via %s", v.Type())})
}