Skip to content

Instantly share code, notes, and snippets.

@athomason
Last active June 21, 2016 22:32
Show Gist options
  • Save athomason/e1f4cdd228c6d63dc896c706538aaa76 to your computer and use it in GitHub Desktop.
Save athomason/e1f4cdd228c6d63dc896c706538aaa76 to your computer and use it in GitHub Desktop.
#!/bin/bash
t1=`tempfile`
t2=`tempfile`
trap "rm -f $t1.go $t2.go $t2" EXIT
echo "package main; func main() { $@; }" > $t1.go
goimports $t1.go > $t2.go
if [[ $? != 0 ]]; then
echo "goimports failed:"
cat $t1.go
exit
fi
go run $t2.go
if [[ $? != 0 ]]; then
echo "go run failed:"
cat $t2.go
exit
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment