‘cap’ function
returns the capacity of the underlying array.
App.go
package main import "fmt" func main() { data := make([]int, 5, 20) fmt.Println("Length : ", len(data)) fmt.Println("Capacity : ", cap(data)) fmt.Println("Data : ", data) }
Output
Length
: 5
Capacity
: 20
[0 0 0 0
0]
No comments:
Post a Comment