#!/bin/sh set -e old_dir=$PWD new_dir=`mktemp -d` cleanup() { rm -rf "$new_dir" } trap cleanup EXIT cp -r . "$new_dir" cd "$new_dir" checkgen() { $1 if ! diff -r . "$old_dir" then echo $2 1>&2 return 1 fi } checkgen 'go generate ./...' 'Generated files not up-to-date. Please run go generate.' checkgen 'go fmt ./...' '.go files not formatted. Please run go fmt.' go vet ./... go test ./...