问题描述

我编译了一个 hello world Go 程序,它在我的 linux 机器上生成了本机可执行文件.但是我惊讶地看到简单的 Hello world Go 程序的大小,它是 1.9MB!

I complied a hello world Go program which generated native executable on my linux machine. But I was surprised to see the size of the simple Hello world Go program, it was 1.9MB !

为什么这么简单的 Go 程序的可执行文件那么大?

Why is it that the executable of such a simple program in Go is so huge?

推荐答案

这个确切的问题出现在官方常见问题解答中:为什么我的小程序是这么大的二进制文件?

This exact question appears in the official FAQ: Why is my trivial program such a large binary?

引用答案:

5l6l8l
5l6l8l
printffmt.Printf
printffmt.Printf
Hello World"fmt
fmt"Hello World"
fmt.Println("Hello World! Again")fmt
fmt.Println("Hello World! Again")fmt

这篇关于Go 编译后的可执行文件很大的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!