Abstract

///usr/bin/true; exec /usr/bin/env go run "$0" "$@"
package main
import "fmt"
func main() {
  fmt.Println("Hello, World!")
}

Source

As I learn Golang and find its syntax and standard library really nice, I wondered if I could use it for scripting. Bash scripts get me pretty far, but since I’m a big fan of the Fish Shell, I’d like a shell or even OS agnostic tool. Sure, I could use python. But I don’t like python as much.

Of course, every system has some version of python installed by default, but that’s also true for bash and curl. And if need be, I can just compile and publish some binaries to GitHub.

The above script works splendidly. Its not quite a shebang, but it works the same way.