Range

The range keyword is used in conjunction with the for loop to iterate the items of a collection.

The range can be used with an array, string, map or channels. During each iteration, range can return one or two values ​​based on the type of collection you are iterating over.

For arrays, range returns the index and element on each iteration.


for index, value := range myArray {...}
                        
range.go