Skip to content

Commit

Permalink
feat: add Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
fifsky committed Jul 27, 2023
1 parent e17733d commit 6cccb0e
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
GO ?= go
GOFMT ?= gofmt "-s"
GOFILES := $(shell find . -name "*.go" -type f -not -path "./vendor/*")
VETPACKAGES ?= $(shell $(GO) list ./... | grep -v /vendor/ | grep -v /examples/)

.PHONY: build
build: fmt-check
$(GO) build -o app main.go

.PHONY: test
test:
$(GO) test -v -coverprofile=cover.out ./...

.PHONY: cover
cover:
$(GO) tool cover -func=cover.out -o cover_total.out
$(GO) tool cover -html=cover.out -o cover.html

.PHONY: fmt
fmt:
$(GOFMT) -w $(GOFILES)

.PHONY: fmt-check
fmt-check:
@diff=$$($(GOFMT) -d $(GOFILES)); \
if [ -n "$$diff" ]; then \
echo "Please run 'make fmt' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi; \
echo "\033[34m[Code] format perfect!\033[0m";

vet:
$(GO) vet $(VETPACKAGES)

.PHONY: lint
lint:
golangci-lint run

0 comments on commit 6cccb0e

Please sign in to comment.