From 404a61efa2ed8587033c776c39601a67a3e25123 Mon Sep 17 00:00:00 2001 From: Gregory Roseberry Date: Wed, 21 Jan 2015 11:33:38 +0900 Subject: [PATCH] improve godoc --- README.md | 2 +- bool.go | 2 +- float.go | 2 +- int.go | 2 +- string.go | 3 ++- zero/bool.go | 3 ++- zero/float.go | 4 +++- zero/int.go | 2 ++ zero/string.go | 2 ++ 9 files changed, 15 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 922b5b6..d6c268c 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ An even nuller nullable float64. Unlike `zero.Bool`, `null.Bool` will marshal to null if null. False input will not produce a null Bool. Can unmarshal from `sql.NullBool` JSON 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). +`json`'s `",omitempty"` struct tag does not work correctly right now. It will never omit a null or empty String. This should be [fixed eventually](https://github.com/golang/go/issues/4357). ### License BSD \ No newline at end of file diff --git a/bool.go b/bool.go index b913777..ca127f6 100644 --- a/bool.go +++ b/bool.go @@ -8,7 +8,7 @@ import ( "reflect" ) -// Bool is an even nuller nullable bool. +// Bool is a nullable bool. // It does not consider false values to be null. // It will decode to null, not false, if null. type Bool struct { diff --git a/float.go b/float.go index 5b722b1..b809d68 100644 --- a/float.go +++ b/float.go @@ -8,7 +8,7 @@ import ( "strconv" ) -// Float is an even nuller nullable float64. +// Float is a nullable float64. // It does not consider zero values to be null. // It will decode to null, not zero, if null. type Float struct { diff --git a/int.go b/int.go index 0c710c5..51ae2c4 100644 --- a/int.go +++ b/int.go @@ -8,7 +8,7 @@ import ( "strconv" ) -// Int is an even nuller nullable int64. +// Int is an nullable int64. // It does not consider zero values to be null. // It will decode to null, not zero, if null. type Int struct { diff --git a/string.go b/string.go index 630616a..0ad43a8 100644 --- a/string.go +++ b/string.go @@ -10,7 +10,8 @@ import ( "reflect" ) -// String is an even nuller nullable string. +// String is a nullable string. It supports SQL and JSON serialization. +// It will marshal to null if null. Blank string input will be considered null. type String struct { sql.NullString } diff --git a/zero/bool.go b/zero/bool.go index e59cf96..80f1a63 100644 --- a/zero/bool.go +++ b/zero/bool.go @@ -8,7 +8,8 @@ import ( "reflect" ) -// Bool is a nullable bool. +// Bool is a nullable bool. False input is considered null. +// Considered null to SQL unmarshaled from a false value. type Bool struct { sql.NullBool } diff --git a/zero/float.go b/zero/float.go index 247ea08..0b84285 100644 --- a/zero/float.go +++ b/zero/float.go @@ -8,7 +8,9 @@ import ( "strconv" ) -// Float is a nullable float64. +// Float is a nullable float64. Zero input will be considered null. +// JSON marshals to zero if null. +// Considered null to SQL if zero. type Float struct { sql.NullFloat64 } diff --git a/zero/int.go b/zero/int.go index 15d68da..8170683 100644 --- a/zero/int.go +++ b/zero/int.go @@ -9,6 +9,8 @@ import ( ) // Int is a nullable int64. +// JSON marshals to zero if null. +// Considered null to SQL if zero. type Int struct { sql.NullInt64 } diff --git a/zero/string.go b/zero/string.go index a1aae5a..cf39303 100644 --- a/zero/string.go +++ b/zero/string.go @@ -12,6 +12,8 @@ import ( ) // String is a nullable string. +// JSON marshals to a blank string if null. +// Considered null to SQL if zero. type String struct { sql.NullString }