To find the length of an array in Go, you can use the built-in len
function. Here's an example:
main.go146 chars10 lines
In this example, we declare an array of int
called numbers
with 5 elements. We then use the len
function to find the length of the array and assign that value to a variable called length
. Finally, we print the value of length
.
The len
function can also be used on slices, maps, and strings in Go.
gistlibby LogSnag