What's the appropriate Go shebang line?

mcandre picture mcandre · Oct 10, 2011 · Viewed 10.2k times · Source

I like using shebangs to run my Perl scripts directly:

#!/usr/bin/env perl

What's the shebang for Go programs?

Answer

هومن جاویدپور picture هومن جاویدپور · Jul 27, 2013

//usr/bin/go run $0 $@ ; exit

example:

//usr/bin/go run $0 $@ ; exit
package main

import "fmt"

func main() {
    fmt.Println("Hello World!")
}

go treat // as a single line comment and shell ignore extra /