Golang bufio.Write() function example

package bufio

Write writes contents into the buffer. It returns the number of bytes written also an error if the write is short.

Golang bufio.Write() function usage example

 writeBuffer := bytes.NewBuffer(nil)
 writer := bufio.NewWriter(writeBuffer)

 data, err := writer.Write([]byte("abc123"))  // bufio.Write()
 if err != nil {
 return
 }

Advertisement