go Length of the array in Go

To find the length of an array in Go, you can use the built-in len() function. Here is an example of how to use it:

package main

import "fmt"

func main() {
    arr := [5]int{1, 2, 3, 4, 5}
    length := len(arr)
    fmt.Println("Length of the array:", length)
}

In this example, we first declare an array arr with 5 elements of type int. The values of the elements are {1, 2, 3, 4, 5}.

Next, we use the len() function to determine the length of the array. The result is assigned to the variable length.

Finally, we print the value of length using fmt.Println().

When you run this program, it will output:

Length of the array: 5

The len() function returns the number of elements in the array. In this case, the array arr has 5 elements, so the length is 5.