diff --git a/README.md b/README.md index 6c20344..c2fddce 100644 --- a/README.md +++ b/README.md @@ -142,3 +142,17 @@ It does this by defaulting to the bundle provided by `golang.org/x/crypto/x509ro See https://github.com/fortio/multicurl for a good example. If you do not want this behavior, build using `-tags no_tls_fallback`. + +### Small binaries + +If you application doesn't do http request/response logging at all, use `-tags no_http` or `-tags no_net` (that one will also imply `no_tls_fallback`) and save 1.6 Mbytes in your binary's size (because the linker isn't smart enough to see net/http isn't actually used) (1.1Mbytes for log's no_http and 530k from the no_tls_fallback) + +And, if you don't need any of the advanced JSON logging (which is quite likely with a cli), use `-tags no_json` the logger will still produce json structured logging just not as advanced if what you log are deep structures - this saves another 130k or so. + +These tags are from [fortio.org/log](https://github.com/fortio/log) v1.14 and later + +In summary: for smallest pure local cli binaries using this package: +``` +CGO_ENABLE=0 go build -trimpath -ldflags="-w -s" -tags no_net,no_json . +``` +saves ~1.7Mbytes in total (a basic cli dependending on this package will then only be about 300k more as an hello world yet include color help, buildinfo, version, logging etc) diff --git a/ca_bundle.go b/ca_bundle.go index 7fa2aee..e6942e4 100644 --- a/ca_bundle.go +++ b/ca_bundle.go @@ -3,8 +3,8 @@ // (c) 2024 Fortio Authors // See LICENSE -//go:build !no_tls_fallback -// +build !no_tls_fallback +//go:build !no_tls_fallback && !no_net +// +build !no_tls_fallback,!no_net package cli // import "fortio.org/cli" diff --git a/go.mod b/go.mod index 5505fa6..7f19e7a 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module fortio.org/cli go 1.18 require ( - fortio.org/log v1.12.2 + fortio.org/log v1.14.0 fortio.org/version v1.0.4 - golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8 + golang.org/x/crypto/x509roots/fallback v0.0.0-20240626151235-a6a393ffd658 ) -require fortio.org/struct2env v0.4.0 // indirect +require fortio.org/struct2env v0.4.1 // indirect diff --git a/go.sum b/go.sum index 34a05a5..36dc097 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ -fortio.org/log v1.12.2 h1:JwLDFvEUKGfqA09fcf+mOn8kxsvwhjXV92xghxNnnwA= -fortio.org/log v1.12.2/go.mod h1:1tMBG/Elr6YqjmJCWiejJp2FPvXg7/9UAN0Rfpkyt1o= -fortio.org/struct2env v0.4.0 h1:k5alSOTf3YHiB3MuacjDHQ3YhVWvNZ95ZP/a6MqvyLo= -fortio.org/struct2env v0.4.0/go.mod h1:lENUe70UwA1zDUCX+8AsO663QCFqYaprk5lnPhjD410= +fortio.org/log v1.14.0 h1:ZkIc3Qqwfs9Dd931k07YzoC+bqCpJKEjVlZwxgXW3Nw= +fortio.org/log v1.14.0/go.mod h1:1tnXMqd5rZAgvSeHJkD2xXpyXRBzdeXtKLZuzNLIwtA= +fortio.org/struct2env v0.4.1 h1:rJludAMO5eBvpWplWEQNqoVDFZr4RWMQX7RUapgZyc0= +fortio.org/struct2env v0.4.1/go.mod h1:lENUe70UwA1zDUCX+8AsO663QCFqYaprk5lnPhjD410= fortio.org/version v1.0.4 h1:FWUMpJ+hVTNc4RhvvOJzb0xesrlRmG/a+D6bjbQ4+5U= fortio.org/version v1.0.4/go.mod h1:2JQp9Ax+tm6QKiGuzR5nJY63kFeANcgrZ0osoQFDVm0= -golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8 h1:+kWDWI3Eb5cPIOr4cP+R2RLDwK3/dXppL+7XmSOh2LA= -golang.org/x/crypto/x509roots/fallback v0.0.0-20240604170348-d4e7c9cb6cb8/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8= +golang.org/x/crypto/x509roots/fallback v0.0.0-20240626151235-a6a393ffd658 h1:i7K6wQLN/0oxF7FT3tKkfMCstxoT4VGG36YIB9ZKLzI= +golang.org/x/crypto/x509roots/fallback v0.0.0-20240626151235-a6a393ffd658/go.mod h1:kNa9WdvYnzFwC79zRpLRMJbdEFlhyM5RPFBBZp/wWH8=