Skip to content

go linter doesn't run against gwctl code #2918

@dprotaso

Description

@dprotaso

Seems it's a limitation of the linter - golangci/golangci-lint#828

Here's a patch to gateway APIs script that will do the linting in two phases. I don't want to PR this because there a dozen issues that would need to be addressed when adding this change

diff --git a/hack/verify-golint.sh b/hack/verify-golint.sh
index f14c7933..6fadd3b4 100755
--- a/hack/verify-golint.sh
+++ b/hack/verify-golint.sh
@@ -26,6 +26,21 @@ 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=0
+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=1
+done
+
+[[ $failed -eq 1 ]] && exit 1
 
 # ex: ts=2 sw=2 et filetype=sh

cc @gauravkghildiyal

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions