With Go v1.26.1
package main
import "fmt"
func main() {
fmt.Printf("Hello World!\n")
}
Binary sizes:• 2581616B (2.5MB) → 1714560B (1.6MB) (with -ldflags="-s -w")
• 1531920B (1.5MB) → 753680B (0.7MB) (with upx --force-macos)
That said, a trivial “Hello World!” isn’t a meaningful benchmark. If you’re going to play that game, you might as well swap `fmt.Printf` for `fmt.Println`, or even `println` to avoid the import statement entirely. At that point, you’re no longer comparing anything interesting, the binaries end up roughly the same size anyway.
I find it quite interesting that import of "fmt" package alone leads to a 2+ MiB binary :). But, to be fair, TinyGo doesn't seem to treat "fmt.Printf" function any differently from others, so it does compile the same source code as the regular Go compiler and just has better escape analysis, dead code elimination, etc.