#!/bin/sh
# Pre-commit hook: run gofmt and go vet on staged Go files.
# Install with: make install-hooks

UNFORMATTED=$(gofmt -l .)
if [ -n "$UNFORMATTED" ]; then
    echo "gofmt: these files need formatting:"
    echo "$UNFORMATTED"
    echo ""
    echo "Run 'gofmt -w .' to fix."
    exit 1
fi

go vet ./... 2>&1
if [ $? -ne 0 ]; then
    echo "go vet failed"
    exit 1
fi
