encodeArray encodes an array.
(obj reflect.Value, dest *wire.Object)
| 539 | |
| 540 | // encodeArray encodes an array. |
| 541 | func (es *encodeState) encodeArray(obj reflect.Value, dest *wire.Object) { |
| 542 | l := obj.Len() |
| 543 | a := &wire.Array{ |
| 544 | Contents: make([]wire.Object, l), |
| 545 | } |
| 546 | *dest = a |
| 547 | for i := 0; i < l; i++ { |
| 548 | // We need to encode the full value because arrays are encoded |
| 549 | // using the type information from only the first element. |
| 550 | es.encodeObject(obj.Index(i), encodeAsValue, &a.Contents[i]) |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | // findType recursively finds type information. |
| 555 | func (es *encodeState) findType(typ reflect.Type) wire.TypeSpec { |
no test coverage detected