blob: 4d0e5818945b59391d8a1721d03a90895fc00f05 [file] [log] [blame]
#!/bin/bash
CHECKER=goimports
which goimports > /dev/null
if [ $? -ne 0 ]
then
which gofmt > /dev/null
if [ $? -ne 0 ]
then
echo 'Neither goimports nor gofmt could be found'
exit 2
fi
CHECKER=gofmt
fi
failed=0
lc=`ls *.go 2>/dev/null | wc -l`
if [ $lc -gt 0 ]
then
lc=`${CHECKER} -l . | wc -l`
if [ $lc -gt 0 ]
then
echo "** ${CHECKER} run required:"
${CHECKER} -l .
failed=1
fi
go vet
if [ $? -ne 0 ]
then
echo "** go vet failed"
failed=1
fi
fi
shopt -s nullglob
for f in *.go *.[ch]
do
lc=`egrep -c 'Copyright [0-9]+ Google Inc.|Apache License' $f`
if [ $lc -lt 2 ]
then
echo "** $f is missing a license header"
failed=1
fi
done
shopt -u nullglob
if [ $failed -gt 0 ]
then
exit 2
fi