4 ms·
Go doesn't need to have shebang support, the kernel will provide that. But for the record it will work: frodo ~ $ cat t.go //opt/go/bin/go ru
by stevekemp 6y ago
Go doesn't need to have shebang support, the kernel will provide that. But for the record it will work:
frodo ~ $ cat t.go
//opt/go/bin/go run $0 $@ ; exit
package main
import( "fmt" )
func main() {
fmt.Printf("Hello, world\n" );
}
frodo ~ $ ./t.go
Hello, world
Otherwise there are a bunch of go-interpreters out there, which can be used for adhoc scripting. I'm sure that in some circumstances they can be useful, but I've only used them for providing extensions / scripting to host-applications, rather than trying to use them interactively.
- maddyboo 6y agoI’m specifically asking about Go+ (not Go) “having” shebang support in that you can legally use the standard #! shebang. Yes, the kernel handles the shebang, but if the shebang target doesn’t ignore the line and errors then that’s where the problem lies. The workarounds mentioned by you and the other commenter’s linked article are sub-optional in that they require a system-wide modification, require wrapper scripts, or are non-standard hacks.