67 lines
2.5 KiB
Makefile
67 lines
2.5 KiB
Makefile
GO_CTL_NAME=goctl
|
|
|
|
# go-zero 生成風格
|
|
GO_ZERO_STYLE=go_zero
|
|
|
|
GO ?= go
|
|
GOFMT ?= gofmt "-s"
|
|
GOFILES := $(shell find . -name "*.go")
|
|
LDFLAGS := -s -w
|
|
VERSION="v1.0.3"
|
|
DOCKER_REPO="igs170911/notification"
|
|
|
|
.PHONY: test
|
|
test: # 進行測試
|
|
go test -v --cover ./...
|
|
|
|
.PHONY: fmt
|
|
fmt: # 格式優化
|
|
$(GOFMT) -w $(GOFILES)
|
|
goimports -w ./
|
|
|
|
.PHONY: gen-rpc
|
|
gen-rpc: # 建立 rpc code
|
|
$(GO_CTL_NAME) rpc protoc ./generate/protobuf/service.proto -m --style=$(GO_ZERO_STYLE) --go_out=./gen_result/pb --go-grpc_out=./gen_result/pb --zrpc_out=.
|
|
copy ./etc/service.yaml ./etc/service.example.yaml
|
|
go mod tidy
|
|
@echo "Generate core-api files successfully"
|
|
|
|
.PHONY: gen-clean
|
|
gen-clean: # 建立 rpc code
|
|
rm -rf ./client
|
|
rm -rf ./etc
|
|
rm -rf ./gen_result
|
|
rm -rf ./internal
|
|
rm -rf go.mod
|
|
rm -rf go.sum
|
|
rm -rf service.go
|
|
@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 SSH_PRIVATE_KEY="$(cat ~/.ssh/ed_25519)" .
|
|
rm -rf Dockerfile
|
|
@echo "Generate core-api files successfully"
|
|
|
|
.PHONY: gen-model
|
|
gen-model: # 建立 rpc 資料庫
|
|
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_account_table.up.sql --style go_zero -d ./internal/model -i ''
|
|
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_account_uid_table.up.sql --style go_zero -d ./internal/model -i ''
|
|
goctl model mysql ddl -c no -s ./generate/database/mysql/20230529020011_user_table.up.sql --style go_zero -d ./internal/model -i ''
|
|
goctl model mysql ddl -c no -s ./generate/database/mysql/20230719061241_machine_node.up.sql --style go_zero -d ./internal/model -i ''
|
|
@echo "Generate model files successfully"
|
|
# 只產生 Model 剩下的要自己撰寫,連欄位名稱也是
|
|
goctl model mongo -t AutoId -c --dir ./internal/model/mongo --style go_zero
|
|
|
|
#goctl model mysql ddl -s ./generate/database/mysql/20240819090248_create_role_permission_table.up.sql --style go_zero -d ./internal/model -i '' (沒cache)
|
|
#goctl model mysql ddl -c no -s ./generate/database/mysql/20240816014305_create_permission_table.up.sql --style go_zero -d ./internal/model -i '' (有cache)
|
|
|
|
#.PHONY: mock-gen
|
|
#mock-gen: # 建立 mock 資料
|
|
# mockgen -source=./order.go -destination=../../repository/mock/order.go -package=mock
|
|
# @echo "Generate model files successfully"
|