scanner

package
v1.1.57-test Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 10 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
}

type SliceMapper added in v1.1.9

type SliceMapper struct {
	Delimiter string
}

SliceMapper splits a delimited string into a slice

func (*SliceMapper) Map added in v1.1.9

func (a *SliceMapper) Map(dest any, scannedValue any) (any, error)

Jump to

Keyboard shortcuts

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