Add GOPROXY misconfiguration diagnostics to setup docs/scripts

This commit is contained in:
beatz174-bit
2026-04-21 15:33:25 +10:00
parent b8a7534b2c
commit d09fa1f665
3 changed files with 75 additions and 0 deletions
+27
View File
@@ -14,6 +14,33 @@ for cmd in bash git; do
have "$cmd" || die "$cmd is required"
done
validate_goproxy() {
local value="$1"
local part trimmed
local has_valid=0
IFS=',' read -r -a parts <<<"$value"
for part in "${parts[@]}"; do
trimmed="${part#"${part%%[![:space:]]*}"}"
trimmed="${trimmed%"${trimmed##*[![:space:]]}"}"
if [[ -n "$trimmed" ]]; then
has_valid=1
break
fi
done
if [[ "$has_valid" -eq 0 ]]; then
warn "GOPROXY appears malformed: non-empty value contains no entries"
warn "This can cause errors like: GOPROXY list is not the empty string, but contains no entries"
warn "Suggested fix: go env -w GOPROXY=https://proxy.golang.org,direct"
warn "Current GOPROXY from environment: '$value'"
fi
}
if [[ "${GOPROXY+x}" == "x" ]]; then
validate_goproxy "$GOPROXY"
fi
ensure_dir .codex
ensure_dir .codex/bin
ensure_dir .codex/cache