# go-zero 生成風格 GO_ZERO_STYLE=go_zero GO ?= go GOFMT ?= gofmt "-s" GOFILES := $(shell find . -name "*.go") LDFLAGS := -s -w VERSION="v0.0.1" DOCKER_REPO="reg.wang/app-cloudep-product-service" .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/product.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: build-docker build-docker: cp ./build/Dockerfile Dockerfile docker buildx build -t $(DOCKER_REPO):$(VERSION) --build-arg SSH_PRIVATE_KEY="$(cat ~/.ssh/id_ed25519)" . rm -rf Dockerfile @echo "Generate core-api files successfully" .PHONY: mock-gen mock-gen: # 建立 mock 資料 #mockgen -source=./pkg/domain/repository/token.go -destination=./pkg/mock/repository/token.go -package=mock @echo "Generate mock files successfully"