Documentation
¶
Overview ¶
Package scan provides functionality for scanning database/sql rows into slices, structs, and primitive types dynamically
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNotAPointer is returned when a non-pointer is received // when a pointer is expected. ErrNotAPointer = errors.New("not a pointer") // ErrNotAStructPointer is returned when a non-struct pointer // is received but a struct pointer was expected ErrNotAStructPointer = errors.New("not a struct pointer") // ErrNotASlicePointer is returned when receiving an argument // that is expected to be a slice pointer, but it is not ErrNotASlicePointer = errors.New("not a slice pointer") // ErrStructFieldMissing is returned when trying to scan a value // to a column which does not match a struct. This means that // the struct does not have a field that matches the column // specified. ErrStructFieldMissing = errors.New("struct field missing") // ColumnsMapper transforms struct/map field names // into the database column names. // E.g. you can set function for convert CamelCase into snake_case ColumnsMapper = func(name string) string { return name } )
View Source
var ( // ErrTooManyColumns indicates that a select query returned multiple columns and // attempted to bind to a slice of a primitive type. For example, trying to bind // `select col1, col2 from mutable` to []string ErrTooManyColumns = errors.New("too many columns returned for primitive slice") // ScannerMapper transforms database field names into struct/map field names // E.g. you can set function for convert snake_case into CamelCase ScannerMapper = func(name string) string { return toTitleCase(name) } )
Functions ¶
func Columns ¶
Columns scans a struct and returns a list of strings that represent the assumed column names based on the db struct tag, or the field name. Any field or struct tag that matches a string within the excluded list will be excluded from the result.
func ColumnsStrict ¶
ColumnsStrict is identical to Columns, but it only searches struct tags and excludes fields not tagged with the db struct tag.
func Nullable ¶ added in v0.0.2
Nullable wrap value as a nullable sql.Scanner. If value returned from database is nil, nullable scanner will set dest to zero value.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.