-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (42 loc) · 1.13 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
BINARY_NAME=lazyalias
MAIN_PATH=./cmd/lazyalias/main.go
COVERAGE_FILE=coverage.out
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOMOD=$(GOCMD) mod
GOGET=$(GOCMD) get
GORUN=$(GOCMD) run
UNAME_S := $(shell uname -s)
.PHONY: all build test coverage lint clean deps tidy install-lint
install-lint:
ifeq ($(UNAME_S),Darwin)
@if ! command -v golangci-lint >/dev/null 2>&1; then \
brew install golangci-lint; \
fi
else ifeq ($(UNAME_S),Linux)
@if ! command -v golangci-lint >/dev/null 2>&1; then \
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.56.2; \
fi
else
@echo "Por favor, instala golangci-lint manualmente desde https://golangci-lint.run/usage/install/"
endif
build:
$(GOBUILD) -ldflags="-w -s" -o bin/$(BINARY_NAME) $(MAIN_PATH)
run:
$(GORUN) $(MAIN_PATH)
test:
$(GOTEST) -v ./...
coverage:
$(GOTEST) -coverprofile=$(COVERAGE_FILE) ./...
$(GOCMD) tool cover -html=$(COVERAGE_FILE)
lint: install-lint
golangci-lint run
clean:
rm -f $(BINARY_NAME)
rm -f $(COVERAGE_FILE)
deps:
$(GOGET) -v -t -d ./...
tidy:
$(GOMOD) tidy
all: lint test build