Skip to content

Fix GO_BUILD_MIRROR_URL not working (#446) #447

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions plugins/go-build/bin/go-build
Original file line number Diff line number Diff line change
Expand Up @@ -453,7 +453,9 @@ http() {
local file="$3"
[ -n "$url" ] || return 1

if [[ -z $GO_BUILD_MIRROR_URL ]] && [[ $IS_TEST != "true" ]]; then
if [ -n "$GO_BUILD_MIRROR_URL" ] && [ -z "$IS_TEST" ]; then
url="$GO_BUILD_MIRROR_URL/${url}"
else
url="https://go.dev/dl/${url}"
fi

Expand Down Expand Up @@ -502,18 +504,11 @@ http_get_wget() {
fetch_tarball() {
local package_name="$1"
local package_url="$2"
local mirror_url
local checksum

if [ "$package_url" != "${package_url/\#/}" ]; then
checksum="${package_url#*#}"
package_url="${package_url%%#*}"

if [ -n "$GO_BUILD_MIRROR_URL" ]; then
if [[ -z "$GO_BUILD_DEFAULT_MIRROR" || $package_url != */go.dev/* ]]; then
mirror_url="${GO_BUILD_MIRROR_URL}/$checksum"
fi
fi
fi

local tar_args="xzf"
Expand All @@ -538,9 +533,7 @@ fetch_tarball() {
if ! reuse_existing_tarball "$package_filename" "$checksum"; then
local tarball_filename=$(basename $package_url)
echo "Downloading ${tarball_filename}..." >&2
http head "$mirror_url" &&
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
download_tarball "$package_url" "$package_filename" "$checksum"
download_tarball "$package_url" "$package_filename" "$checksum"
fi

{
Expand Down Expand Up @@ -638,25 +631,18 @@ fetch_git() {
fetch_zip() {
local package_name="$1"
local package_url="$2"
local mirror_url
local checksum

if [ "$package_url" != "${package_url/\#/}" ]; then
checksum="${package_url#*#}"
package_url="${package_url%%#*}"

if [ -n "$GO_BUILD_MIRROR_URL" ]; then
mirror_url="${GO_BUILD_MIRROR_URL}/$checksum"
fi
fi

local package_filename="${package_name}.zip"

if ! reuse_existing_tarball "$package_filename" "$checksum"; then
echo "Downloading ${package_filename}..." >&2
http head "$mirror_url" &&
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
download_tarball "$package_url" "$package_filename" "$checksum"
download_tarball "$package_url" "$package_filename" "$checksum"
fi

{
Expand Down Expand Up @@ -902,7 +888,6 @@ fi

if [ -n "$GO_BUILD_MIRROR_URL" ]; then
GO_BUILD_MIRROR_URL="${GO_BUILD_MIRROR_URL%/}"
GO_BUILD_DEFAULT_MIRROR=
fi

if [ -n "$GO_BUILD_SKIP_MIRROR" ] || ! has_checksum_support compute_sha2; then
Expand Down
Loading