You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The prealloc code seems to assume that the length of whatever you are iterating over is known in advance. But this is no longer true with the new Go 1.23 range-over-function iterators.
Minimal example:
package main
func iterator(func(int) bool) {
// ...iterator implementation...
}
func main() {
var slice []int
for i := range iterator {
slice = append(slice, i)
}
}
Solution: do not issue a linter warning for range-over-function loops.
The text was updated successfully, but these errors were encountered:
The
prealloc
code seems to assume that the length of whatever you are iterating over is known in advance. But this is no longer true with the new Go 1.23 range-over-function iterators.Minimal example:
Solution: do not issue a linter warning for range-over-function loops.
The text was updated successfully, but these errors were encountered: