-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
57 lines (49 loc) · 1.49 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
GOPATH:=$(shell go env GOPATH)
ORG_NAME?=ohmygrpc
SERVICE_NAME?=echo
.PHONY: build
## build: build the application(api)
build:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/${SERVICE_NAME}.linux.amd64 cmd/main.go
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/${SERVICE_NAME}.linux.arm64 cmd/main.go
CGO_ENABLED=0 go build -a -installsuffix cgo -ldflags="-w -s" -o bin/${SERVICE_NAME} cmd/main.go
.PHONY: run
## run: run the application(api)
run:
go run -v -race cmd/main.go
.PHONY: format
## format: format files
format:
@go get golang.org/x/tools/cmd/goimports
goimports -local github.com/${ORG_NAME} -w .
gofmt -s -w .
go mod tidy
.PHONY: test
## test: run tests
test:
@go get github.com/rakyll/gotest
gotest -p 1 -race -cover -v ./...
.PHONY: coverage
## coverage: run tests with coverage
coverage:
@go get github.com/rakyll/gotest
gotest -p 1 -race -coverprofile=coverage.txt -covermode=atomic -v ./...
.PHONY: lint
## lint: check everything's okay
lint:
@go get github.com/kyoh86/scopelint
golangci-lint run ./...
scopelint --set-exit-status ./...
go mod verify
.PHONY: generate
## generate: generate source code for mocking
generate:
@go get golang.org/x/tools/cmd/stringer
@go get github.com/golang/mock/gomock
@go install github.com/golang/mock/mockgen
go generate ./...
.PHONY: help
## help: prints this help message
help:
@echo "Usage: \n"
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':'