Skip to content

Commit

Permalink
Pull log 1.14.0 with it's no_net (no_http) (#34)
Browse files Browse the repository at this point in the history
* Pull log 1.14.0 with it's no_net (no_http)

* Add tag info in readme

* Add build command example, also update fallback while at it - strangely dependabot doesn't do it automatically

* add more data about sizes
  • Loading branch information
ldemailly authored Jul 2, 2024
1 parent 0bbca23 commit cc842c6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions ca_bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=

0 comments on commit cc842c6

Please sign in to comment.