diff --git a/bool.go b/bool.go index bf239ec..86950a1 100644 --- a/bool.go +++ b/bool.go @@ -4,6 +4,7 @@ import ( "database/sql" "encoding/json" "errors" + // "fmt" ) // Bool is an even nuller nullable bool. @@ -52,6 +53,8 @@ func (b *Bool) UnmarshalJSON(data []byte) error { case nil: b.Valid = false return nil + // default: + // err = fmt.Errorf("json: cannot unmarshal %v into Go value of type null.Bool", v.(type).Name()) } b.Valid = err == nil return err diff --git a/gin-bin b/gin-bin new file mode 100644 index 0000000..0ef32d9 Binary files /dev/null and b/gin-bin differ diff --git a/int.go b/int.go index 81e39ad..692801b 100644 --- a/int.go +++ b/int.go @@ -3,6 +3,8 @@ package null import ( "database/sql" "encoding/json" + "fmt" + "reflect" "strconv" ) @@ -52,6 +54,8 @@ func (i *Int) UnmarshalJSON(data []byte) error { case nil: i.Valid = false return nil + default: + err = fmt.Errorf("json: cannot unmarshal %v into Go value of type null.Int", reflect.TypeOf(v).Name()) } i.Valid = err == nil return err