Example:
type NamedInt int64
func (i *NamedInt) Scan(src interface{}) error {
v := reflect.ValueOf(src)
if v.Kind() != reflect.Int64 {
return errors.New("Cannot scan NamedInt from " + v.String())
}
*i = NamedInt(v.Int())
return nil
}
The model:
type Model struct {
NamedInt NamedInt `sql:"type:bigint"`
}
Currently, the NamedInt field causes gorm to panic. This change allows it to work as expected.