How to reduce compiled file size?

前端 未结 12 734
野性不改
野性不改 2020-11-28 20:59

Lets compare c and go: Hello_world.c :

#include
int main(){
    printf(\"Hello world!\");
}

Hello_world.go:

         


        
12条回答
  •  抹茶落季
    2020-11-28 21:44

    Go binaries are large because they are statically linked (except for library bindings using cgo). Try statically linking a C program and you'll see it grow to a comparable size.

    If this is really a problem for you (which I have a hard time believing), you can compile with gccgo and dynamically link.

提交回复
热议问题