sourcegraph/dev/check/gofmt.sh
Varun Gandhi 87de6322e2
build: Merge sg-syntax into scip-syntax (#59890)
The bulk of the logic in the sg-syntax crate is related to highlighting.
Since that is generic information related to highlighting, move
it to scip-syntax which will be renamed to syntax-analysis in the future.

I will later move some of the webserver related logic into the
syntax-highlighter crate.
2024-01-26 18:18:22 +08:00

31 lines
628 B
Bash
Executable File

#!/usr/bin/env bash
set -e
echo "--- gofmt"
cd "$(dirname "${BASH_SOURCE[0]}")/../.."
# Check if all code is gofmt'd
# IGNORE:
# vendored: Vendored code doesn't matter for gofmt
# syntax-highlighter/crates: has embedded go test files
DIFF=$(
find . \( \
-path ./vendor \
-o -path ./vendored \
-o -path ./docker-images/syntax-highlighter/crates \
\) -prune -o -name '*.go' -exec gofmt -s -w -d {} +
)
if [ -z "$DIFF" ]; then
echo "Success: gofmt check passed."
exit 0
else
echo "ERROR: gofmt check failed:"
echo -e "\`\`\`term\n$DIFF\n\`\`\`" >./annotations/gofmt
echo "^^^ +++"
exit 1
fi