MCPcopy
hub / github.com/grpc/grpc-go / ExampleNewWriter

Function ExampleNewWriter

mem/buffer_slice_test.go:413–432  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

411}
412
413func ExampleNewWriter() {
414 var bs mem.BufferSlice
415 pool := mem.DefaultBufferPool()
416 writer := mem.NewWriter(&bs, pool)
417
418 for _, data := range [][]byte{
419 []byte("abcd"),
420 []byte("abcd"),
421 []byte("abcd"),
422 } {
423 n, err := writer.Write(data)
424 fmt.Printf("Wrote %d bytes, err: %v\n", n, err)
425 }
426 fmt.Println(string(bs.Materialize()))
427 // Output:
428 // Wrote 4 bytes, err: <nil>
429 // Wrote 4 bytes, err: <nil>
430 // Wrote 4 bytes, err: <nil>
431 // abcdabcdabcd
432}
433
434var (
435 _ io.Reader = (*stepReader)(nil)

Callers

nothing calls this directly

Calls 6

MaterializeMethod · 0.95
DefaultBufferPoolFunction · 0.92
NewWriterFunction · 0.92
PrintlnMethod · 0.80
WriteMethod · 0.65
PrintfMethod · 0.65

Tested by

no test coverage detected