To create a range with a specific starting point in golang, we can simply use the built-in range keyword followed by our starting point, a colon, and the length of our range. Here's an example code block:
main.go149 chars13 linesIn this example, our starting point is 3 and our range length is 4. We initialize our for loop with i equal to start and we iterate until i is equal to start+length. This will output:
main.go8 chars5 lines
Note that we can also use range on slices, maps, and channels in golang.
gistlibby LogSnag