3 ms·
> Written in Go I have a fairly simple web-app written in go – no websockets, just net/http. I just checked and the binary size is 6.8 megabytes. There's a lo
by dpwm 8y ago
> Written in Go
I have a fairly simple web-app written in go – no websockets, just net/http. I just checked and the binary size is 6.8 megabytes.
There's a lot in there. For starters, there's the go runtime. Then there's the HTTP server.
I suspect there may be ways to improve on the binary size if it mattered so much. xz gets it down to 2.1MB, suggesting there's some redundancy in there.
- marcrosoft 8y agoYou can cut your binary size almost in half on Linux by removing debug information and symbols with: `go build -ldflags="-s -w"`
- Something1234 8y agoI thought it was dangerous to use `strip` on any go binaries, because it would result in an incorrect program. LDFlags might cause something else but isn't it the same concept?
- cdoxsey 8y agoIt's certainly an issue, especially now with wasm: https://github.com/golang/go/issues/27266 https://github.com/golang/go/issues/27266 Probably unavoidable for this kind of app though. Unicode alone involves a whole lot of data tables that are going to be hard to get rid of unless they're dynamically linked. 7MB is still a lot smaller than Docker containers :)