From 141376130f91917b7510d9430aa32833ab9b3fd4 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Wed, 3 Apr 2024 01:12:50 +0200 Subject: [PATCH] add readme --- README.md | 11 +++++++++++ app/Makefile | 8 ++++---- 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..49b7cd2 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +# go-binary-size +This repo is companion to an article published here (TODO add link). + +Contents : +* `app`: a Go module intended as an "application" (vs library) with 4 packages compilable as single binaries + * `a`, `a2` and `b` depend exclusively on matching packages from `mod1` + * `control` depends only on stdlib's `fmt` and is used as a control for what a small Go binary can weigh +* `mod1`: a Go module intended to represent a library that `app` would include. It contains 3 packages: + * `a`: depends on a large external dependency (`github.com/gin-gonic/gin`) in the "normal" files and also depends on some other external dependencies exclusively used in the test files, whether in the same package or in the `a_test` package. + * `a2`: same as `a` but doesn't contain test files, to show that test dependencies don't bloat the built binary + * `b`: depends only on `fmt` diff --git a/app/Makefile b/app/Makefile index 49bdd32..8ced80f 100644 --- a/app/Makefile +++ b/app/Makefile @@ -1,8 +1,8 @@ .PHONY: build build: - GOARCH=amd64 go build -o ./dist/a ./a - GOARCH=amd64 go build -o ./dist/a2 ./a2 - GOARCH=amd64 go build -o ./dist/b ./b - GOARCH=amd64 go build -o ./dist/control ./control + GOARCH=amd64 GOOS=darwin go build -o ./dist/a ./a + GOARCH=amd64 GOOS=darwin go build -o ./dist/a2 ./a2 + GOARCH=amd64 GOOS=darwin go build -o ./dist/b ./b + GOARCH=amd64 GOOS=darwin go build -o ./dist/control ./control ls -al ./dist shasum -a 256 ./dist/*