Archived
Add GOPROXY misconfiguration diagnostics to setup docs/scripts
This commit is contained in:
1 parent
b8a7534b2c
commit
d09fa1f665
3 files changed
+75
No files matched your search
@@ -84,6 +84,27 @@ go build ./...
|
|||||||
go test ./...
|
go test ./...
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Troubleshooting Go dependency downloads
|
||||||
|
|
||||||
|
If you see an error like:
|
||||||
|
|
||||||
|
```text
|
||||||
|
GOPROXY list is not the empty string, but contains no entries
|
||||||
|
```
|
||||||
|
|
||||||
|
your local Go environment is misconfigured. A common fix is:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go env -w GOPROXY=https://proxy.golang.org,direct
|
||||||
|
```
|
||||||
|
|
||||||
|
Helpful diagnostics:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
go env GOPROXY
|
||||||
|
echo "$GOPROXY"
|
||||||
|
```
|
||||||
|
|
||||||
### Acceptance tests
|
### Acceptance tests
|
||||||
|
|
||||||
Acceptance tests are read-only and opt-in.
|
Acceptance tests are read-only and opt-in.
|
||||||
|
|||||||
@@ -14,6 +14,33 @@ for cmd in bash git; do
|
|||||||
have "$cmd" || die "$cmd is required"
|
have "$cmd" || die "$cmd is required"
|
||||||
done
|
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
|
||||||
ensure_dir .codex/bin
|
ensure_dir .codex/bin
|
||||||
ensure_dir .codex/cache
|
ensure_dir .codex/cache
|
||||||
|
|||||||
@@ -11,6 +11,33 @@ for cmd in bash git go; do
|
|||||||
echo "[setup-dev] $cmd: $(command -v "$cmd")"
|
echo "[setup-dev] $cmd: $(command -v "$cmd")"
|
||||||
done
|
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
|
||||||
|
echo "[setup-dev][warn] GOPROXY appears malformed: non-empty value contains no entries." >&2
|
||||||
|
echo "[setup-dev][warn] This can cause errors like: GOPROXY list is not the empty string, but contains no entries." >&2
|
||||||
|
echo "[setup-dev][warn] Suggested fix: go env -w GOPROXY=https://proxy.golang.org,direct" >&2
|
||||||
|
echo "[setup-dev][warn] Current GOPROXY from environment: '$value'" >&2
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ "${GOPROXY+x}" == "x" ]]; then
|
||||||
|
validate_goproxy "$GOPROXY"
|
||||||
|
fi
|
||||||
|
|
||||||
if command -v terraform >/dev/null 2>&1; then
|
if command -v terraform >/dev/null 2>&1; then
|
||||||
echo "[setup-dev] terraform: $(command -v terraform)"
|
echo "[setup-dev] terraform: $(command -v terraform)"
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in new issue
Block a user