bytebuffer_example_test.go 396 B

123456789101112131415161718192021
  1. package bytebufferpool_test
  2. import (
  3. "fmt"
  4. "github.com/valyala/bytebufferpool"
  5. )
  6. func ExampleByteBuffer() {
  7. bb := bytebufferpool.Get()
  8. bb.WriteString("first line\n")
  9. bb.Write([]byte("second line\n"))
  10. bb.B = append(bb.B, "third line\n"...)
  11. fmt.Printf("bytebuffer contents=%q", bb.B)
  12. // It is safe to release byte buffer now, since it is
  13. // no longer used.
  14. bytebufferpool.Put(bb)
  15. }