update docs
This commit is contained in:
parent
9ed047bf7b
commit
ab8dd4e057
2 changed files with 9 additions and 1 deletions
|
@ -8,6 +8,13 @@ Will marshal to a blank string if null. Blank string input produces a null Strin
|
||||||
|
|
||||||
`UnmarshalJSON` supports `sql.NullString` input.
|
`UnmarshalJSON` supports `sql.NullString` input.
|
||||||
|
|
||||||
|
### Int
|
||||||
|
A nullable int64.
|
||||||
|
|
||||||
|
Unlike null.String, null.Int will marshal to null if null. Zero input will not produce a null Int.
|
||||||
|
|
||||||
|
`UnmarshalJSON` supports `sql.NullInt64` input.
|
||||||
|
|
||||||
### Bugs
|
### Bugs
|
||||||
`json`'s `",omitempty"` struct tag does not work correctly right now. It will never omit a null or empty String. This should be [fixed in Go 1.4](https://code.google.com/p/go/issues/detail?id=4357).
|
`json`'s `",omitempty"` struct tag does not work correctly right now. It will never omit a null or empty String. This should be [fixed in Go 1.4](https://code.google.com/p/go/issues/detail?id=4357).
|
||||||
|
|
||||||
|
|
3
int.go
3
int.go
|
@ -6,7 +6,7 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Int is a nullable int.
|
// Int is a nullable int64.
|
||||||
type Int struct {
|
type Int struct {
|
||||||
sql.NullInt64
|
sql.NullInt64
|
||||||
}
|
}
|
||||||
|
@ -80,6 +80,7 @@ func (i Int) MarshalText() ([]byte, error) {
|
||||||
return []byte(strconv.FormatInt(i.Int64, 10)), nil
|
return []byte(strconv.FormatInt(i.Int64, 10)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Pointer returns a pointer to this Int's value, or a nil pointer if this Int is null.
|
||||||
func (i Int) Pointer() *int64 {
|
func (i Int) Pointer() *int64 {
|
||||||
if !i.Valid {
|
if !i.Valid {
|
||||||
return nil
|
return nil
|
||||||
|
|
Loading…
Reference in a new issue