Open simonw opened 1 year ago
Fun follow-up idea: https://fedi.simonwillison.net/@simon/110922873440211227
you could hash the script body, create
~/.cache/goscript/HASH/script.go
, save a compiled binary to that folder and run that directly in the future.
Super nice, thanks @simonw! I'll have a play with this.
@simonw have you seen https://github.com/erning/gorun ?
Was just going to suggest something similar but in the form of a hash bang in the go file used as a script ....
#! /usr/bin/env go-script
I built a little Bash script to let you do this: https://til.simonwillison.net/bash/go-script
It supports this too:
And this, saved as
top10.goscript
and made executable:Then run like this:
It's a fun little hack in Bash, but maybe something like this could be useful as an actual Go program distributed as part of this project.