Golang & Concurrency (50 Qs)•Part 4: Production Compilation, Tooling & Senior Engineering (39 - 50)
Compiler Flags: What do `-ldflags="-s -w"` and `CGO_ENABLED=0` do?
senior LevelgolangProduction Compilation
In Simple Words:
CGO_ENABLED=0: Disables CGo, producing a purely static Go binary that runs anywhere without dynamic C library dependencies (glibc).-ldflags="-s -w":-s: Strips symbol tables.-w: Strips DWARF debug information.- Reduces binary size by up to 40–50%.