Skip to content

Instantly share code, notes, and snippets.

@dolmen
Created November 16, 2016 21:31
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dolmen/cb83e784fd920ed051a46a2bb2327cb6 to your computer and use it in GitHub Desktop.
Wrapping a Go source with a few lines of shell to make it directly runnable (chmod u+x)
#!/bin/sh
f=$(mktemp -t XXXXXXXX.go); sed -n '3,$p' "$0" >"$f"; go run "$f"; e=$?; rm -f "$f"; exit $?
package main
import "fmt"
func main() {
fmt.Println("Hello")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment