encodeInterface encodes an interface.
(obj reflect.Value, dest *wire.Object)
| 593 | |
| 594 | // encodeInterface encodes an interface. |
| 595 | func (es *encodeState) encodeInterface(obj reflect.Value, dest *wire.Object) { |
| 596 | // Dereference the object. |
| 597 | obj = obj.Elem() |
| 598 | if !obj.IsValid() { |
| 599 | // Special case: the nil object. |
| 600 | *dest = &wire.Interface{ |
| 601 | Type: wire.TypeSpecNil{}, |
| 602 | Value: wire.Nil{}, |
| 603 | } |
| 604 | return |
| 605 | } |
| 606 | |
| 607 | // Encode underlying object. |
| 608 | i := &wire.Interface{ |
| 609 | Type: es.findType(obj.Type()), |
| 610 | } |
| 611 | *dest = i |
| 612 | es.encodeObject(obj, encodeAsValue, &i.Value) |
| 613 | } |
| 614 | |
| 615 | // isPrimitive returns true if this is a primitive object, or a composite |
| 616 | // object composed entirely of primitives. |
no test coverage detected