diff --git a/.golangci.toml b/.golangci.toml new file mode 100644 index 0000000..b465f03 --- /dev/null +++ b/.golangci.toml @@ -0,0 +1,40 @@ +[run] + deadline = "2m" + skip-files = [] + +[linters-settings] + + [linters-settings.govet] + check-shadowing = true + + [linters-settings.gocyclo] + min-complexity = 12.0 + + [linters-settings.maligned] + suggest-new = true + + [linters-settings.goconst] + min-len = 3.0 + min-occurrences = 3.0 + + [linters-settings.misspell] + locale = "US" + +[linters] + enable-all = true + disable = [ + "maligned", + "lll", + "gas", + "dupl", + "prealloc", + "scopelint", + ] + +[issues] + exclude-use-default = false + max-per-linter = 0 + max-same = 0 + exclude = [ + "`(version|commit|date)` is a global variable", # version.go + ] diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..f550073 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,31 @@ +language: go + +go: + - 1.11.x + - 1.x + +sudo: false + +env: + - GO111MODULE=on + +notifications: + email: + on_success: never + on_failure: change + +before_install: + # Install linters and misspell + - curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b $GOPATH/bin v1.12.5 + - golangci-lint --version + +install: + - echo "TRAVIS_GO_VERSION=$TRAVIS_GO_VERSION" + +deploy: + - provider: script + skip_cleanup: true + script: curl -sL https://git.io/goreleaser | bash + on: + tags: true + condition: $TRAVIS_GO_VERSION =~ ^1\.x$ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8f91d03 --- /dev/null +++ b/Makefile @@ -0,0 +1,22 @@ +.PHONY: default clean checks test build + +TAG_NAME := $(shell git tag -l --contains HEAD) +SHA := $(shell git rev-parse --short HEAD) +VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA)) + +BUILD_DATE := $(shell date -u '+%Y-%m-%d_%I:%M:%S%p') + +default: clean checks test build + +test: clean + go test -v -cover ./... + +clean: + rm -rf dist/ cover.out + +build: clean + @echo Version: $(VERSION) $(BUILD_DATE) + go build -v -ldflags '-X "main.version=${VERSION}" -X "main.commit=${SHA}" -X "main.date=${BUILD_DATE}"' + +checks: + golangci-lint run