jackc/pgx · error
cannot scan into non-pointer or nil destinations %T
Error message
cannot scan into non-pointer or nil destinations %T
What it means
Error "cannot scan into non-pointer or nil destinations %T" thrown in jackc/pgx.
Source
Thrown at pgtype/pgtype.go:502
}
// TryWrapScanPlanFunc is a function that tries to create a wrapper plan for target. If successful it returns a plan
// that will convert the target passed to Scan and then call the next plan. nextTarget is target as it will be converted
// by plan. It must be used to find another suitable ScanPlan. When it is found SetNext must be called on plan for it
// to be usabled. ok indicates if a suitable wrapper was found.
type TryWrapScanPlanFunc func(target any) (plan WrappedScanPlanNextSetter, nextTarget any, ok bool)
type pointerPointerScanPlan struct {
dstType reflect.Type
next ScanPlan
}
func (plan *pointerPointerScanPlan) SetNext(next ScanPlan) { plan.next = next }
func (plan *pointerPointerScanPlan) Scan(src []byte, dst any) error {
dstValue := reflect.ValueOf(dst)
if dstValue.Kind() != reflect.Pointer || dstValue.IsNil() {
return fmt.Errorf("cannot scan into non-pointer or nil destinations %T", dst)
}
el := dstValue.Elem()
if src == nil {
el.Set(reflect.Zero(el.Type()))
return nil
}
el.Set(reflect.New(el.Type().Elem()))
return plan.next.Scan(src, el.Interface())
}
// TryPointerPointerScanPlan handles a pointer to a pointer by setting the target to nil for SQL NULL and allocating and
// scanning for non-NULL.
func TryPointerPointerScanPlan(target any) (plan WrappedScanPlanNextSetter, nextTarget any, ok bool) {
if dstType := reflect.TypeOf(target); dstType != nil && dstType.Kind() == reflect.Pointer {
elemType := dstType.Elem()
if elemType.Kind() == reflect.Pointer {View on GitHub (pinned to ec1a0befd2)
When it happens
Trigger: Thrown at pgtype/pgtype.go:502 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04).
Data as JSON: /data/errors/4d6d2a4c020ea061.json.
Report an issue: GitHub.