MCPcopy
hub / github.com/tinylib/msgp / AppendIntf

Function AppendIntf

msgp/write_bytes.go:397–502  ·  view source on GitHub ↗

AppendIntf appends the concrete type of 'i' to the provided []byte. 'i' must be one of the following: - 'nil' - A bool, float, string, []byte, int, uint, or complex - A map[string]T where T is another supported type - A []T, where T is another supported type - A *T, where T is another supported type

(b []byte, i any)

Source from the content-addressed store, hash-verified

395// - A type that satisfies the msgp.Marshaler interface
396// - A type that satisfies the msgp.Extension interface
397func AppendIntf(b []byte, i any) ([]byte, error) {
398 if i == nil {
399 return AppendNil(b), nil
400 }
401
402 // all the concrete types
403 // for which we have methods
404 switch i := i.(type) {
405 case Marshaler:
406 return i.MarshalMsg(b)
407 case Extension:
408 return AppendExtension(b, i)
409 case bool:
410 return AppendBool(b, i), nil
411 case float32:
412 return AppendFloat32(b, i), nil
413 case float64:
414 return AppendFloat64(b, i), nil
415 case complex64:
416 return AppendComplex64(b, i), nil
417 case complex128:
418 return AppendComplex128(b, i), nil
419 case string:
420 return AppendString(b, i), nil
421 case []byte:
422 return AppendBytes(b, i), nil
423 case int8:
424 return AppendInt8(b, i), nil
425 case int16:
426 return AppendInt16(b, i), nil
427 case int32:
428 return AppendInt32(b, i), nil
429 case int64:
430 return AppendInt64(b, i), nil
431 case int:
432 return AppendInt64(b, int64(i)), nil
433 case uint:
434 return AppendUint64(b, uint64(i)), nil
435 case uint8:
436 return AppendUint8(b, i), nil
437 case uint16:
438 return AppendUint16(b, i), nil
439 case uint32:
440 return AppendUint32(b, i), nil
441 case uint64:
442 return AppendUint64(b, i), nil
443 case time.Time:
444 return AppendTime(b, i), nil
445 case time.Duration:
446 return AppendDuration(b, i), nil
447 case map[string]any:
448 return AppendMapStrIntf(b, i)
449 case map[string]string:
450 return AppendMapStrStr(b, i), nil
451 case json.Number:
452 return AppendJSONNumber(b, i)
453 case []any:
454 b = AppendArrayHeader(b, uint32(len(i)))

Callers 4

TestJSONNumberFunction · 0.92
TestNumberFunction · 0.85
AppendMapStrIntfFunction · 0.85
TestEncodeDecodeFunction · 0.85

Calls 15

AppendNilFunction · 0.85
AppendExtensionFunction · 0.85
AppendBoolFunction · 0.85
AppendFloat32Function · 0.85
AppendFloat64Function · 0.85
AppendComplex64Function · 0.85
AppendComplex128Function · 0.85
AppendStringFunction · 0.85
AppendBytesFunction · 0.85
AppendInt8Function · 0.85
AppendInt16Function · 0.85
AppendInt32Function · 0.85

Tested by 3

TestJSONNumberFunction · 0.74
TestNumberFunction · 0.68
TestEncodeDecodeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…