Skip to content

Commit

Permalink
Run go fmt in CI
Browse files Browse the repository at this point in the history
  • Loading branch information
sparrc committed Oct 16, 2015
1 parent 0986caf commit 97d4f9e
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
22 changes: 11 additions & 11 deletions plugins/nginx/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ func TestNginxGeneratesMetrics(t *testing.T) {
panic(err)
}

host, port, err := net.SplitHostPort(addr.Host)
if err != nil {
host = addr.Host
if addr.Scheme == "http" {
port = "80"
} else if addr.Scheme == "https" {
port = "443"
} else {
port = ""
}
}
host, port, err := net.SplitHostPort(addr.Host)
if err != nil {
host = addr.Host
if addr.Scheme == "http" {
port = "80"
} else if addr.Scheme == "https" {
port = "443"
} else {
port = ""
}
}

tags := map[string]string{"server": host, "port": port}

Expand Down
2 changes: 1 addition & 1 deletion plugins/postgresql/postgresql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestPostgresqlGeneratesMetrics(t *testing.T) {
}

assert.True(t, metricsCounted > 0)
assert.Equal(t, len(availableColumns) - len(p.IgnoredColumns()), metricsCounted)
assert.Equal(t, len(availableColumns)-len(p.IgnoredColumns()), metricsCounted)
}

func TestPostgresqlTagsMetricsWithDatabaseName(t *testing.T) {
Expand Down
12 changes: 12 additions & 0 deletions scripts/circle-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ function exit_if_fail {
fi
}

# Check that go fmt has been run.
function check_go_fmt {
fmtcount=`git ls-files | grep '.go$' | grep -v Godep | xargs gofmt -l 2>&1 | wc -l`
if [ $fmtcount -gt 0 ]; then
echo "run 'go fmt ./...' to format your source code."
exit 1
fi
}

# build takes three arguments: GOOS & GOARCH & VERSION
function build {
echo -n "=> $1-$2: "
Expand Down Expand Up @@ -53,6 +62,9 @@ echo "\$CIRCLE_BRANCH: $CIRCLE_BRANCH"
exit_if_fail mv $HOME/telegraf $GOPATH/src/github.com/influxdb
exit_if_fail cd $GOPATH/src/github.com/influxdb/telegraf

# Verify that go fmt has been run
check_go_fmt

# Install the code
exit_if_fail godep go build -v ./...
exit_if_fail godep go install -v ./...
Expand Down
2 changes: 1 addition & 1 deletion testutil/accumulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package testutil
import (
"fmt"
"reflect"
"time"
"sync"
"time"
)

// Point defines a single point measurement
Expand Down

0 comments on commit 97d4f9e

Please sign in to comment.