VideoTools/scripts/clear-go-cache.sh

40 lines
1.4 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Convenience script to clear Go build/module caches.
# Safe to run on Linux/macOS and Windows Git Bash.
set -e
echo "════════════════════════════════════════════════════════════════"
echo " VideoTools Go Cache Cleaner"
echo "════════════════════════════════════════════════════════════════"
echo ""
if ! command -v go >/dev/null 2>&1; then
echo "⚠️ Go is not installed or not in PATH; skipping go clean."
else
echo "🧹 Running: go clean -cache -modcache -testcache"
go clean -cache -modcache -testcache || true
echo "✓ Go clean complete"
fi
OS="$(uname -s)"
case "$OS" in
CYGWIN*|MINGW*|MSYS*)
# Windows paths under Git Bash
CACHE_DIR="${LOCALAPPDATA:-$APPDATA}/go-build"
;;
*)
CACHE_DIR="${GOCACHE:-$HOME/.cache/go-build}"
;;
esac
if [ -n "$CACHE_DIR" ] && [ -d "$CACHE_DIR" ]; then
echo "🗑️ Removing build cache dir: $CACHE_DIR"
rm -rf "$CACHE_DIR" || sudo rm -rf "$CACHE_DIR" || true
else
echo " No cache directory found at $CACHE_DIR (nothing to remove)."
fi
echo ""
echo "✅ Done. Re-run ./scripts/build.sh to rebuild VideoTools."