From 407762b5d9f31250b6d57910eb275290d6e9c506 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Mon, 5 Oct 2026 15:06:02 -0700 Subject: [PATCH] docs: fix go tool nm usage in binary-size.md The example ran go tool nm on a binary built with -ldflags="-s -w", which has no symbol table, so nm only reports "no symbols". Also, piping the output to "sort -nr" sorts by the first column, which is the symbol address (in hex), not the size. Run nm on a binary built without -s -w, and use its own -sort size option. Fixes: 679f715994ff ("Document v3 binary size checks") Signed-off-by: Kir Kolyshkin --- docs/v3/binary-size.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/v3/binary-size.md b/docs/v3/binary-size.md index a1e773e6b7..219eb4dcbe 100644 --- a/docs/v3/binary-size.md +++ b/docs/v3/binary-size.md @@ -16,11 +16,13 @@ go build -trimpath -ldflags="-s -w" -o myapp ./cmd/myapp ls -lh myapp ``` -Use the Go toolchain to inspect what is in the binary: +Use the Go toolchain to inspect what is in the binary. Note that `go tool nm` +needs the symbol table, so run it on a binary built without `-ldflags="-s -w"`: ```sh-session +go build -trimpath -o myapp ./cmd/myapp go version -m myapp -go tool nm -size myapp | sort -nr | head -40 +go tool nm -size -sort size myapp | head -40 ``` ## Practical Checks