Standard library / bufio

bufio.Reader.ReadString()

Returns text including delimiter or partial text plus error at EOF; does not strip line endings. Expected stdout: 'last true\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Reader) ReadString(delim byte) (string, error)

Parameters & Attributes

NameTypeDescription
delimbyteDelimiter byte.

Return Value

(string, error)

Returns text including delimiter or partial text plus error at EOF; does not strip line endings.

Working Example

Example Snippetgo
package main
import (  "bufio"  "fmt"  "io"  "strings")
func main() {  r := bufio.NewReader(strings.NewReader("last"))  s, e := r.ReadString('\n')  fmt.Println(s, e == io.EOF)}
Go Reference