Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ready ¶
func Ready[T any, U **T](fieldAddr U)
Ready is a helper to prevent nil pointer dereferences when scanning values into sub-fields. The address of the field should be passed in.
func WithDefault ¶
WithDefault is a helper to set a default value, used when Scan methods attempt to scan NULL into a non-pointer field. This is particularly useful with proto3.
The returned value should be used as the argument to Scan.
Types ¶
type Slice ¶
Slice implements driver.Valuer and sql.Scanner for a slice of values that also implement driver.Valuer and sql.Scanner.
Due to the oddities of sql.Scanner usually being on the pointer receiver while driver.Valuer is usually on the value receiver, we need to check for the sql.Scanner implementation at runtime.
func NewSlice ¶
NewSlice creates a new Slice for addr, which should be a pointer to a slice whose member type implements driver.Valuer and sql.Scanner.
func (Slice[T, U]) Scan ¶
Scan scans an SQL array into the address that s wraps. Due to the oddities around sql.Scanner usually being implemented on the pointer receiver (and `rows.Scan` being passed the addresses of variables), Scan needs to check (*T) to ensure it implements sql.Scanner at runtime.