Full Discussion (Custom range iterators in Go)

Python's range() just returns a list, that can then be iterated. If you do a version of IntRange() that just returns a slice, you will have something comparable. I would even rename it to something more appropriate, like IntSequence or IntSlice, because that is what the function would be doing.

What you did with channels here is closer to what Python's xrange() is. Given that it is not safe to use channels for this use-case, I would suggest any another approach, without using the range keyword. I believe using the 3-clause for loop is the best replacement for xrange()

code of conduct - report abuse