From a02c813784a784c1bd14f0379f8e275e11d643ba Mon Sep 17 00:00:00 2001 From: Dan Sosedoff Date: Fri, 16 Mar 2018 19:59:58 -0500 Subject: [PATCH] Check files with go fmt in CI --- .travis.yml | 1 + script/check_formatting.sh | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100755 script/check_formatting.sh diff --git a/.travis.yml b/.travis.yml index 9a20e18..d61829f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ env: - GO15VENDOREXPERIMENT=1 before_install: + - ./script/check_formatting.sh - ./script/check_assets.sh install: diff --git a/script/check_formatting.sh b/script/check_formatting.sh new file mode 100755 index 0000000..e064638 --- /dev/null +++ b/script/check_formatting.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +files="$(go fmt ./...)" +ignore="pkg/data/bindata.go" +files=${files[@]/$ignore} + +if [ -n "$files" ]; then + echo "Go code is not formatted: $files" + for file in $files; do + echo "----> $file" + done + exit 1 +fi \ No newline at end of file