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
Because I'm using a scanner, foos can't be preallocated. It's not possible to know information about the number of lines or data lines in the file.
Minor issue: prealloc is identifying the problem on line 21, however, that is the opening declaration of the var block var (. foos is actually on line 24. Not sure if this is possible to remedy, and not a huge issue since prealloc names the slice to consider preallocating in the output.
The text was updated successfully, but these errors were encountered:
kellen-miller
changed the title
False positive when read a file line by line and incorrect line number for suggested preallocating
False positive when scanning a file and incorrect line number for suggested preallocation
Apr 8, 2024
Example setup to reproduce the issue.
foo.txt
main.go
Running
prealloc -forloops main.go
outputs:main.go:21 Consider preallocating foos
Two issues:
foos
can't be preallocated. It's not possible to know information about the number of lines or data lines in the file.prealloc
is identifying the problem on line 21, however, that is the opening declaration of the var blockvar (
.foos
is actually on line 24. Not sure if this is possible to remedy, and not a huge issue sinceprealloc
names the slice to consider preallocating in the output.The text was updated successfully, but these errors were encountered: