I like using shebangs to run my Perl scripts directly:
#!/usr/bin/env perl
What\'s the shebang for Go programs?
So far, chaining sh and gorun has proven to be the most portable solution for me.
///bin/sh -c true && exec gorun "$0" "$@"
package main
import (
"fmt"
"log"
"os"
)
func main() {
fmt.Println("hello")
log.Printf("args: %v", os.Args)
// just to test exit code, would be 0x11
os.Exit(17)
}
OUTPUT:
00:~ $ chmod a+x test.go && ./test.go rawr
hello
2020/01/21 23:17:40 args: [./test.go rawr]
11:~ $