Created
July 24, 2026 17:45
-
-
Save burik666/65c2e8ab502cbdcea18a8510750e71c4 to your computer and use it in GitHub Desktop.
Quickly create and open temporary Go modules for experimentation.
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
| #!/usr/bin/env bash | |
| # Usage: | |
| # ./go-playground.sh [module-name] | |
| # | |
| # Examples: | |
| # ./go-playground.sh | |
| # ./go-playground.sh my-test | |
| # | |
| # Creates a temporary Go module in $TMPDIR/go-playground/<module-name> | |
| # and opens main.go in the default editor. | |
| set -e | |
| modname="${1:-unnamed}" | |
| ttdir="${TMPDIR:-/tmp}/go-playground/${modname}" | |
| if [[ -e "$ttdir" ]]; then | |
| cd "$ttdir" | |
| else | |
| mkdir -p "$ttdir" | |
| cd "$ttdir" | |
| go mod init "$modname" | |
| fi | |
| "${EDITOR:-vim}" main.go |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment