Buffer.Len in Go

Posted by GoDoc
Public (Editable by Users)

Len returns the number of bytes of the unread portion of the buffer; b.Len() == len(b.Bytes()).

Go
Edit
package main

import (
	"bytes"
	"fmt"
)

func main() {
	var b bytes.Buffer
	b.Grow(64)
	b.Write([]byte("abcde"))
	fmt.Printf("%d", b.Len())
}