Skip to content

Instantly share code, notes, and snippets.

@mniak
Last active March 29, 2022 21:40
Show Gist options
  • Save mniak/09e5e46425ced7e3fe1c1661c24a0d8c to your computer and use it in GitHub Desktop.
Save mniak/09e5e46425ced7e3fe1c1661c24a0d8c to your computer and use it in GitHub Desktop.
Go bash runner - Add this to the beginning of the file
#!/bin/bash
# Check out the latest version at https://gist.github.com/mniak/09e5e46425ced7e3fe1c1661c24a0d8c
## CUSTOMIZATION SECTION: Type your own code below. You can add or remove lines if you need/want
## END OF CUSTOMIZATION SECTION
TEMPDIR=$(mktemp -d -t script)
trap "rm -rf $TEMPDIR" EXIT
GOLINENO=$(($LINENO + 10))
sed -n -e "$GOLINENO,\$p" < "$0" > $TEMPDIR/main.go
cd $TEMPDIR
go mod init script
go mod tidy
go build -o app .
cd -
$TEMPDIR/app
exit
# ---- PASTE THE GO SCRIPT BELOW ----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment