#!/bin/bash -e

source build

SRC=$(find . -name '*.go' \
	-not -path "./vendor/*")

PKG=$(cd gopath/src/${REPO_PATH}; go list ./... | \
	grep --invert-match vendor)

echo "Checking gofix..."
go tool fix -diff $SRC

echo "Checking gofmt..."
res=$(gofmt -d -e -s $SRC)
echo "${res}"
if [ -n "${res}" ]; then
	exit 1
fi

echo "Checking govet..."
go vet $PKG

echo "Running tests..."
go test -timeout 60s -cover $@ ${PKG} --race

echo "Success"
