go vet yourself (#397)

go vet caught some nifty bugs. so fixed those here, and also made it so that
we vet everything from now on since the robots seem to do a better job of
vetting than we have managed to.

also adds gofmt check to circle. could move this to the test.sh script (didn't
want a script calling a script, because $reasons) and it's nice and isolated
in its own little land as it is. side note, changed the script so it runs in
100ms instead of 3s, i think find is a lot faster than go list.

attempted some minor cleanup of various scripts
This commit is contained in:
Reed Allman
2017-10-06 08:42:33 -07:00
committed by Travis Reeder
parent d16d449626
commit 8a59654582
13 changed files with 25 additions and 46 deletions

View File

@@ -1,23 +1,12 @@
#! /bin/sh
#!/bin/sh
# find and output all Go files that are not correctly formatted
set -e
function listFilesExit () {
echo The following files need to have go fmt ran:
echo $NEED_TO_FORMAT
exit 1
}
# Find all .go files except those under vendor/ or .git, run gofmt -l on them
OUT=$(find ! \( -path ./vendor -prune \) ! \( -path ./.git -prune \) -name '*.go' -exec gofmt -l {} +)
FOLDERS=$(go list -f {{.Dir}} ./... | grep -v vendor)
for i in $FOLDERS
do
cd $i
FILES=$(ls *.go)
for j in $FILES
do
#echo $i/$j
ALL_FILES="$ALL_FILES $i/$j"
done
done
#echo $ALL_FILES
NEED_TO_FORMAT="$(gofmt -l $ALL_FILES)"
[[ -z $NEED_TO_FORMAT ]] || listFilesExit
if [ -n "$OUT" ]; then
echo "$OUT"
exit 1
fi