Documentation
¶
Overview ¶
Command wasmsize says where the bytes of a Go WebAssembly binary go: the code of each package (or module), measured from the module's own code section, plus the data and the other sections.
It exists because `go tool nm` and `go version -m` both answer "unrecognized file format" for a .wasm, and the question came up for real: go-embedded-ruby's browser build was 102 MB (21.8 MB gzipped), six times the go-ndarray playground that wanted to embed it, and cutting it down needs to know which of its ~700 packages weigh what.
Function names come from the "name" custom section, which cmd/link writes unless -s is given. It writes them sanitized (every byte outside [0-9A-Za-z_.] becomes "_"), so a name cannot be split back into a package path; wasmsize matches it against the sanitized form of the build's package list instead, given with -deps (the output of `go list -deps` for the same GOOS/GOARCH and tags). Two paths that sanitize alike are reported, never guessed between.