Standard library / database/sql
sql.NullInt32.Scan()
Converts a driver value into the nullable wrapper. Nil marks it invalid; check the conversion error before using it. Expected stdout: 'true\nfalse\n'.
Formal Syntax & Structure
go syntaxgo
func (n *NullInt32) Scan(value any) errorParameters & Attributes
| Name | Type | Description |
|---|---|---|
| value | any | Value to convert or scan; nil represents SQL NULL. |
Return Value
error
Converts a driver value into the nullable wrapper. Check returned errors where applicable.
Working Example
Example Snippetgo
package main
import ( "database/sql" "fmt")
func must[T any](v T, e error) T { if e != nil { panic(e) } return v}func check(e error) { if e != nil { panic(e) }}func main() { var n sql.NullInt32 check(n.Scan(int64(7))) fmt.Println(n.Valid) check(n.Scan(nil)) fmt.Println(n.Valid)}