tinkerbell / lint-install

Consistently install reasonable linter rules for open-source projects
Apache License 2.0
6 stars 7 forks source link

lint-install breaks on projects where Go programs exist in subdirectories #1

Closed tstromberg closed 2 years ago

tstromberg commented 2 years ago

When run against hook, lint-install creates a bad Makefile:

% make lint
out/linters/golangci-lint-v1.42.0 run
ERRO Running error: context loading failed: no go files to analyze 
make: *** [lint] Error 5

That's because the Go modules live in two subdirectories:

% find . -name "go.mod"
./tink-docker/go.mod
./bootkit/go.mod

What should the Makefile generator do then? Probably something like:

tstromberg commented 2 years ago

The right incantation seems to be:

find . -name go.mod | xargs -n1 dirname | xargs -n1 -I{} sh -c "cd {} && golangci-lint run -c $(GOLINT_CONFIG)"

We can use that for projects that lack a top-level go.mod file.