Standard library / bytes

bytes.Buffer.ReadBytes()

Reads through delim inclusive. If delimiter is absent, returns remaining bytes and io.EOF. Expected stdout: 'abc true\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Buffer) ReadBytes(delim byte) (line []byte, err error)

Parameters & Attributes

NameTypeDescription
delimbyteDelimiter byte; included in the result when found.

Return Value

(line []byte, err error)

Reads through delim inclusive. If delimiter is absent, returns remaining bytes and io.EOF.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt"  "io")
func main() {  b := bytes.NewBufferString("abc")  p, e := b.ReadBytes(',')  fmt.Println(string(p), e == io.EOF)}
Go Reference