Add Makefile
This commit is contained in:
parent
7d304729b4
commit
28b31068cd
|
|
@ -10,4 +10,5 @@ matrix:
|
|||
- go: tip
|
||||
|
||||
script:
|
||||
- ./ci.sh
|
||||
# TODO: change to "make" when golint, errcheck, staticcheck pass
|
||||
- make checkgofmt vet unused test
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
SRCS := $(shell find . -name '*.go')
|
||||
PKGS := $(shell go list ./...)
|
||||
|
||||
.PHONY: all
|
||||
all: lint test
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
go install $(PKGS)
|
||||
|
||||
.PHONY: golint
|
||||
golint:
|
||||
go get github.com/golang/lint/golint
|
||||
for file in $(SRCS); do \
|
||||
golint $${file}; \
|
||||
if [ -n "$$(golint $${file})" ]; then \
|
||||
exit 1; \
|
||||
fi; \
|
||||
done
|
||||
|
||||
.PHONY: checkgofmt
|
||||
checkgofmt:
|
||||
gofmt -s -l $(SRCS)
|
||||
if [ -n "$$(gofmt -s -l $(SRCS))" ]; then \
|
||||
exit 1; \
|
||||
fi
|
||||
|
||||
.PHONY: vet
|
||||
vet:
|
||||
go vet $(PKGS)
|
||||
|
||||
.PHONY:
|
||||
errcheck:
|
||||
go get github.com/kisielk/errcheck
|
||||
errcheck $(PKGS)
|
||||
|
||||
.PHONY: staticcheck
|
||||
staticcheck:
|
||||
@go get honnef.co/go/tools/cmd/staticcheck
|
||||
staticcheck $(PKGS)
|
||||
|
||||
.PHONY: unused
|
||||
unused:
|
||||
@go get honnef.co/go/tools/cmd/unused
|
||||
unused $(PKGS)
|
||||
|
||||
.PHONY: lint
|
||||
lint: golint checkgofmt vet errcheck staticcheck unused
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
go test -race $(PKGS)
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
go clean -i $(PKGS)
|
||||
Loading…
Reference in New Issue