From ab8dd4e0578663f4c05bcf3d6477147d9bc9305d Mon Sep 17 00:00:00 2001 From: Greg Date: Sun, 31 Aug 2014 00:03:04 +0900 Subject: [PATCH] update docs --- README.md | 7 +++++++ int.go | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 876007c..f0fd423 100644 --- a/README.md +++ b/README.md @@ -8,6 +8,13 @@ Will marshal to a blank string if null. Blank string input produces a null Strin `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 `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). diff --git a/int.go b/int.go index b6d387d..557cb1b 100644 --- a/int.go +++ b/int.go @@ -6,7 +6,7 @@ import ( "strconv" ) -// Int is a nullable int. +// Int is a nullable int64. type Int struct { sql.NullInt64 } @@ -80,6 +80,7 @@ func (i Int) MarshalText() ([]byte, error) { 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 { if !i.Valid { return nil