I'm new in go, and trying just read data from MySQL. Schema: "id: INT(11), head: TEXT, filter: BIT(64)"
I tried to do this in common way:
type News struct {
Id int `field:"id"`
Head string `field:"head"`
Filter uint64 `field:"filter"`
}
...
rows.Scan(&item.Id, &item.Head, &item.Filter)
and got:
Scan error on column index 2, name "filter": converting NULL to uint64 is unsupported
I tried some example with reflection, but without result.
I tried make own type like here (really don't understand this):
type BitMask uint64
func (bits *BitMask) Scan(src interface{}) error {
str, ok := src.(string)
if !ok {
return fmt.Errorf("Unexpected type for BitMask: %T\n", src)
}
fmt.Println(str)
//var v uint64 = 0
//*bits = v // <- Also have error here
return nil
}
And got similar error: "Unexpected type for BitMask: < nil>"