From 384b9f2804162b90b8de877aca05c6e2fd4474d4 Mon Sep 17 00:00:00 2001 From: Andy Bursavich Date: Mon, 1 Jan 2018 22:11:29 -0800 Subject: [PATCH] Fix anonymous field index in range clause. Given the anonymousFields value []int{4, 5}, struct fields 0 and 1 were being decoded into instead of 4 and 5. --- decoder.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/decoder.go b/decoder.go index 396da75..6e4d7e5 100644 --- a/decoder.go +++ b/decoder.go @@ -602,7 +602,7 @@ func (d *decoder) decodeStruct( } // This fills in embedded structs - for i := range fields.anonymousFields { + for _, i := range fields.anonymousFields { _, err := d.unmarshalMap(size, offset, result.Field(i), depth) if err != nil { return 0, err