HomeToolsAbout a20k

Buffer

what is it

Create new buffer/byte array ([]byte)

io.Reader is an interface that wraps the basic Read method.

  • Read reads up to len(p) bytes into p
  • It returns the number of bytes read (0 <= n <= len(p)) and any error encountered
type Reader interface { Read(p []byte) (n int, err error) }

It is useful when

import ( "bytes" ) func main() []byte { buf := new(bytes.Buffer) return buf.Bytes() }
© VincentVanKoh