From a651b4da806807ea6dc9a03835adf02e5a96c627 Mon Sep 17 00:00:00 2001 From: Julian Kornberger <jk+github@digineo.de> Date: Sat, 29 Dec 2018 17:13:18 +0100 Subject: [PATCH] Check gofmt during CI build --- .circleci/check-gofmt | 10 ++++++++++ .circleci/config.yml | 1 + 2 files changed, 11 insertions(+) create mode 100755 .circleci/check-gofmt diff --git a/.circleci/check-gofmt b/.circleci/check-gofmt new file mode 100755 index 00000000..b9c4731e --- /dev/null +++ b/.circleci/check-gofmt @@ -0,0 +1,10 @@ +#!/bin/bash + +result="$(gofmt -e -s -l . 2>&1 | grep -v '^vendor/' )" +if [ -n "$result" ]; then + echo "Go code is not formatted, run 'gofmt -e -s -w .'" >&2 + echo "$result" + exit 1 +else + echo "Go code is formatted well" +fi diff --git a/.circleci/config.yml b/.circleci/config.yml index c5af3d3e..62904d8b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -18,3 +18,4 @@ jobs: - run: go test -v -cover -coverprofile=coverage.out ./... - run: goveralls -coverprofile=coverage.out -service=circle-ci -repotoken=$COVERALLS_TOKEN - run: .circleci/build-examples + - run: .circleci/check-gofmt -- GitLab