MCPcopy
hub / github.com/jmoiron/sqlx / structOnlyError

Function structOnlyError

sqlx.go:871–881  ·  view source on GitHub ↗

structOnlyError returns an error appropriate for type when a non-scannable struct is expected but something else is given

(t reflect.Type)

Source from the content-addressed store, hash-verified

869// structOnlyError returns an error appropriate for type when a non-scannable
870// struct is expected but something else is given
871func structOnlyError(t reflect.Type) error {
872 isStruct := t.Kind() == reflect.Struct
873 isScanner := reflect.PtrTo(t).Implements(_scannerInterface)
874 if !isStruct {
875 return fmt.Errorf("expected %s but got %s", reflect.Struct, t.Kind())
876 }
877 if isScanner {
878 return fmt.Errorf("structscan expects a struct dest but the provided struct type %s implements scanner", t.Name())
879 }
880 return fmt.Errorf("expected a struct, but struct %s has no exported fields", t.Name())
881}
882
883// scanAll scans all rows into a destination, which must be a slice of any
884// type. It resets the slice length to zero before appending each element to

Callers 2

scanAnyMethod · 0.85
scanAllFunction · 0.85

Calls 2

KindMethod · 0.80
ErrorfMethod · 0.80

Tested by

no test coverage detected