With Go, you can the of an array (or more accurately a slice) by using the internal len() function. Our example shows us creating a slice and then printing out it’s , then adding an extra item and printing the again.
package main import "fmt" func main() { // Create an exmaple array array := []int{1, 2, 3, 4, 5} // Print number of items fmt.Println("First Length:", len(array)) // Add an item and print again array = append(array, 6) fmt.



Source link

LEAVE A REPLY

Please enter your comment!
Please enter your name here