MCPcopy
hub / github.com/elastic/go-elasticsearch / WriteTo

Method WriteTo

esutil/json_reader.go:79–90  ·  view source on GitHub ↗

WriteTo implements the io.WriterTo interface.

(w io.Writer)

Source from the content-addressed store, hash-verified

77
78// WriteTo implements the io.WriterTo interface.
79func (r *JSONReader) WriteTo(w io.Writer) (int64, error) {
80 if r.buf != nil {
81 // Already encoded; seek to start so WriteTo emits the full content.
82 if _, err := r.buf.Seek(0, io.SeekStart); err != nil {
83 return 0, err
84 }
85 return r.buf.WriteTo(w)
86 }
87 cw := countingWriter{Writer: w}
88 err := r.encode(&cw)
89 return int64(cw.n), err
90}
91
92func (r *JSONReader) encode(w io.Writer) error {
93 if e, ok := r.val.(JSONEncoder); ok {

Callers 3

TestJSONReaderFunction · 0.95
RoundTripMethod · 0.80
EncodeJSONMethod · 0.80

Calls 2

encodeMethod · 0.95
SeekMethod · 0.80

Tested by 2

TestJSONReaderFunction · 0.76
EncodeJSONMethod · 0.64