diff options
author | MalloZup <dmaiocchi@suse.com> | 2017-11-06 11:28:17 +0100 |
---|---|---|
committer | Flavio Castelli <flavio@castelli.me> | 2017-11-07 18:01:07 +0100 |
commit | d3156d4b640c4605dec49fb1c1075d72dc2d7301 (patch) | |
tree | 4b14c209b432fb4e944051bc67e707ad5399d825 | |
parent | 50e585afcc4db913215cd42a7da18aff74d369a1 (diff) | |
download | terraform-provider-libvirt-d3156d4b640c4605dec49fb1c1075d72dc2d7301.tar terraform-provider-libvirt-d3156d4b640c4605dec49fb1c1075d72dc2d7301.tar.gz |
add gofmt check for pkg(libvirt and main)
-rw-r--r-- | .travis.yml | 1 | ||||
-rw-r--r-- | libvirt/utils_domain_def.go | 1 | ||||
-rw-r--r-- | libvirt/utils_libvirt_test.go | 8 | ||||
-rw-r--r-- | travis/gofmtcheck.sh | 30 |
4 files changed, 35 insertions, 5 deletions
diff --git a/.travis.yml b/.travis.yml index 0913bc40..a33675bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,6 +10,7 @@ before_script: - sudo bash ./travis/setup-host - sudo lxc exec libvirt -- bash /code/travis/setup-guest script: + - bash ./travis/gofmtcheck.sh - sudo lxc exec libvirt -- bash /code/travis/run-tests-inside-guest - sudo lxc file pull libvirt/root/go/src/github.com/dmacvicar/terraform-provider-libvirt/profile.cov . - goveralls -coverprofile=profile.cov -service=travis-ci diff --git a/libvirt/utils_domain_def.go b/libvirt/utils_domain_def.go index 2f7f74a6..a712f145 100644 --- a/libvirt/utils_domain_def.go +++ b/libvirt/utils_domain_def.go @@ -34,7 +34,6 @@ func getCanonicalMachineName(caps libvirtxml.Caps, arch string, virttype string, return "", fmt.Errorf("[WARN] Cannot find machine type %s for %s/%s in %v", targetmachine, virttype, arch, caps) } - func getOriginalMachineName(caps libvirtxml.Caps, arch string, virttype string, targetmachine string) (string, error) { guest, err := getGuestForArchType(caps, arch, virttype) if err != nil { diff --git a/libvirt/utils_libvirt_test.go b/libvirt/utils_libvirt_test.go index 38d90136..0f53b6b3 100644 --- a/libvirt/utils_libvirt_test.go +++ b/libvirt/utils_libvirt_test.go @@ -71,11 +71,11 @@ func TestGetCanonicalMachineName(t *testing.T) { virttype := "hvm" machine := "pc" - caps,err := getHostCapabilities(conn) + caps, err := getHostCapabilities(conn) if err != nil { t.Error(err) } - + name, err := getCanonicalMachineName(caps, arch, virttype, machine) if err != nil { @@ -93,7 +93,7 @@ func TestGetOriginalMachineName(t *testing.T) { virttype := "hvm" machine := "pc" - caps,err := getHostCapabilities(conn) + caps, err := getHostCapabilities(conn) if err != nil { t.Error(err) } @@ -117,7 +117,7 @@ func TestGetHostCapabilties(t *testing.T) { start := time.Now() conn := connect(t) defer conn.Close() - caps,err := getHostCapabilities(conn) + caps, err := getHostCapabilities(conn) if err != nil { t.Errorf("Can't get host capabilties") } 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 |