Search code examples
cgobuildrelease

How to build a release version binary in Go?


In C, we can build a debug version or a release version of the binary files (the object files and the executable). How can we do this in Go?


Solution

  • In Go, it isn't typical to have a debug version or a release version.

    By default, go build combines symbol and debug info with binary files. However, you can remove the symbol and debug info with go build -ldflags "-s -w".