54 lines
1.8 KiB
Makefile
54 lines
1.8 KiB
Makefile
# go-zero 生成風格
|
|
GO_ZERO_STYLE=go_zero
|
|
GO ?= go
|
|
GOFMT ?= gofmt "-s"
|
|
GOFILES := $(shell find . -name "*.go")
|
|
LDFLAGS := -s -w
|
|
VERSION="v1.0.4"
|
|
DOCKER_REPO="igs170911/member"
|
|
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
|
|
|
|
.PHONY: test
|
|
test: # 進行測試
|
|
go test -v --cover ./...
|
|
|
|
.PHONY: fmt
|
|
fmt: # 格式優化
|
|
$(GOFMT) -w $(GOFILES)
|
|
goimports -w ./
|
|
golangci-lint run
|
|
|
|
.PHONY: gen-rpc
|
|
gen-rpc: # 建立 rpc code
|
|
goctl rpc protoc ./generate/protobuf/member.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
|
|
go mod tidy
|
|
@echo "Generate core-api files successfully"
|
|
|
|
.PHONY: run-docker
|
|
run-docker: # 建立 rpc code
|
|
docker run --platform=linux/arm64/v8 -p 8080:8080 $(DOCKER_REPO):$(VERSION)
|
|
|
|
.PHONY: build-docker
|
|
build-docker:
|
|
cp ./build/Dockerfile Dockerfile
|
|
docker buildx build \
|
|
-t $(DOCKER_REPO):$(VERSION) \
|
|
--build-arg VERSION=$(VERSION) \
|
|
--build-arg GIT_COMMIT=$(GIT_COMMIT) \
|
|
--secret id=ssh_key,src=./build/id_ed25519 \
|
|
--progress=plain .
|
|
rm -rf Dockerfile
|
|
@echo "Generate core-api files successfully"
|
|
|
|
|
|
.PHONY: mock-gen
|
|
mock-gen: # 建立 mock 資料
|
|
mockgen -source=./pkg/domain/repository/account.go -destination=./pkg/mock/repository/account.go -package=mock
|
|
mockgen -source=./pkg/domain/repository/account_uid.go -destination=./pkg/mock/repository/account_uid.go -package=mock
|
|
mockgen -source=./pkg/domain/repository/auto_id.go -destination=./pkg/mock/repository/auto_id.go -package=mock
|
|
mockgen -source=./pkg/domain/repository/user.go -destination=./pkg/mock/repository/user.go -package=mock
|
|
mockgen -source=./pkg/domain/repository/verify_code.go -destination=./pkg/mock/repository/verify_code.go -package=mock
|
|
mockgen -source=./pkg/domain/usecase/generate_uid.go -destination=./pkg/mock/usecase/generate_uid.go -package=mock
|
|
|
|
@echo "Generate mock files successfully"
|