Aniara

Blog

Snippet: Curling home test Go toolchain

I came across this snippet to download the latest and greatest Go toolchain. Typically useful in docker builds where the distro is behind.

RUN GOLANG_LATEST=$(curl -s "https://go.dev/dl/?mode=json" | jq -r '.[0].files[].filename | select(test("go.*.linux-amd64.tar.gz"))') && \
    curl -sOL https://go.dev/dl/${GOLANG_LATEST} && \
    rm -rf /usr/local/go && \
    tar -C /usr/local -xzf ${GOLANG_LATEST} && \
    rm ${GOLANG_LATEST}

Then make sure its on path:

export PATH=$PATH:/usr/local/go/bin