#!/bin/bash # Checks that all Go files in the specified project respect gofmt formatting. # Requires GOPATH to be set to a single path, not a list of them. PROJECT=${1:?missing project} PROBLEMS= for pkg in $(go list ${PROJECT}/...) ; do NONCOMPLIANT=$(gofmt -l ${GOPATH}/src/${pkg}/*.go) if [ -n "${NONCOMPLIANT}" ]; then echo pkg $pkg has some gofmt non-compliant files: echo ${NONCOMPLIANT}|xargs -d ' ' -n1 basename PROBLEMS="y" fi done test -z "${PROBLEMS}"