Golang bytes.Buffer.ReadByte() function example

package bytes

ReadByte reads and returns the next byte from the buffer. If no byte is available, it returns error io.EOF.

Golang bytes.Buffer.ReadByte() function usage example

 package main

 import (
 "bytes"
 "fmt"
 )

 func main() {
 buff := bytes.NewBufferString("abcdef")


 rb, err := buff.ReadByte()

 fmt.Printf("%v  %d  %s\n", err, rb, string(rb))
 }

Output :

97 a

Reference :

http://golang.org/pkg/bytes/#Buffer.ReadByte

Advertisement