WriteIntf writes the concrete type of 'v'. WriteIntf will error if 'v' is not one of the following: - A bool, float, string, []byte, int, uint, or complex - A map of supported types (with string keys) - An array or slice of supported types - A pointer to a supported type - A type that satisfies the
(v any)
| 716 | // - A type that satisfies the msgp.Encodable interface |
| 717 | // - A type that satisfies the msgp.Extension interface |
| 718 | func (mw *Writer) WriteIntf(v any) error { |
| 719 | if v == nil { |
| 720 | return mw.WriteNil() |
| 721 | } |
| 722 | switch v := v.(type) { |
| 723 | |
| 724 | // preferred interfaces |
| 725 | |
| 726 | case Encodable: |
| 727 | return v.EncodeMsg(mw) |
| 728 | case Extension: |
| 729 | return mw.WriteExtension(v) |
| 730 | |
| 731 | // concrete types |
| 732 | |
| 733 | case bool: |
| 734 | return mw.WriteBool(v) |
| 735 | case float32: |
| 736 | return mw.WriteFloat32(v) |
| 737 | case float64: |
| 738 | return mw.WriteFloat64(v) |
| 739 | case complex64: |
| 740 | return mw.WriteComplex64(v) |
| 741 | case complex128: |
| 742 | return mw.WriteComplex128(v) |
| 743 | case uint8: |
| 744 | return mw.WriteUint8(v) |
| 745 | case uint16: |
| 746 | return mw.WriteUint16(v) |
| 747 | case uint32: |
| 748 | return mw.WriteUint32(v) |
| 749 | case uint64: |
| 750 | return mw.WriteUint64(v) |
| 751 | case uint: |
| 752 | return mw.WriteUint(v) |
| 753 | case int8: |
| 754 | return mw.WriteInt8(v) |
| 755 | case int16: |
| 756 | return mw.WriteInt16(v) |
| 757 | case int32: |
| 758 | return mw.WriteInt32(v) |
| 759 | case int64: |
| 760 | return mw.WriteInt64(v) |
| 761 | case int: |
| 762 | return mw.WriteInt(v) |
| 763 | case string: |
| 764 | return mw.WriteString(v) |
| 765 | case []byte: |
| 766 | return mw.WriteBytes(v) |
| 767 | case map[string]string: |
| 768 | return mw.WriteMapStrStr(v) |
| 769 | case map[string]any: |
| 770 | return mw.WriteMapStrIntf(v) |
| 771 | case time.Time: |
| 772 | return mw.WriteTime(v) |
| 773 | case time.Duration: |
| 774 | return mw.WriteDuration(v) |
| 775 | case json.Number: |