MCPcopy Create free account
hub / github.com/protocolbuffers/protobuf-go / WriteString

Method WriteString

internal/encoding/json/encode.go:80–87  ·  view source on GitHub ↗

WriteString writes out the given string in JSON string value. Returns error if input string contains invalid UTF-8.

(s string)

Source from the content-addressed store, hash-verified

78// WriteString writes out the given string in JSON string value. Returns error
79// if input string contains invalid UTF-8.
80func (e *Encoder) WriteString(s string) error {
81 e.prepareNext(scalar)
82 var err error
83 if e.out, err = appendString(e.out, s); err != nil {
84 return err
85 }
86 return nil
87}
88
89// Sentinel error used for indicating invalid UTF-8.
90var errInvalidUTF8 = errors.New("invalid UTF-8")

Callers 13

TestWriteStringErrorFunction · 0.95
marshalSingularMethod · 0.45
marshalUnknownMethod · 0.45
marshalAnyMethod · 0.45
marshalDurationMethod · 0.45
marshalTimestampMethod · 0.45
marshalFieldMaskMethod · 0.45
marshalSingularMethod · 0.45
TestEncoderFunction · 0.45
FormatListFunction · 0.45
FormatDescFunction · 0.45
FormatMethod · 0.45

Calls 2

prepareNextMethod · 0.95
appendStringFunction · 0.70

Tested by 2

TestWriteStringErrorFunction · 0.76
TestEncoderFunction · 0.36