MCPcopy
hub / github.com/vmihailenco/msgpack / Encode

Method Encode

encode.go:199–227  ·  view source on GitHub ↗
(v interface{})

Source from the content-addressed store, hash-verified

197}
198
199func (e *Encoder) Encode(v interface{}) error {
200 switch v := v.(type) {
201 case nil:
202 return e.EncodeNil()
203 case string:
204 return e.EncodeString(v)
205 case []byte:
206 return e.EncodeBytes(v)
207 case int:
208 return e.EncodeInt(int64(v))
209 case int64:
210 return e.encodeInt64Cond(v)
211 case uint:
212 return e.EncodeUint(uint64(v))
213 case uint64:
214 return e.encodeUint64Cond(v)
215 case bool:
216 return e.EncodeBool(v)
217 case float32:
218 return e.EncodeFloat32(v)
219 case float64:
220 return e.EncodeFloat64(v)
221 case time.Duration:
222 return e.encodeInt64Cond(int64(v))
223 case time.Time:
224 return e.EncodeTime(v)
225 }
226 return e.EncodeValue(reflect.ValueOf(v))
227}
228
229func (e *Encoder) EncodeMulti(v ...interface{}) error {
230 for _, vv := range v {

Callers 15

TestUseJsonTagFunction · 0.95
TestUseCustomTagFunction · 0.95
TestEncoderFunction · 0.95
TestFloatEncodingFunction · 0.95
TestTypesFunction · 0.95
TestUint64Function · 0.95
TestInt64Function · 0.95
TestSetSortMapKeysFunction · 0.95
TestSetOmitEmptyFunction · 0.95
EncodeMapMethod · 0.95
EncodeMapSortedMethod · 0.95
TestInternedStringFunction · 0.95

Calls 12

EncodeNilMethod · 0.95
EncodeStringMethod · 0.95
EncodeBytesMethod · 0.95
EncodeIntMethod · 0.95
encodeInt64CondMethod · 0.95
EncodeUintMethod · 0.95
encodeUint64CondMethod · 0.95
EncodeBoolMethod · 0.95
EncodeFloat32Method · 0.95
EncodeFloat64Method · 0.95
EncodeTimeMethod · 0.95
EncodeValueMethod · 0.95

Tested by 15

TestUseJsonTagFunction · 0.76
TestUseCustomTagFunction · 0.76
TestEncoderFunction · 0.76
TestFloatEncodingFunction · 0.76
TestTypesFunction · 0.76
TestUint64Function · 0.76
TestInt64Function · 0.76
TestSetSortMapKeysFunction · 0.76
TestSetOmitEmptyFunction · 0.76
TestInternedStringFunction · 0.76
TestInternedStringTagFunction · 0.76
TestResetDictFunction · 0.76