How to reduce compiled file size?

前端 未结 12 732
野性不改
野性不改 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:36

    You should get goupx, it will "fix" Golang ELF executables to work with upx. I've already got around 78% file size shrink in some cases ~16MB >> ~3MB.

    Compression ratio usually tends to 25%, so it's worth a try:

    $ go get github.com/pwaller/goupx
    $ go build -o filename
    $ goupx filename
    

    >>

    2014/12/25 10:10:54 File fixed!
    
            File size         Ratio      Format      Name
       --------------------   ------   -----------   -----------
      16271132 ->   3647116   22.41%  linux/ElfAMD   filename                            
    
    Packed 1 file.
    

    EXTRA: -s flag (strip) can shrink bin file even more goupx -s filename

提交回复
热议问题