sja*_*jas 8

如果您不想使用已经提到的可能有限制的“shebang”:

//usr/bin/env go run "$0" "$@"; exit "$?"

改为这样做:

# check if binfmt_misc is already active 
# (should already be done through systemd)
mount | grep binfmt_misc

# if not already mounted
sudo mount binfmt_misc -t binfmt_misc /proc/sys/fs/binfmt_misc

# get gorun and place it so it will work
go get github.com/erning/gorun
sudo mv $GOPATH/bin/gorun /usr/local/bin

# make .go scripts being run with `gorun` wrapper script
echo ':golang:E::go::/usr/local/bin/gorun:OC' | sudo tee /proc/sys/fs/binfmt_misc/register
/etc/rc.local
echo ':golang:E::go::/usr/local/bin/gorun:OC' | tee /proc/sys/fs/binfmt_misc/register 1>/dev/null
/tmp/gorun-$(hostname)-USERID
bash