Go notes.volution.ro

In Go-land you pay even for what you don't use  ↦

While I was trying to identify why my-Go-based project took more than three times to execute than a similar Bash script (for a code-path that amounted to just a few stderr writes), I found that many of the Go packages (including some in the built-in library) have quite “heavy” static initializers, which due to how Go initialization works are always executed regardless if I use them for a particular code-path or not.

Also, with the newly introduced GODEBUG=inittrace=1 in Go 1.16 developers can now investigate the cost of static initializers of their dependencies, thus I wanted to raise the awareness of this issue.


Discussion

Sign in or Join to comment or subscribe

Player art
  0:00 / 0:00