Standard library / bufio

bufio.Reader.ReadSlice()

Returns a transient slice through the delimiter; if buffer fills first returns partial data and ErrBufferFull. Copy before further reads. Expected stdout: '"a," <nil>\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Reader) ReadSlice(delim byte) (line []byte, err error)

Parameters & Attributes

NameTypeDescription
delimbyteDelimiter byte.

Return Value

(line []byte, err error)

Returns a transient slice through the delimiter; if buffer fills first returns partial data and ErrBufferFull.

Working Example

Example Snippetgo
package main
import (  "bufio"  "fmt"  "strings")
func main() {  r := bufio.NewReader(strings.NewReader("a,b"))  p, e := r.ReadSlice(',')  fmt.Printf("%q %v\n", p, e)}
Go Reference