Skip to content

Commit 03ea24c

Browse files
#1587 - Fix: Remove temporary Go tools directory (#1588)
* Fix: Remove temporary Go tools directory * Bump go version & Fixed variable expansion --------- Co-authored-by: Kaniska <kaniska244@github.com>
1 parent d79c223 commit 03ea24c

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/go/devcontainer-feature.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"id": "go",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"name": "Go",
55
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/go",
66
"description": "Installs Go and common Go utilities. Auto-detects latest version and installs needed dependencies.",

src/go/install.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -301,10 +301,11 @@ GO_TOOLS="\
301301
if [ "${INSTALL_GO_TOOLS}" = "true" ]; then
302302
echo "Installing common Go tools..."
303303
export PATH=${TARGET_GOROOT}/bin:${PATH}
304-
mkdir -p /tmp/gotools /usr/local/etc/vscode-dev-containers ${TARGET_GOPATH}/bin
305-
cd /tmp/gotools
306304
export GOPATH=/tmp/gotools
307-
export GOCACHE=/tmp/gotools/cache
305+
export GOCACHE="${GOPATH}/cache"
306+
307+
mkdir -p "${GOPATH}" /usr/local/etc/vscode-dev-containers "${TARGET_GOPATH}/bin"
308+
cd "${GOPATH}"
308309

309310
# Use go get for versions of go under 1.16
310311
go_install_command=install
@@ -316,10 +317,9 @@ if [ "${INSTALL_GO_TOOLS}" = "true" ]; then
316317

317318
(echo "${GO_TOOLS}" | xargs -n 1 go ${go_install_command} -v )2>&1 | tee -a /usr/local/etc/vscode-dev-containers/go.log
318319

319-
# Move Go tools into path and clean up
320-
if [ -d /tmp/gotools/bin ]; then
321-
mv /tmp/gotools/bin/* ${TARGET_GOPATH}/bin/
322-
rm -rf /tmp/gotools
320+
# Move Go tools into path
321+
if [ -d "${GOPATH}/bin" ]; then
322+
mv "${GOPATH}/bin"/* "${TARGET_GOPATH}/bin/"
323323
fi
324324

325325
# Install golangci-lint from precompiled binares
@@ -332,6 +332,9 @@ if [ "${INSTALL_GO_TOOLS}" = "true" ]; then
332332
curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \
333333
sh -s -- -b "${TARGET_GOPATH}/bin" "v${GOLANGCILINT_VERSION}"
334334
fi
335+
336+
# Remove Go tools temp directory
337+
rm -rf "${GOPATH}"
335338
fi
336339

337340

0 commit comments

Comments
 (0)