michaelsembwever commented on code in PR #3966:
URL: https://github.com/apache/cassandra/pull/3966#discussion_r1987209379
##########
doc/scripts/process-native-protocol-specs-in-docker.sh:
##########
@@ -23,17 +23,39 @@ GO_VERSION="1.23.1"
GO_TAR="go${GO_VERSION}.linux-amd64.tar.gz"
TMPDIR="${TMPDIR:-/tmp}"
-# Step 0: Download and install Go
-echo "Downloading Go $GO_VERSION..."
-wget -q "https://golang.org/dl/$GO_TAR" -O "$TMPDIR/$GO_TAR"
-
-echo "Installing Go..."
-tar -C "$TMPDIR" -xzf "$TMPDIR/$GO_TAR"
-rm "$TMPDIR/$GO_TAR"
-
-# Set Go environment variables
-export PATH="$PATH:$TMPDIR/go/bin"
-export GOPATH="$TMPDIR/go"
+check_go_version() {
+ if command -v go &>/dev/null; then
+ local installed_version
+ installed_version=$(go version | awk '{print $3}' | sed 's/go//')
+
+ if [ "$(printf '%s\n' "$GO_VERSION" "$installed_version" | sort -V |
head -n1)" = "$GO_VERSION" ]; then
+ echo "Detected Go $installed_version (>= $GO_VERSION), skipping
installation."
+ return 0
+ else
+ echo "Detected Go $installed_version (< $GO_VERSION), proceeding
with installation."
+ return 1
+ fi
+ else
+ echo "Go env not found in your system, proceeding with installation."
+ return 1
+ fi
+}
+
+if ! check_go_version; then
+ # Step 0: Download and install Go
+ echo "Downloading Go $GO_VERSION..."
+ wget --timeout=30 --tries=2 --waitretry=5 -q
"https://golang.org/dl/$GO_TAR" -O "$TMPDIR/$GO_TAR" || echo "Download golang
failed. Network timeout"
+
+ echo "Installing Go $GO_VERSION..."
+ tar -C "$TMPDIR" -xzf "$TMPDIR/$GO_TAR"
+ rm "$TMPDIR/$GO_TAR"
+
+ # Set Go environment variables
+ export PATH="$PATH:$TMPDIR/go/bin"
+ export GOPATH="$TMPDIR/go"
+else
+ echo "Using system-installed Go."
+fi
Review Comment:
nit: indentation needs to be only two spaces (in this file)
##########
doc/scripts/process-native-protocol-specs-in-docker.sh:
##########
@@ -23,17 +23,39 @@ GO_VERSION="1.23.1"
GO_TAR="go${GO_VERSION}.linux-amd64.tar.gz"
TMPDIR="${TMPDIR:-/tmp}"
-# Step 0: Download and install Go
-echo "Downloading Go $GO_VERSION..."
-wget -q "https://golang.org/dl/$GO_TAR" -O "$TMPDIR/$GO_TAR"
-
-echo "Installing Go..."
-tar -C "$TMPDIR" -xzf "$TMPDIR/$GO_TAR"
-rm "$TMPDIR/$GO_TAR"
-
-# Set Go environment variables
-export PATH="$PATH:$TMPDIR/go/bin"
-export GOPATH="$TMPDIR/go"
+check_go_version() {
+ if command -v go &>/dev/null; then
+ local installed_version
+ installed_version=$(go version | awk '{print $3}' | sed 's/go//')
Review Comment:
nit
```suggestion
local installed_version=$(go version | awk '{print $3}' | sed
's/go//')
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]