diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..0f3a70a --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,17 @@ +linters: + enable: + - gofmt + - gosec + - unconvert + - misspell + - goimports + - megacheck + - staticcheck + - unused + - deadcode + - typecheck + - ineffassign + - golint + - stylecheck + - unparam + - nakedret diff --git a/.travis.yml b/.travis.yml index 25d6fb4..e96d0c5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,13 +1,16 @@ -dist: trusty +dist: xenial sudo: false language: go go: - - 1.10.x - 1.11.x + - 1.12.x - master +before_install: + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.16.0 + matrix: allow_failures: - go: master diff --git a/Makefile b/Makefile index b57f39a..30ccbe0 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,19 @@ all: test check bench +.PHONY: deps deps: go get -v -d -t ./... - go get -v github.com/alecthomas/gometalinter - gometalinter --install +.PHONY: test test: deps go test -race -v -coverprofile=coverage.txt -covermode=atomic +.PHONY: bench bench: deps go test -v -bench . -benchmem -run nothing ./... +.PHONY: check check: deps - go test -i - gometalinter --vendored-linters --deadline=30s --cyclo-over=15 ./... + golangci-lint run .PHONY: deps bench test check diff --git a/client.go b/client.go index f9fed5d..ffaaa80 100644 --- a/client.go +++ b/client.go @@ -154,7 +154,7 @@ func (c *Client) GetLostPackets() int64 { // // Often used to note a particular event, for example incoming web request. func (c *Client) Incr(stat string, count int64, tags ...Tag) { - if 0 != count { + if count != 0 { c.trans.bufLock.Lock() lastLen := len(c.trans.buf) @@ -185,7 +185,7 @@ func (c *Client) Decr(stat string, count int64, tags ...Tag) { // FIncr increments a float counter metric func (c *Client) FIncr(stat string, count float64, tags ...Tag) { - if 0 != count { + if count != 0 { c.trans.bufLock.Lock() lastLen := len(c.trans.buf) diff --git a/statsd.go b/statsd.go index d6533f3..e446815 100644 --- a/statsd.go +++ b/statsd.go @@ -59,7 +59,7 @@ For every metric sent, tags could be added as the last argument(s) to the functi call: client.Incr("request", 1, - statsd.StringTag("procotol", "http"), statsd.IntTag("port", 80)) + statsd.StringTag("protocol", "http"), statsd.IntTag("port", 80)) */ package statsd