github.com/codeready-toolchain/api@v0.0.0-20240507023248-73662d6db2c5/make/format.mk (about) 1 GOFORMAT_FILES := $(shell find . -name '*.go' | grep -vEf ./gofmt_exclude) 2 3 .PHONY: check-go-format 4 ## Exits with an error if there are files that do not match formatting defined by gofmt 5 check-go-format: 6 $(Q)gofmt -s -l ${GOFORMAT_FILES} 2>&1 \ 7 | tee ./out/gofmt-errors \ 8 | read \ 9 && echo "ERROR: These files differ from gofmt's style (run 'make format-go-code' to fix this):" \ 10 && cat ./out/gofmt-errors \ 11 && exit 1 \ 12 || true 13 14 .PHONY: format-go-code 15 ## Formats any go file that does not match formatting defined by gofmt 16 format-go-code: 17 $(Q)gofmt -s -l -w ${GOFORMAT_FILES}