Last active
August 29, 2015 14:07
-
-
Save adam000/618f35aaaf10d72b4f15 to your computer and use it in GitHub Desktop.
A nice little command to set up a small Go "playground" (see also: play.golang.org) in a temporary directory
This file contains hidden or 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 | |
while true; do | |
DIR=/tmp/`printf %05d $RANDOM` | |
if [[ ! -e $DIR ]]; then | |
break | |
fi | |
done | |
echo Making $DIR | |
mkdir $DIR | |
cd $DIR | |
cat << EOF > main.go | |
package main | |
import "fmt" | |
func main() { | |
fmt.Println("Hello, playground") | |
} | |
EOF | |
vim main.go | |
echo Output: | |
go build -o a.out && ./a.out |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: you'll want to make sure that it's indented with a tab on line 20, if you copy-paste this (even the "raw" version seems to have 4 spaces inserted instead of a tab... sigh...)