Skip to content

Instantly share code, notes, and snippets.

@adam000
Last active August 29, 2015 14:07
Show Gist options
  • Save adam000/618f35aaaf10d72b4f15 to your computer and use it in GitHub Desktop.
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
#!/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
@adam000
Copy link
Author

adam000 commented Oct 17, 2014

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...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment