elvish/tools/check-fmt-go.sh
Qi Xiao a537d12f40 Restructure check targets in Makefile.
- Consolidate all checks into a "all-checks" target in the Makefile, and use it
  from tools/pre-push and ci.yml.

- Remove trivial make targets, including "generate" and all the individual check
  targets.

- Remove the trivial script tools/lint.sh.

- Rename the "checkstyle" scripts to "check-fmt", which is more specific.
2022-12-29 23:23:42 +00:00

13 lines
357 B
Bash
Executable File

#!/bin/sh -e
# Check if Go files are properly formatted without modifying them.
echo 'Go files need these changes:'
# The grep is needed because `goimports -d` and `gofmt -d` always exits with 0.
if find . -name '*.go' | xargs goimports -d | grep .; then
exit 1
fi
if find . -name '*.go' | xargs gofmt -s -d | grep .; then
exit 1
fi
echo ' None!'