Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Go] Delete existing go install before extracting new version #1099

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion src/go/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "go",
"version": "1.3.1",
"version": "1.3.2",
"name": "Go",
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/go",
"description": "Installs Go and common Go utilities. Auto-detects latest version and installs needed dependencies.",
Expand Down
2 changes: 2 additions & 0 deletions src/go/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ if [[ "${TARGET_GO_VERSION}" != "none" ]] && [[ "$(go version 2>/dev/null)" != *
fi
curl -fsSL -o /tmp/go.tar.gz.asc "https://golang.org/dl/go${TARGET_GO_VERSION}.linux-${architecture}.tar.gz.asc"
gpg --verify /tmp/go.tar.gz.asc /tmp/go.tar.gz
echo "Removing existing Go ${TARGET_GOROOT}..."
mitesch marked this conversation as resolved.
Show resolved Hide resolved
rm -rf "${TARGET_GOROOT:?}/"*
Comment on lines +281 to +282
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
echo "Removing existing Go ${TARGET_GOROOT}..."
rm -rf "${TARGET_GOROOT:?}/"*
if [ -n "${TARGET_GOROOT}" ] && [ -d "${TARGET_GOROOT}" ]; then
echo "Removing existing Go installation at ${TARGET_GOROOT}..."
rm -rf "${TARGET_GOROOT}/"*
fi

echo "Extracting Go ${TARGET_GO_VERSION}..."
mitesch marked this conversation as resolved.
Show resolved Hide resolved
tar -xzf /tmp/go.tar.gz -C "${TARGET_GOROOT}" --strip-components=1
rm -rf /tmp/go.tar.gz /tmp/go.tar.gz.asc /tmp/tmp-gnupg
Expand Down
12 changes: 12 additions & 0 deletions test/go/install_go_1_23_over_1_22.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e

# Optional: Import test library
source dev-container-features-test-lib

# golangci is a smoke test to ensure the go install directory doesn't have leftover files from 1.22
check "install golangci-lint to verify the go install" bash -c "go install github.com/golangci/golangci-lint/cmd/[email protected]"

# Report result
reportResults
File renamed without changes.
12 changes: 10 additions & 2 deletions test/go/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
}
}
},
"install_go_centos-7": {
"image": "centos:centos7",
Comment on lines -38 to -39
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we keep this as is? For the test failures, you can pull from main which would have a fix for it.

"install_go_centos-9": {
"image": "quay.io/centos/centos:stream9",
"features": {
"go": {
"version": "latest",
Expand Down Expand Up @@ -89,5 +89,13 @@
"version": "1.19"
}
}
},
"install_go_1_23_over_1_22": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

"image": "mcr.microsoft.com/devcontainers/go:1.22",
"features": {
"go": {
"version": "1.23"
}
}
}
}