summaryrefslogtreecommitdiff
path: root/src/pkg/json/struct.go
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2010-01-05 11:33:06 +1100
committerRob Pike <r@golang.org>2010-01-05 11:33:06 +1100
commit25800663c143c09d489aa19dc3631f066cf6bdb0 (patch)
tree6a39849592d2b750069f91aec559bb631b26848a /src/pkg/json/struct.go
parentf1ef4faa0c1d143c032fa5a01a9be20df8089e98 (diff)
downloadgolang-25800663c143c09d489aa19dc3631f066cf6bdb0.tar.gz
Check for errors when writing fields of a struct.
R=rsc CC=golang-dev, jack.palevich http://codereview.appspot.com/183109
Diffstat (limited to 'src/pkg/json/struct.go')
-rw-r--r--src/pkg/json/struct.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/pkg/json/struct.go b/src/pkg/json/struct.go
index 4f2a1782c..7b50301e4 100644
--- a/src/pkg/json/struct.go
+++ b/src/pkg/json/struct.go
@@ -366,7 +366,11 @@ func writeStruct(w io.Writer, val *reflect.StructValue) os.Error {
for i := 0; i < val.NumField(); i++ {
fieldValue := val.Field(i)
fmt.Fprintf(w, "%q:", typ.Field(i).Name)
- writeValue(w, fieldValue)
+
+ if err := writeValue(w, fieldValue); err != nil {
+ return err
+ }
+
if i < val.NumField()-1 {
fmt.Fprint(w, ",")
}