1#!/usr/bin/env nix-shell
2#! nix-shell -i bash -p curl jq
3# shellcheck shell=bash
4set -euo pipefail
5
6BASEURL=https://go.dev/dl/
7VERSION=${1:-}
8
9if [[ -z ${VERSION} ]]; then
10 echo "No version supplied"
11 exit 1
12fi
13
14curl -s "${BASEURL}?mode=json&include=all" |
15 jq '.[] | select(.version == "go'"${VERSION}"'")' |
16 jq -r '.files[] | select(.kind == "archive" and (.os == "linux" or .os == "darwin" or .os == "freebsd")) | (.os + "-" + .arch + " = \"" + .sha256 + "\";")'