Standard library / bufio
bufio.Reader.ReadBytes()
Returns bytes through and including the delimiter; on failure returns collected bytes and error. Handle a final partial record. Expected stdout: '"a," <nil>\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Reader) ReadBytes(delim byte) ([]byte, error)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| delim | byte | Delimiter byte. |
Return Value
([]byte, error)
Returns bytes through and including the delimiter; on failure returns collected bytes and error.
Working Example
Example Snippetgo
package main
import ( "bufio" "fmt" "strings")
func main() { r := bufio.NewReader(strings.NewReader("a,b")) p, e := r.ReadBytes(',') fmt.Printf("%q %v\n", p, e)}