Skip to content

Commit

Permalink
chore(goimports): change imports-check from go list to find
Browse files Browse the repository at this point in the history
The previous imports-check target uses `go list` to find code to scan.
The problem is that `go list` produces a listing of directories to input
into goimports.

/a/b/c
/a/b/c/d
/a/b/c/e ---> example we want to exclude

In the example listing above, we want to exclude `e`. That was previously
done by excluding `e` via a `grep -v` command that followed `go list`.
The result is that the path with `e` on the end is excluded, but `/a/b/c`
is still scanned causing the excluded path to get scanned anyway. This
commit swaps all this out for a find command that excludes the paths and
returns filenames as input, not directories.
  • Loading branch information
ipcrm committed Nov 10, 2023
1 parent 21841d8 commit 1463f3e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ fmt-check: ## Lists formatting issues

.PHONY: imports-check
imports-check: ## Lists imports issues
@test -z $(shell goimports -l $(shell go list -f {{.Dir}} ./... | grep -v proto))
@test -z $(shell goimports -l $(shell find . -type f -name '*.go' -not -path './vendor/*' -not -path './cli/cdk/go/proto/*'))

.PHONY: run-api-example
run-api-example: ## Run an API example like 'make run-api-example example=api/_examples/active-containers/main.go'
Expand Down

0 comments on commit 1463f3e

Please sign in to comment.