Initial commit

This commit is contained in:
Zhongwei Li
2025-11-29 17:52:06 +08:00
commit 6823d09952
6 changed files with 155 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
#!/bin/bash
set -euo pipefail
PACKAGE="$1"
# Query Go proxy for latest version
URL="https://proxy.golang.org/${PACKAGE}/@latest"
RESPONSE=$(curl -sf "$URL" 2>/dev/null || echo "")
if [ -z "$RESPONSE" ]; then
echo "Error: Package '$PACKAGE' not found or unreachable" >&2
exit 1
fi
# Extract version from JSON response
VERSION=$(echo "$RESPONSE" | grep -o '"Version":"[^"]*"' | cut -d'"' -f4)
if [ -z "$VERSION" ]; then
echo "Error: Could not parse version from response" >&2
exit 1
fi
echo "$VERSION"