Skip to content

Instantly share code, notes, and snippets.

@brandonbloom
Created August 27, 2020 18:32
Show Gist options
  • Save brandonbloom/bc29e8a1d87e47bea78a251d5e06c2af to your computer and use it in GitHub Desktop.
Save brandonbloom/bc29e8a1d87e47bea78a251d5e06c2af to your computer and use it in GitHub Desktop.
Go: build & run command script
#!/bin/bash
set -e
if [ "$#" == "0" ]; then
echo "Usage: $0 <cmd> <args...>" > /dev/stderr
exit 1
fi
cmd=$1
shift
go build -o bin ./cmd/$cmd/...
exec ./bin/$cmd "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment