February 2026 Go Meetup
Meetup #82 on February 18 in person at Edmonton Unlimited at 6:00 pm.
Please RSVP at Meetup
News
Agenda
Using Go for Scripts
Abram Hindle walked through using Go as a scripting language, framed as "goals, failures, and working shebang patterns." The goal was single .go files in ~/bin, run like scripts via /usr/bin/env, with compiled binaries cached to avoid paying the full go run cost on every invocation. He quoted Rob Pike's position that a built-in script runner isn't worth the compiler/linker I/O it would encourage, then tried go-run-cache/gobin (which want a module context, breaking standalone scripts) before settling on gx, a runner that hashes a script, compiles once, and reuses the binary. A classic #! line fails outright because Go rejects #, and /usr/bin/env gx run treats "gx run" as a single program name unless -S splits it. The working solution is a comment-shebang — //usr/bin/env -S gx run "$0" "$@"; exit "$?" — which is valid Go (a comment) and also valid shell, giving a single-file, cached Go script.
Key points:
- Goal: single-file
.goscripts that run like shell scripts, with caching. - Rob Pike argues a built-in Go script runner isn't worth the resource cost.
go-run-cache/gobinneed a module context, breaking standalone scripts.- A real
#!line fails because Go rejects#as an illegal character. /usr/bin/env gx runtreats "gx run" as one program;-Sfixes argument splitting.- The comment-shebang
//usr/bin/env -S gx run "$0" "$@"is valid Go and shell. gxhashes the script, compiles once, and reuses the cached binary.
Future Topics Discussion
Open discussion on topic for future talks, workshops, activities.
Events
- Edmonton Go Meetup March