After using Golang Gin wrote the backend program with GoAdmin, the volume of the distribution package generated by go build has reached a whopping 30M. Upload Ali Cloud Server, which has a transfer speed of 400K/s for 1 minute.
Find a solution online, plus compilation parameters.
go build -ldflags "-s-w"
The volume has been reduced to 23M.
File size drops by about a quarter.
- The function of -s is to remove symbolic information. If you remove the symbol table, the stack trace will not see the file name and the wrong line number information when you golang panic.
- The purpose of -w is to remove DWARF tables debugging information. The result is that the program you get won't debug with GDB.
DWARF tables needed for debuggers
More extreme compression methods
Leave a Comment