Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions bin/download
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ download_golang() {
local platform=""
local arch=""

# Validate version format before attempting download
validate_version "$version"

platform=$(get_platform)
arch=$(get_arch)
download_url="https://dl.google.com/go/go${version}.${platform}-${arch}.tar.gz"
Expand Down
10 changes: 10 additions & 0 deletions lib/helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ get_arch() {
printf "%s" "$arch"
}

validate_version() {
local version="$1"

# Check if version matches the pattern major.minor.patch
# This allows for versions like 1.21.0, 1.22.1, etc.
if [[ ! "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
fail "Invalid version format: '$version'. Go versions must be in the format 'major.minor.patch' (e.g., '1.25.0')."
fi
}

msg() {
echo -e "\033[32m$1\033[39m" >&2
}
Expand Down
Loading