Golang database/sql.NullBool.Scan function example

package database/sql

Scan implements the Scanner interface.

Golang database/sql.NullBool.Scan function usage example

 func TestBoolScan(t *testing.T) {
 var b Bool
 err := b.Scan(true) // <-- here
 maybePanic(err)
 assertBool(t, b, "scanned bool")
 var null Bool
 err = null.Scan(nil)
 maybePanic(err)
 assertNullBool(t, null, "scanned null")
 }

References :

https://github.com/guregu/null/blob/master/bool_test.go

http://golang.org/pkg/database/sql/#NullBool.Scan

Advertisement