1
0
mirror of https://github.com/golang/go synced 2024-11-25 01:27:56 -07:00

Check for errors when writing fields of a struct.

R=rsc
CC=golang-dev, jack.palevich
https://golang.org/cl/183109
This commit is contained in:
Rob Pike 2010-01-05 11:33:06 +11:00
parent f221067fe8
commit a0ee18bdd5

View File

@ -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, ",")
}