mirror of
https://github.com/burrowers/garble.git
synced 2025-12-24 12:58:05 +08:00
garble's -literals flag and its patching of the runtime may leave unused imports. We used to try to detect those and remove the imports, but that was still buggy with edge cases like dot imports or renamed imports. Moreover, it was potentially incorrect. Completely removing an import from a package means we don't run its init funcs, which could have side effects changing the behavior of a program. As an example, database/sql drivers are registered at init time. Instead, for each import in an obfuscated Go file, add an unnamed declaration which references the imported package. This may not be necessary for all imported packages, as only a minority become unused due to garble, but it's also relatively harmless to do so. Fixes #658.