Standard library / bytes
bytes.Buffer.Len()
Returns number of unread bytes; reads reduce Len. Expected stdout: '1\n'.
Formal Syntax & Structure
go syntaxgo
func (b *Buffer) Len() intReturn Value
int
Returns number of unread bytes; reads reduce Len.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt")
func main() { b := bytes.NewBufferString("go") b.ReadByte() fmt.Println(b.Len())}