Home >Backend Development >Golang >What is the Correct Shebang Line for a Go Program?
Shebang Lines for Go Programs
In scripting languages like Perl, shebang lines are commonly used to execute scripts directly from the command line. For Go programs, what is the appropriate shebang line to use?
The correct shebang line for Go programs is:
Here's an example of its usage:
//usr/bin/go run <pre class="brush:php;toolbar:false">//$GOROOT/bin/go run $@ ; exit$@ ; exit package main import "fmt" func main() { fmt.Println("Hello World!") }
Note that Go interprets "//" as a single-line comment, while the shell ignores the additional "/".
Update:
Go installations can be located in different paths. The following syntax will take that into account, especially for Mac systems:
The above is the detailed content of What is the Correct Shebang Line for a Go Program?. For more information, please follow other related articles on the PHP Chinese website!