Skip to content

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

Merged
ldemailly merged 27 commits intomainfrom
build_tags
Jul 1, 2024
Merged

Build tags for smaller binaries that don't need net/http or encoding/json#63
ldemailly merged 27 commits intomainfrom
build_tags

Conversation

@ldemailly
Copy link
Copy Markdown
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)

@codecov
Copy link
Copy Markdown

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
Copy Markdown
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

Copy link
Copy Markdown
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 👍

Co-authored-by: ccoVeille <3875889+ccoVeille@users.noreply.github.com>
… 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
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