Skip to content

Instantly share code, notes, and snippets.

@motemen
Created March 9, 2018 05:17
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 motemen/5b2ecf1d24621ef0ca4c45abadf50e46 to your computer and use it in GitHub Desktop.
Save motemen/5b2ecf1d24621ef0ca4c45abadf50e46 to your computer and use it in GitHub Desktop.
Shell script to run a Go program by package path
#!/bin/bash
set -e
pkg="$1"; shift
files=($(go list -f '{{range .GoFiles}}{{$.Dir}}/{{.}}{{end}}' "$pkg"))
go run -exec "bash -c 'shift; exec \"\$0\" \"\$@\"'" "${files[@]}" -- "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment