Golang database/sql/#NullFloat64 type examples

package database/sql

NullFloat64 represents a float64 that may be null. NullFloat64 implements the Scanner interface so it can be used as a scan destination, similar to NullString.

Golang database/sql/#NullFloat64 type usage examples

Example 1:

 var nf sql.NullFloat64{Float64: 42.42, Valid: true}

Example 2:

 type TableWithNull struct {
 Id int64
 Str sql.NullString
 Int64 sql.NullInt64
 Float64 sql.NullFloat64
 Bool sql.NullBool
 Bytes []byte
 }

Reference :

http://golang.org/pkg/database/sql/#NullFloat64

Advertisement