2020-02-20 19:25:38 +00:00
|
|
|
BIN="./bin"
|
|
|
|
SRC=$(shell find . -name "*.go")
|
2022-10-09 13:21:38 +00:00
|
|
|
GOPATH=$(shell go env GOPATH)
|
2020-02-20 19:25:38 +00:00
|
|
|
|
2021-02-08 00:08:50 +00:00
|
|
|
ifeq (, $(shell which golangci-lint))
|
2022-10-09 13:21:38 +00:00
|
|
|
$(warning "could not find golangci-lint in PATH, run: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.50.0")
|
2021-02-08 00:08:50 +00:00
|
|
|
endif
|
|
|
|
|
2020-02-20 19:25:38 +00:00
|
|
|
ifeq (, $(shell which richgo))
|
2022-10-09 13:21:38 +00:00
|
|
|
$(warning "could not find richgo in PATH, run: go install github.com/kyoh86/richgo@latest")
|
2020-02-20 19:25:38 +00:00
|
|
|
endif
|
|
|
|
|
2022-03-10 15:19:35 +00:00
|
|
|
.PHONY: fmt lint test install_deps clean
|
2020-02-20 19:25:38 +00:00
|
|
|
|
|
|
|
default: all
|
|
|
|
|
2022-03-10 15:19:35 +00:00
|
|
|
all: fmt test
|
2020-02-20 19:25:38 +00:00
|
|
|
|
|
|
|
fmt:
|
|
|
|
$(info ******************** checking formatting ********************)
|
|
|
|
@test -z $(shell gofmt -l $(SRC)) || (gofmt -d $(SRC); exit 1)
|
|
|
|
|
2021-02-08 00:08:50 +00:00
|
|
|
lint:
|
|
|
|
$(info ******************** running lint tools ********************)
|
|
|
|
golangci-lint run -v
|
|
|
|
|
2021-12-07 23:06:09 +00:00
|
|
|
test: install_deps
|
2020-02-20 19:25:38 +00:00
|
|
|
$(info ******************** running tests ********************)
|
|
|
|
richgo test -v ./...
|
|
|
|
|
|
|
|
install_deps:
|
|
|
|
$(info ******************** downloading dependencies ********************)
|
|
|
|
go get -v ./...
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -rf $(BIN)
|