In Go, you can access the first element of an array by using index 0. Here is an example:
main.go129 chars12 lines
In the code above, the first element of the arr
array is accessed using index 0 and assigned to the first
variable. The value of first
is then printed to the console using the fmt.Println()
function.
Note that the same method can be used to access any element of an array by using its index.
gistlibby LogSnag