Go Shebang Line for Direct Execution
When working with Perl scripts, using shebangs allows for direct execution. For Go programs, the appropriate shebang line is:
//usr/bin/go run <pre class="brush:php;toolbar:false">//usr/bin/go run <pre class="brush:php;toolbar:false">//$GOROOT/bin/go run $@ ; exit
Example Usage:
Go considers "//" as single-line comments, while the shell ignores the additional "/".
Alternative Syntax
Go installations may vary in location. The following syntax adapts to this, working well for Macs:
The above is the detailed content of How Should I Write a Go Shebang Line for Direct Execution?. For more information, please follow other related articles on the PHP Chinese website!