-
Notifications
You must be signed in to change notification settings - Fork 34
/
Makefile
58 lines (50 loc) · 1.52 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
PACKAGE := $(shell go list)
GOOS := $(shell go env GOOS)
GOARCH = $(shell go env GOARCH)
OBJ_DIR := $(GOPATH)/pkg/$(GOOS)_$(GOARCH)/$(PACKAGE)
GO_VERSION_MINOR := $(shell go version | sed -E 's/.*go([0-9]\.[0-9]+).*/\1/g')
TRAVIS_GO_VERSION ?= $(GO_VERSION_MINOR).x
GOLANGCI_LINT_1.9.x := v1.10.2
GOLANGCI_LINT_1.10.x := v1.15.0
GOLANGCI_LINT_1.11.x := v1.17.1
GOLANGCI_LINT_1.12.x := v1.21.0
GOLANGCI_LINT_1.13.x := v1.21.0
GOLANGCI_LINT_tip := v1.21.0
GOLANGCI_LINT := ${GOLANGCI_LINT_${TRAVIS_GO_VERSION}}
ifeq ($(GOLANGCI_LINT),)
GOLANGCI_LINT := $(GOLANGCI_LINT_tip)
endif
# Linter
.PHONY: lint-prepare
lint-prepare:
@echo "Installing golangci-lint $(GOLANGCI_LINT)"
@[ -d $(GOPATH)/bin ] || mkdir -p $(GOPATH)/bin
@curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin $(GOLANGCI_LINT)
.PHONY: lint
lint:
@golangci-lint run \
--exclude-use-default=false \
--enable=golint \
--enable=gocyclo \
--enable=goconst \
--enable=unconvert \
--exclude='^Error return value of `.*\.Log` is not checked$$' \
--exclude='^G104: Errors unhandled\.$$' \
--exclude='^G304: Potential file inclusion via variable$$' \
./...
# Testing
.PHONY: test
test:
@go test $(TEST_OPTS) github.com/uudashr/gopkgs/v2
.PHONY: bench
bench:
@go test -run=none -bench=. -benchmem
# Build and Installation
.PHONY: install
install:
@go install ./...
.PHONY: uninstall
uninstall:
@echo "Removing binaries and libraries"
@go clean -i ./...
@if [ -d $(OBJ_DIR) ]; then rm -rf $(OBJ_DIR); fi