aboutsummaryrefslogtreecommitdiff
path: root/src/go
diff options
context:
space:
mode:
authorSamruddhi Khandale <skhandale@microsoft.com>2022-11-23 20:33:50 +0300
committerGitHub <noreply@github.com>2022-11-23 20:33:50 +0300
commitc4648ab98cdeeb520e7e629c5db4a471ec802954 (patch)
treef7f10e225e46f4ce4b6a71e5564345abb1b13e30 /src/go
parent173c7ca3c7ad646e6b9732b5af8d45f08606182e (diff)
go: fix bug - Go doesn't update version if go is already installed (#303)
* go: fix bug - Go doesn't update version if go is already installed * Update tests with bash -c
Diffstat (limited to 'src/go')
-rw-r--r--src/go/devcontainer-feature.json2
-rwxr-xr-xsrc/go/install.sh11
2 files changed, 8 insertions, 5 deletions
diff --git a/src/go/devcontainer-feature.json b/src/go/devcontainer-feature.json
index c83b4f0..b2aa30b 100644
--- a/src/go/devcontainer-feature.json
+++ b/src/go/devcontainer-feature.json
@@ -1,6 +1,6 @@
{
"id": "go",
- "version": "1.1.0",
+ "version": "1.1.1",
"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.",
diff --git a/src/go/install.sh b/src/go/install.sh
index f561144..844411f 100755
--- a/src/go/install.sh
+++ b/src/go/install.sh
@@ -142,7 +142,8 @@ if ! cat /etc/group | grep -e "^golang:" > /dev/null 2>&1; then
fi
usermod -a -G golang "${USERNAME}"
mkdir -p "${TARGET_GOROOT}" "${TARGET_GOPATH}"
-if [ "${TARGET_GO_VERSION}" != "none" ] && ! type go > /dev/null 2>&1; then
+
+if [[ "${TARGET_GO_VERSION}" != "none" ]] && [[ "$(go version)" != *"${TARGET_GO_VERSION}"* ]]; then
# Use a temporary locaiton for gpg keys to avoid polluting image
export GNUPGHOME="/tmp/tmp-gnupg"
mkdir -p ${GNUPGHOME}
@@ -186,7 +187,7 @@ if [ "${TARGET_GO_VERSION}" != "none" ] && ! type go > /dev/null 2>&1; then
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
else
- echo "Go already installed. Skipping."
+ echo "(!) Go is already installed with version ${TARGET_GO_VERSION}. Skipping."
fi
# Install Go tools that are isImportant && !replacedByGopls based on
@@ -218,8 +219,10 @@ if [ "${INSTALL_GO_TOOLS}" = "true" ]; then
(echo "${GO_TOOLS}" | xargs -n 1 go ${go_install_command} -v )2>&1 | tee -a /usr/local/etc/vscode-dev-containers/go.log
# Move Go tools into path and clean up
- mv /tmp/gotools/bin/* ${TARGET_GOPATH}/bin/
- rm -rf /tmp/gotools
+ if [ -d /tmp/gotools/bin ]; then
+ mv /tmp/gotools/bin/* ${TARGET_GOPATH}/bin/
+ rm -rf /tmp/gotools
+ fi
# Install golangci-lint from precompiled binares
if [ "$GOLANGCILINT_VERSION" = "latest" ] || [ "$GOLANGCILINT_VERSION" = "" ]; then