Standard library / bytes

bytes.Buffer.ReadString()

Reads through delim inclusive as a string. Missing delimiter returns remaining text and io.EOF. Expected stdout: 'a, <nil> b\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Buffer) ReadString(delim byte) (line string, err error)

Parameters & Attributes

NameTypeDescription
delimbyteDelimiter byte; included in the result when found.

Return Value

(line string, err error)

Reads through delim inclusive as a string. Missing delimiter returns remaining text and io.EOF.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  b := bytes.NewBufferString("a,b")  s, e := b.ReadString(',')  fmt.Println(s, e, b.String())}
Go Reference