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
| Name | Type | Description |
|---|---|---|
| delim | byte | Delimiter 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)}