Skip to content

Instantly share code, notes, and snippets.

@ddgenome
Created May 2, 2015 21:20
Show Gist options
  • Save ddgenome/3b4eee49013e68552bc4 to your computer and use it in GitHub Desktop.
Save ddgenome/3b4eee49013e68552bc4 to your computer and use it in GitHub Desktop.
Compile Go program into a static binary
# Go 1.4
CGO_ENABLED=0 GOOS=linux go get -a -installsuffix cgo -ldflags '-s' github.com/elastic/logstash-forwarder
# Go 1.3
CGO_ENABLED=0 GOOS=linux go get -a -ldflags '-s' github.com/elastic/logstash-forwarder
# GOOS is the OS target of the binary
# -a forces recompilation of all components
# you can replace get with build and the GitHub URL with a path to the directory with the code
# the -s ld option strips the symbols from the binary making it smaller
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment