diff --git a/Makefile b/Makefile
index 867b9b27b01637233ddeb9de6244d464d8956e9d..9792c5b1675e369dee3cd48320102e0b2df156fe 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,7 @@ vet:
 	@go vet $(shell go list ./... | grep -v '/vendor/')
 
 fmt:
-	@go fmt $(shell go list ./... | grep -v '/vendor/')
+	@./scripts/gofmt $(shell go list ./... | grep -v '/vendor/')
 
 lint:
 	@for package in $(shell go list ./... | grep -v '/vendor/' | grep -v '/api' | grep -v '/server/internal'); do \
diff --git a/connector/github/github.go b/connector/github/github.go
index 0579e42eefa69268d277273ed4a895679f0d633f..ae0784121bb325ef26c1105f5ba22c1193278b8c 100644
--- a/connector/github/github.go
+++ b/connector/github/github.go
@@ -503,13 +503,13 @@ func (c *githubConnector) userEmail(ctx context.Context, client *http.Client) (s
 				advised them not to check for verified emails
 				(https://circleci.com/enterprise/changelog/#1-47-1).
 				In addition, GitHub Enterprise support replied to a support
-				ticket with "There is no way to verify an email address in 
-				GitHub Enterprise."			
+				ticket with "There is no way to verify an email address in
+				GitHub Enterprise."
 			*/
 			if c.hostName != "" {
 				email.Verified = true
 			}
-			
+
 			if email.Verified && email.Primary {
 				return email.Email, nil
 			}
diff --git a/scripts/gofmt b/scripts/gofmt
new file mode 100755
index 0000000000000000000000000000000000000000..8851bdab865dc2af70131067e420bfc358730fae
--- /dev/null
+++ b/scripts/gofmt
@@ -0,0 +1,7 @@
+#!/bin/bash -e
+
+result=$( go fmt $@ )
+if [[ $result != "" ]]; then
+    >&2 echo "The following files are not formatted correctly: $result"
+    exit 1
+fi