scanner

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 30, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const MapperTagName = "mapper"

Variables

View Source
var ErrNoSuchField = errors.New("no such field")

Functions

This section is empty.

Types

type AutoConversionMapper

type AutoConversionMapper struct {
	// contains filtered or unexported fields
}

func (*AutoConversionMapper) Map

func (a *AutoConversionMapper) Map(destinationValue any, scannedValue any) (any, error)

type ConcreteMapper

type ConcreteMapper struct {
}

ConcreteMapper converts nil scanned values into the zero value for the corresponding type

func (ConcreteMapper) Map

func (s ConcreteMapper) Map(dest any, scannedValue any) (any, error)

type DbScanner

type DbScanner struct {
	MapperCollection *MapperCollection
}

func NewDbScanner

func NewDbScanner() *DbScanner

func (*DbScanner) ScanRowsIntoStructs

func (s *DbScanner) ScanRowsIntoStructs(rows *sql.Rows, spacer string, models ...any) (ScanResults, error)

type JsonMapper

type JsonMapper struct {
	// contains filtered or unexported fields
}

func (JsonMapper) Map

func (j JsonMapper) Map(destinationValue any, scannedValue any) (any, error)

type Mapper

type Mapper interface {
	Map(dest any, scannedValue any) (any, error)
}

type MapperCollection

type MapperCollection struct {
	// contains filtered or unexported fields
}

func NewMapperCollection

func NewMapperCollection() *MapperCollection

func (*MapperCollection) GetMapperByName

func (mc *MapperCollection) GetMapperByName(name string) Mapper

func (*MapperCollection) RegisterMapper

func (mc *MapperCollection) RegisterMapper(name string, m Mapper)

type ScanResults

type ScanResults [][]any

type ScanTarget

type ScanTarget[T any] struct {
	Model T
	// contains filtered or unexported fields
}

func CopyIntoNewScanTarget

func CopyIntoNewScanTarget[T any](model T) *ScanTarget[T]

func NewScanTarget

func NewScanTarget[T any](model T) *ScanTarget[T]

func (*ScanTarget[T]) AddAllFields

func (t *ScanTarget[T]) AddAllFields(defaultMapper Mapper)

func (*ScanTarget[T]) AddField

func (t *ScanTarget[T]) AddField(name string, defaultMapper Mapper)

func (*ScanTarget[T]) FieldHasBeenAdded

func (t *ScanTarget[T]) FieldHasBeenAdded(name string) bool

func (*ScanTarget[T]) GetFieldValue

func (t *ScanTarget[T]) GetFieldValue(fieldName string) any

func (*ScanTarget[T]) GetReflectedModel

func (t *ScanTarget[T]) GetReflectedModel() reflect.Value

func (*ScanTarget[T]) SetFieldValue

func (t *ScanTarget[T]) SetFieldValue(fieldName string, fieldValue any) error

type ScanTargetField

type ScanTargetField struct {
	Mapper
	// contains filtered or unexported fields
}

func (*ScanTargetField) Read

func (f *ScanTargetField) Read() any

func (*ScanTargetField) Scan

func (f *ScanTargetField) Scan(src any) error

type Scanner

type Scanner interface {
	Scan(src any) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL