Skip to content
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

Build tags for smaller binaries that don't need net/http or encoding/json #63

Merged
merged 27 commits into from
Jul 1, 2024

Conversation

ldemailly
Copy link
Member

@ldemailly ldemailly commented Jun 30, 2024

Discovered through the excellent https://github.com/Zxilly/go-size-analyzer that
even without any logging of http, binaries included vendor/golang.org/x/net/http/httpproxy

it's because of net/http's init and the linker not being smart enough to elide that:

httpproxy.FromEnvironment().ProxyFunc() is called by envProxyFunc
envProxyFunc is called by http.ProxyFromEnvironment (already an exported function)
http.ProxyFromEnvironment is called while setting up http.DefaultTransport, which is an exported package variable

(credit @CarsonHoffman for the analysis)

Also for the records,

go list  -tags whichevertags -f '{{.ImportPath}}: {{.Deps}}' ./...

lets you see dependencies (which go mod why doesn't)

Copy link

codecov bot commented Jun 30, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (c4c7d64) to head (a085108).
Report is 2 commits behind head on main.

Current head a085108 differs from pull request most recent head 7ec8cc2

Please upload reports for the commit 7ec8cc2 to get more accurate results.

Additional details and impacted files
@@            Coverage Diff            @@
##              main       #63   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         6    +2     
  Lines          550       612   +62     
=========================================
+ Hits           550       612   +62     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ldemailly
Copy link
Member Author

Didn't readily figure out how to get codecov read the coverage*.out but gave up for now - also fortio/workflows#2 (comment) might have to bite the bullet on the token thing as the coverage action keeps silently failing

But this is good to go now (I think) and will propagate in fortio/cli (main objective for small binaries) and fortio/scli

json_logging.go Show resolved Hide resolved
no_json_logging.go Outdated Show resolved Hide resolved
json_logging_test.go Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
levelsDemo/levels.go Outdated Show resolved Hide resolved
levelsDemo/levels.go Outdated Show resolved Hide resolved
Copy link
Contributor

@ccoVeille ccoVeille left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

json_logging_test.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
… makefile specific/local (GO_BIN) - tweaked the make all target
@ldemailly ldemailly requested a review from ccoVeille July 1, 2024 21:20
@ldemailly ldemailly merged commit 4f63076 into main Jul 1, 2024
4 checks passed
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