Skip to content

Commit

Permalink
Add go lint checking for gwctl
Browse files Browse the repository at this point in the history
  • Loading branch information
gauravkghildiyal committed Apr 18, 2024
1 parent a0fc8c2 commit d167dde
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,9 @@ issues:
- linters:
- testifylint
text: "contains assertions that must only be used in the goroutine running the test function"
# It is valid usage to wrap errors without using %w to not make them part of
# the API contract.
- linters: ["errorlint"]
text: "non-wrapping format verb for fmt.Errorf. Use `%w` to format errors"
exclude:
- Using the variable on range scope `tc` in function literal
21 changes: 20 additions & 1 deletion hack/verify-golint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,25 @@ cd "${KUBE_ROOT}"
# See configuration file in ${KUBE_ROOT}/.golangci.yml.
mkdir -p cache

docker run --rm -v $(pwd)/cache:/cache -v $(pwd):/app --security-opt="label=disable" -e GOLANGCI_LINT_CACHE=/cache -e GOFLAGS="-buildvcs=false" -w /app "golangci/golangci-lint:$VERSION" golangci-lint run
failed=false
for module in $(find . -name "go.mod" | xargs -n1 dirname); do
echo "Linting ${module}"

docker run --rm \
-v $(pwd)/cache:/cache \
-v $(pwd):/app \
-w "/app/${module}" \
--security-opt="label=disable" \
-e GOLANGCI_LINT_CACHE=/cache \
-e GOFLAGS="-buildvcs=false" \
"golangci/golangci-lint:$VERSION" \
golangci-lint run || failed=true
done

if ${failed}; then
exit 1
else
exit 0
fi

# ex: ts=2 sw=2 et filetype=sh

0 comments on commit d167dde

Please sign in to comment.