Last active
July 24, 2019 08:45
-
-
Save iwittkau/19ade8d55601dd339d9c3b095c940232 to your computer and use it in GitHub Desktop.
This is a function I keep in my .bashrc / .zshrc to open a local Go playground for quick prototyping or tests.
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
# Quickly jumpstart a local go playground | |
# This is a function I keep in my .bashrc / .zshrc to open a local Go playground for quick prototyping or tests. | |
# If you use something other than macOS and Visual Studio Code you have to edit line 14. | |
# | |
# Example: | |
# | |
# $ goplay test | |
# | |
# This will create `~/go/src/playground/test` containing a `main.go` and runs `go mod init playground/tes` | |
# | |
function goplay() { | |
mkdir -p ~/go/src/playground/$1 | |
printf "package main\n\nfunc main() {\n\n}" > ~/go/src/playground/$1/main.go | |
open -a 'Visual Studio Code' ~/go/src/playground/$1 | |
cd ~/go/src/playground/$1 && go mod init playground/$1 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment