summaryrefslogtreecommitdiff
path: root/travis
diff options
context:
space:
mode:
authorMalloZup <dmaiocchi@suse.com>2017-11-06 11:28:17 +0100
committerFlavio Castelli <flavio@castelli.me>2017-11-07 18:01:07 +0100
commitd3156d4b640c4605dec49fb1c1075d72dc2d7301 (patch)
tree4b14c209b432fb4e944051bc67e707ad5399d825 /travis
parent50e585afcc4db913215cd42a7da18aff74d369a1 (diff)
downloadterraform-provider-libvirt-d3156d4b640c4605dec49fb1c1075d72dc2d7301.tar
terraform-provider-libvirt-d3156d4b640c4605dec49fb1c1075d72dc2d7301.tar.gz
add gofmt check for pkg(libvirt and main)
Diffstat (limited to 'travis')
-rw-r--r--travis/gofmtcheck.sh30
1 files changed, 30 insertions, 0 deletions
diff --git a/travis/gofmtcheck.sh b/travis/gofmtcheck.sh
new file mode 100644
index 00000000..d7d7aef6
--- /dev/null
+++ b/travis/gofmtcheck.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+
+set -e
+GOPKG="libvirt"
+
+lint_pkg () {
+ cd $1
+ echo "*** checking pkg $1 with gofmt"
+ if [ -n "$(go fmt ./...)" ]; then
+ echo "Go code on pkg $1 is not formatted well, run 'go fmt on pkg $1'"
+ exit 1
+ fi
+ echo " pkg $1 has no lint gofmt errors!"
+ cd ..
+}
+
+lint_main () {
+ echo '*** running gofmt on main.go'
+ if [ -n "$(go fmt main.go)" ]; then
+ echo "Go code on main.go is not formatted, please run 'go fmt main.go'"
+ exit 1
+ fi
+}
+
+echo "==> Checking that code complies with gofmt requirements..."
+lint_pkg $GOPKG
+echo
+lint_main
+echo '==> go fmt OK !!! ***'
+exit 0