This repository has been archived by the owner on Feb 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #814 from yeya24/feature/support-golangci-lint
feature: replace gometalinter with golangci-lint
- Loading branch information
Showing
8 changed files
with
117 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
run: | ||
deadline: 3m | ||
modules-download-mode: readonly | ||
|
||
linters-settings: | ||
gocyclo: | ||
min-complexity: 20 | ||
|
||
linters: | ||
disable-all: true | ||
enable: | ||
- gofmt | ||
- goimports | ||
- golint | ||
- misspell | ||
- govet | ||
- goconst | ||
- deadcode | ||
- gocyclo | ||
|
||
# output configuration options | ||
output: | ||
format: colored-line-number | ||
print-issued-lines: true | ||
print-linter-name: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/bin/bash | ||
|
||
set -o nounset | ||
set -o errexit | ||
set -o pipefail | ||
|
||
# golangci-lint binary version v1.17.1 | ||
|
||
PKG=github.com/dragonflyoss/Dragonfly | ||
LINT_IMAGE=pouchcontainer/pouchlinter:v0.2.3 | ||
USE_DOCKER=${USE_DOCKER:-"0"} | ||
|
||
curDir=$(cd "$(dirname "$0")" && pwd) | ||
cd "${curDir}" || return | ||
LINT_SOURCE_HOME=$(cd ".." && pwd) | ||
|
||
. ./env.sh | ||
|
||
golangci-lint-docker() { | ||
cd "${LINT_SOURCE_HOME}" || return | ||
docker run \ | ||
--rm \ | ||
-ti \ | ||
-v "$(pwd)"/.go/pkg:/go/pkg \ | ||
-v "$(pwd)":/go/src/${PKG} \ | ||
-e GO111MODULE=on \ | ||
-e GOPROXY="${GOPROXY}" \ | ||
-w /go/src/${PKG} \ | ||
${LINT_IMAGE} \ | ||
golangci-lint run | ||
} | ||
|
||
check-golangci-lint() { | ||
has_installed="$(command -v golangci-lint || echo false)" | ||
if [[ "${has_installed}" = "false" ]]; then | ||
echo false | ||
return | ||
fi | ||
echo true | ||
} | ||
|
||
golangci-lint-local() { | ||
has_installed="$(check-golangci-lint)" | ||
if [[ "${has_installed}" = "true" ]]; then | ||
echo "Detected that golangci-lint has already been installed. Start linting..." | ||
cd "${LINT_SOURCE_HOME}" || return | ||
golangci-lint run | ||
return | ||
else | ||
echo "Detected that golangci-lint has not been installed. You have to install golangci-lint first." | ||
return 1 | ||
fi | ||
} | ||
|
||
main() { | ||
if [[ "1" == "${USE_DOCKER}" ]] | ||
then | ||
echo "Begin to check gocode with golangci-lint in docker." | ||
golangci-lint-docker | ||
else | ||
echo "Begin to check gocode with golangci-lint locally" | ||
golangci-lint-local | ||
fi | ||
echo "Check gocode with golangci-lint successfully " | ||
} | ||
|
||
main "$@" |