buf := bytes.NewBuffer([]byte{0x01, 0x02, 0x03}) b, err := buf.ReadByte() if err != nil { log.Fatal(err) } fmt.Printf("%X", b)
buf := bytes.NewBuffer([]byte("hello, world")) b, err := buf.ReadByte() if err != nil { log.Fatal(err) } fmt.Printf("%c", b)This example creates a new buffer with a string and reads the first byte from it. The byte is printed as a character. Both examples use the `bytes` package library.