Skip to content

Instantly share code, notes, and snippets.

@stevenwilkin
Created July 9, 2015 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenwilkin/3928c453487ae514097e to your computer and use it in GitHub Desktop.
Save stevenwilkin/3928c453487ae514097e to your computer and use it in GitHub Desktop.
# build go static binary from root of project
gostatic(){
local dir=$1
if [[ -z $dir ]]; then
dir=$(pwd)
fi
local name=$(basename "$dir")
(
cd $dir
echo "Building static binary for $name in $dir"
GOOS=linux go build -a \
-tags 'netgo static_build' \
-installsuffix netgo \
-ldflags "
-w
" \
-o "$name" .
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment