Skip to content

Optionally exclude sources from binary #3977

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rgmz
Copy link
Contributor

@rgmz rgmz commented Mar 14, 2025

Description:

Inspired by https://trufflesecurity.com/blog/introducing-trufflehog-s-burp-suite-extension-a-techical-deep-dive:

Extension size bloat: TruffleHog is ~170Mb.

Pros

  • Significantly reduces how long it takes to run go build due to sources I don't use
  • Lets me build an 80Mb binary (saving between 50-70Mb)
$ go build -tags "no_circleci,no_docker,no_elasticsearch,no_gcs,no_git,no_github,no_gitlab,no_huggingface,no_jenkins,no_postman,no_s3,no_syslog,no_travisci" -ldflags="-s -w"
$ ls -lh ./trufflehog
-rwxr-xr-x. 1 user user 80M Mar 13 22:39 ./trufflehog

Cons

  • Awkward; adds a separate _disabled.go file for each source
  • Niche feature

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@rgmz rgmz requested review from a team as code owners March 14, 2025 02:44
@rgmz rgmz force-pushed the build/exclude-sources branch from 4d49e30 to 2238f1c Compare March 14, 2025 02:49
@zricethezav
Copy link
Collaborator

I like it

@zricethezav
Copy link
Collaborator

Lets me build an 80Mb binary (saving between 50-70Mb)

@rgmz What sources do you use?

@rgmz
Copy link
Contributor Author

rgmz commented Mar 14, 2025

Lets me build an 80Mb binary (saving between 50-70Mb)

@rgmz What sources do you use?

It varies, but usually only Filesystem or Git/GitHub.

@rgmz
Copy link
Contributor Author

rgmz commented Mar 16, 2025

The binary shrinks another ~10Mb if you exclude analyzers & TUI.

$ go build -tags "no_tui,no_circleci,no_docker,no_elasticsearch,no_gcs,no_git,no_github,no_gitlab,no_huggingface,no_jenkins,no_postman,no_s3,no_syslog,no_travisci" -ldflags="-s -w"
$  ls -lh ./trufflehog 
-rwxr-xr-x. 1 user user 71M Mar 16 13:17 ./trufflehog

I'm fine to revert that commit: I care more about sources.

@rgmz rgmz force-pushed the build/exclude-sources branch 2 times, most recently from b2b1917 to b70e786 Compare March 23, 2025 22:08
@rgmz rgmz force-pushed the build/exclude-sources branch 2 times, most recently from 3ddad9b to 1d56d31 Compare April 1, 2025 18:39
@rgmz rgmz force-pushed the build/exclude-sources branch 2 times, most recently from 1f587e9 to a038f10 Compare April 12, 2025 18:04
@rgmz rgmz force-pushed the build/exclude-sources branch 2 times, most recently from 54957b7 to 5e9f617 Compare April 18, 2025 02:24
@rgmz rgmz force-pushed the build/exclude-sources branch 2 times, most recently from 2faf9eb to adb0102 Compare May 1, 2025 14:10
@rgmz rgmz force-pushed the build/exclude-sources branch from adb0102 to c477e2f Compare May 20, 2025 23:08
@rgmz rgmz force-pushed the build/exclude-sources branch from c477e2f to c14ccde Compare May 24, 2025 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants