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

Method WriteString

msgp/write.go:495–516  ·  view source on GitHub ↗

WriteString writes a messagepack string to the writer. (This is NOT an implementation of io.StringWriter)

(s string)

Source from the content-addressed store, hash-verified

493// WriteString writes a messagepack string to the writer.
494// (This is NOT an implementation of io.StringWriter)
495func (mw *Writer) WriteString(s string) error {
496 if uint64(len(s)) > math.MaxUint32 {
497 return ErrLimitExceeded
498 }
499
500 sz := uint32(len(s))
501 var err error
502 switch {
503 case sz <= 31:
504 err = mw.push(wfixstr(uint8(sz)))
505 case sz <= math.MaxUint8:
506 err = mw.prefix8(mstr8, uint8(sz))
507 case sz <= math.MaxUint16:
508 err = mw.prefix16(mstr16, uint16(sz))
509 default:
510 err = mw.prefix32(mstr32, sz)
511 }
512 if err != nil {
513 return err
514 }
515 return mw.writeString(s)
516}
517
518// WriteStringHeader writes just the string size
519// header of a MessagePack 'str' object. The user

Callers 15

TestReadZCStringFunction · 0.95
TestReadStringBytesFunction · 0.95
TestReadMapKeyFunction · 0.95
BenchmarkSkipBytesFunction · 0.95
TestReadIntfRecursionFunction · 0.95
TestSkipRecursionFunction · 0.95
TestReadStringFunction · 0.95
TestSkipFunction · 0.95
BenchmarkSkipFunction · 0.95
TestCopyNextFunction · 0.95
TestRemoveFunction · 0.95
TestLocateFunction · 0.95

Calls 6

pushMethod · 0.95
prefix8Method · 0.95
prefix16Method · 0.95
prefix32Method · 0.95
writeStringMethod · 0.95
wfixstrFunction · 0.85

Tested by 15

TestReadZCStringFunction · 0.76
TestReadStringBytesFunction · 0.76
TestReadMapKeyFunction · 0.76
BenchmarkSkipBytesFunction · 0.76
TestReadIntfRecursionFunction · 0.76
TestSkipRecursionFunction · 0.76
TestReadStringFunction · 0.76
TestSkipFunction · 0.76
BenchmarkSkipFunction · 0.76
TestCopyNextFunction · 0.76
TestRemoveFunction · 0.76
TestLocateFunction · 0.76