Files
odo/scripts/check-gofmt.sh
Philippe Martin 6a4e964d5e Move from github.com/feloy/devfile-builder (#6937)
* Move from github.com/feloy/devfile-builder

* Update .github/workflows/ui-e2e.yaml

Co-authored-by: Armel Soro <armel@rm3l.org>

---------

Co-authored-by: Armel Soro <armel@rm3l.org>
2023-06-29 11:06:02 +02:00

26 lines
674 B
Bash
Executable File

#!/bin/bash
# Why we are wrapping gofmt?
# - ignore files in certain directories, like 'vendor' or 'dist' (created when building RPM Packages of odo)
# - gofmt doesn't exit with error code when there are errors
GO_FILES=$(find . \( -path ./vendor -o -path ./dist -o -path ./.ibm/tools/tests-results/vendor -o -path ./ui/wasm/vendor \) -prune -o -name '*.go' -print)
for file in $GO_FILES; do
gofmtOutput=$(gofmt -l "$file")
if [ "$gofmtOutput" ]; then
errors+=("$gofmtOutput")
fi
done
if [ ${#errors[@]} -eq 0 ]; then
echo "gofmt OK"
else
echo "gofmt ERROR - These files are not formatted by gofmt:"
for err in "${errors[@]}"; do
echo "$err"
done
exit 1
fi