Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/gofmt: Panic on large asset file #30121
What version of Go are you using (
I can reproduce on
Here is the file after truncating all lines to ~120 bytes, so that we can see what kind of file it is without trying to load 1.1GB: https://play.golang.org/p/i6HApVeq41v
I can't spot an obvious bug or cause, so I guess this is just
That first length gets close to the maximum value of an
@tsenart This panic aside, I'd generally suggest to refrain from humongous Go source files, and particularly those that have most of the bytes in a single line. Even if gofmt was fixed, I'm sure other tools could also have issues with these extremely large line lengths. And of course,
If you really do want to include the file as part of the binary, perhaps you could use an assets code generator which set a limit on line lengths, such as 8MiB per line.
Thanks for investigating so quickly and for the feedback. It makes total sense.
Indeed this is an assets file. Do you know of any asset generator project that limits line lengths to 8MiB?
Found the cause, and it is indeed a kind of overflow; the longest line is
I can see a few possible short-term solutions:
For now, I'll mail 1. I personally believe that 2 should also be done, since
As it turns out, it's the overall length of the file that causes this panic, and not line length. As long as you have position offsets (from the file's first byte) which are close to