Use golangci-lint instead of golint

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
Miloslav Trmač 2023-04-05 20:57:55 +02:00
parent c538340e3b
commit d4bd787e5f
3 changed files with 8 additions and 19 deletions

View File

@ -53,6 +53,7 @@ validate_task:
cpu: 4
memory: 8
script: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2
make validate-local
make vendor && hack/tree_status.sh
@ -91,7 +92,7 @@ osx_task:
export PATH=$GOPATH/bin:$PATH
brew update
brew install gpgme go go-md2man
go install golang.org/x/lint/golint@latest
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.52.2
test_script: |
export PATH=$GOPATH/bin:$PATH
go version

View File

@ -227,7 +227,7 @@ test-all-local: validate-local validate-docs test-unit-local
validate-local:
hack/validate-git-marks.sh
hack/validate-gofmt.sh
hack/validate-lint.sh
GOBIN=$(GOBIN) hack/validate-lint.sh
BUILDTAGS="${BUILDTAGS}" hack/validate-vet.sh
# This invokes bin/skopeo, hence cannot be run as part of validate-local

View File

@ -1,27 +1,15 @@
#!/bin/bash
IFS=$'\n'
files=( $(find . -name '*.go' | grep -v '^\./vendor/' | sort || true) )
unset IFS
errors=$($GOBIN/golangci-lint run --build-tags "${BUILDTAGS}" 2>&1)
errors=()
for f in "${files[@]}"; do
failedLint=$(golint "$f")
if [ "$failedLint" ]; then
errors+=( "$failedLint" )
fi
done
if [ ${#errors[@]} -eq 0 ]; then
if [ -z "$errors" ]; then
echo 'Congratulations! All Go source files have been linted.'
else
{
echo "Errors from golint:"
for err in "${errors[@]}"; do
echo "$err"
done
echo "Errors from golangci-lint:"
echo "$errors"
echo
echo 'Please fix the above errors. You can test via "golint" and commit the result.'
echo 'Please fix the above errors. You can test via "golangci-lint" and commit the result.'
echo
} >&2
exit 1