Skip to content

Instantly share code, notes, and snippets.

@cdornsife
Last active March 7, 2019 18:57
Show Gist options
  • Select an option

  • Save cdornsife/172c56a5383c4b2ec871ef9946f03d20 to your computer and use it in GitHub Desktop.

Select an option

Save cdornsife/172c56a5383c4b2ec871ef9946f03d20 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Author: [email protected]
# gofmt -s -w .
set -o errexit
set -o nounset
set -o pipefail
echo "run tests:"
for i in $(find cmd pkg internal -maxdepth 0 -type d -exec echo ./{}/... \; 2>/dev/null); do
go test $i
done
echo
echo -n "check gofmt: "
ERRORS=$(find cmd pkg internal -type f -name \*.go 2>/dev/null | xargs gofmt -l 2>&1 || true)
if [ -n "${ERRORS}" ]; then
echo "these files need to be gofmt'ed:"
for error in ${ERRORS}; do
echo " $error"
done
echo "FAIL"
exit 1
fi
echo "PASS"
echo
echo -n "check go vet: "
ERRORS=$(find cmd pkg internal -maxdepth 0 -type d -exec echo ./{}/... \; 2>/dev/null | xargs go vet || true)
if [ -n "${ERRORS}" ]; then
echo "${ERRORS}"
echo "FAIL"
exit 1
fi
echo "PASS"
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment