diff options
author | Alessandro (Ale) Segala <43508+ItalyPaleAle@users.noreply.github.com> | 2022-10-28 23:57:57 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-28 23:57:57 +0300 |
commit | 0ee38a48e4833063acfc9e3c177c7067941e3b30 (patch) | |
tree | b81a8dfbe292edbefc428ce485ff4d8b0932d636 | |
parent | 85d2150997d4a1736c1f407d18ae71acb8541ed3 (diff) |
Install golangci-lint from prebuilt binaries and allow specifying its version (#238)
* Install golangci-lint from prebuilt binaries and allow specifying its version
* Updated as requested
* Update src/go/devcontainer-feature.json
Co-authored-by: Samruddhi Khandale <skhandale@microsoft.com>
* Updated install path
Co-authored-by: Samruddhi Khandale <skhandale@microsoft.com>
-rw-r--r-- | src/go/devcontainer-feature.json | 7 | ||||
-rwxr-xr-x | src/go/install.sh | 16 | ||||
-rw-r--r-- | test/go/install_go_tool_in_postCreate.sh | 1 | ||||
-rw-r--r-- | test/go/scenarios.json | 3 |
4 files changed, 22 insertions, 5 deletions
diff --git a/src/go/devcontainer-feature.json b/src/go/devcontainer-feature.json index 75fa9ae..c83b4f0 100644 --- a/src/go/devcontainer-feature.json +++ b/src/go/devcontainer-feature.json @@ -1,6 +1,6 @@ { "id": "go", - "version": "1.0.9", + "version": "1.1.0", "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.", @@ -15,6 +15,11 @@ ], "default": "latest", "description": "Select or enter a Go version to install" + }, + "golangciLintVersion": { + "type": "string", + "default": "latest", + "description": "Version of golangci-lint to install" } }, "init": true, diff --git a/src/go/install.sh b/src/go/install.sh index 9bb8047..f561144 100755 --- a/src/go/install.sh +++ b/src/go/install.sh @@ -8,6 +8,7 @@ # Maintainer: The VS Code and Codespaces Teams TARGET_GO_VERSION=${VERSION:-"latest"} +GOLANGCILINT_VERSION=${GOLANGCILINTVERSION:-"latest"} TARGET_GOROOT=${TARGET_GOROOT:-"/usr/local/go"} TARGET_GOPATH=${TARGET_GOPATH:-"/go"} @@ -197,8 +198,7 @@ GO_TOOLS="\ github.com/mgechev/revive@latest \ github.com/uudashr/gopkgs/v2/cmd/gopkgs@latest \ github.com/ramya-rao-a/go-outline@latest \ - github.com/go-delve/delve/cmd/dlv@latest \ - github.com/golangci/golangci-lint/cmd/golangci-lint@latest" + github.com/go-delve/delve/cmd/dlv@latest" if [ "${INSTALL_GO_TOOLS}" = "true" ]; then echo "Installing common Go tools..." export PATH=${TARGET_GOROOT}/bin:${PATH} @@ -219,8 +219,18 @@ if [ "${INSTALL_GO_TOOLS}" = "true" ]; then # Move Go tools into path and clean up mv /tmp/gotools/bin/* ${TARGET_GOPATH}/bin/ - rm -rf /tmp/gotools + + # Install golangci-lint from precompiled binares + if [ "$GOLANGCILINT_VERSION" = "latest" ] || [ "$GOLANGCILINT_VERSION" = "" ]; then + echo "Installing golangci-lint latest..." + curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ + sh -s -- -b "${TARGET_GOPATH}/bin" + else + echo "Installing golangci-lint ${GOLANGCILINT_VERSION}..." + curl -fsSL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | \ + sh -s -- -b "${TARGET_GOPATH}/bin" "v${GOLANGCILINT_VERSION}" + fi fi diff --git a/test/go/install_go_tool_in_postCreate.sh b/test/go/install_go_tool_in_postCreate.sh index 7d4bc7b..dbb086c 100644 --- a/test/go/install_go_tool_in_postCreate.sh +++ b/test/go/install_go_tool_in_postCreate.sh @@ -7,6 +7,7 @@ source dev-container-features-test-lib check "mkcert version" mkcert --version | grep "v1.4.2" check "mkcert is installed at correct path" which mkcert | grep "/go/bin/mkcert" +check "golangci-lint version" golangci-lint --version | grep "golangci-lint has version 1.50.0" # Report result reportResults diff --git a/test/go/scenarios.json b/test/go/scenarios.json index 295dbe0..b3fe49c 100644 --- a/test/go/scenarios.json +++ b/test/go/scenarios.json @@ -3,7 +3,8 @@ "image": "ubuntu:focal", "features": { "go": { - "version": "latest" + "version": "latest", + "golangciLintVersion": "1.50.0" } }, "postCreateCommand": "go install filippo.io/mkcert@v1.4.2" |