Standard library / bytes

bytes.Buffer.Grow()

Reserves capacity for at least n additional bytes; panics for negative n or unallocatable capacity. Expected stdout: 'true go\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Buffer) Grow(n int)

Parameters & Attributes

NameTypeDescription
nintMinimum additional capacity in bytes; must be nonnegative.

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt")
func main() {  b := bytes.NewBufferString("go")  b.Grow(8)  fmt.Println(b.Available() >= 8, b.String())}
Go Reference