Last active
March 29, 2022 21:40
-
-
Save mniak/09e5e46425ced7e3fe1c1661c24a0d8c to your computer and use it in GitHub Desktop.
Go bash runner - Add this to the beginning of the file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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