fix: download-to-file with retries (a truncated piped stream half-extracts the GOROOT)

This commit is contained in:
2026-10-31 08:58:32 +02:00
parent a199e29dca
commit a025ca29dd
+5 -1
View File
@@ -17,7 +17,11 @@ runs:
*) echo "better-setup-go: unsupported arch $(uname -m)" >&2; exit 1 ;;
esac
rm -rf /usr/local/go # a base-image GOROOT under the same path corrupts on overlay
curl -fsSL "https://go.dev/dl/go${v}.linux-${arch}.tar.gz" | tar -xz -C /usr/local
# download-to-file with retries: a piped stream that truncates mid-archive leaves a
# half-extracted GOROOT that fails far away from its cause
curl --retry 3 --retry-delay 2 -fsSL -o /tmp/go.tgz "https://go.dev/dl/go${v}.linux-${arch}.tar.gz"
tar -xzf /tmp/go.tgz -C /usr/local
rm -f /tmp/go.tgz
ln -sf /usr/local/go/bin/go /usr/local/bin/go
ln -sf /usr/local/go/bin/gofmt /usr/local/bin/gofmt
go version