Skip to content

Instantly share code, notes, and snippets.

@JonathonReinhart
Last active April 17, 2020 21:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonathonReinhart/ac9d6ef8000a48d2b14121bc2e81ecfe to your computer and use it in GitHub Desktop.
Save JonathonReinhart/ac9d6ef8000a48d2b14121bc2e81ecfe to your computer and use it in GitHub Desktop.
Run gofmt in CI
#!/bin/bash
PATHS='*.go internal'
# Run from project root
cd "$(dirname "${BASH_SOURCE[0]}")"
output="$(gofmt -l $PATHS)"
if [ ! -z "$output" ]; then
echo -e "The following files are not properly formatted:\n"
echo "$output" | sed 's/^/ /'
echo -e "\nPlease run 'gofmt -w $PATHS' to correct the formatting."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment