Standard library / bytes
bytes.Buffer
Resizable byte buffer implementing reading and writing; zero value is usable. Bytes and Next expose slices valid until the next modification; Len is unread length. Grow reserves capacity; Reset clears content; Truncate retains the first n unread bytes and panics outside bounds. ReadBytes/ReadString may return data with EOF. Expected stdout: '"a," <nil> "b"\n'.
Formal Syntax & Structure
go syntaxgo
type Buffer struct { /* unexported fields */ }Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { var b bytes.Buffer b.WriteString("a,b") s, e := b.ReadString(',') fmt.Printf("%q %v %q\n", s, e, b.String())}