Skip to content

Instantly share code, notes, and snippets.

@ferhatelmas
Created July 6, 2015 20:05
Show Gist options
  • Save ferhatelmas/765172152143e81f6077 to your computer and use it in GitHub Desktop.
Save ferhatelmas/765172152143e81f6077 to your computer and use it in GitHub Desktop.
Run go file as a shebang

Add //usr/bin/env go run $0 $@; exit to go file to run like a shell script

$ cat a.go
//usr/bin/env go run $0 $@; exit

package main

import "fmt"

func main() {
        fmt.Println("hello world")
}
$ chmod a+x a.go
$ ./a.go
hello world
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment