Hacker News new | past | comments | ask | show | jobs | submit login

> 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.




It's certainly an issue, especially now with wasm: 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 :)


You can cut your binary size almost in half on Linux by removing debug information and symbols with:

`go build -ldflags="-s -w"`


I 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?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: