Standard library / reflect

reflect.Value.Cap()

Return capacity of an array, slice, channel or pointer to array. Other kinds panic. Expected stdout: '3\n'.

Formal Syntax & Structure

go syntaxgo
func (v Value) Cap() int

Return Value

int

Return capacity of an array, slice, channel or pointer to array.

Working Example

Example Snippetgo
package main
import (  "fmt"  "reflect")
func main() { fmt.Println(reflect.ValueOf(make([]int, 1, 3)).Cap()) }
Go Reference