Standard library / strings

strings.Builder.Cap()

Reports the total capacity of the Builder byte storage. Capacity is at least Len, but exact growth is implementation-dependent. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (b *Builder) Cap() int

Return Value

int

Reports the total capacity of the Builder byte storage. Capacity is at least Len, but exact growth is implementation-dependent.

Working Example

Example Snippetgo
package main
import (  "fmt"  "strings")
func main() {  var b strings.Builder  b.Grow(8)  fmt.Println(b.Cap() >= 8)}
Go Reference