package declaration always on top, followed by imports (if any) and
everything else after. It makes parsing just the package name, or imports
easier and faster since the moment you run into something in the following
group, you know the previous ended.
I'm quite surprised something similar wasn't done with the //go:generate
commands. It seems they are allowed to be absolutely anywhere in any .go
file, so `go generate` has to read through absolutely everything.
In practice, I'm seeing most //go:generate comments placed on top of
Due to current implementation that uses bufio.Scanner that has a 64 KB line
length limit, this places an artificial restriction on all .go files to not
contain lines longer than 64 KB, as described
in https://code.google.com/p/go/issues/detail?id=9143. No one is going to
write 64 KB lines by hand, but it may happen for other unforeseen reasons,
including copy-pasting raw string data or other generated code scenarios
(e.g. see https://github.com/jteeuwen/go-bindata/issues/60). This
limitation did not exist before Go 1.4.
Is there a good reason not to add the requirement for //go:generate
comments to be either above package clause, or above imports, or at the
very least above the rest of the program? It seems like not having such a
restriction has a lot of downsides. Thank you.
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/d/optout.