# Custom configuration | 独立配置 # Service name | 项目名称 SERVICE=core FILE_SERVICE=file TEMPLATE_REMOTE=https://git.noahlan.cn/noahlan/goctls-template.git TEMPLATE_BRANCH=v1.5.17 TEMPLATE_HOME=./doc # The project version, if you don't use git, you should set it manually | 项目版本,如果不使用git请手动设置 # VERSION=$(shell git describe --tags --always) VERSION=1.0.0 # The project file name style | 项目文件命名风格 PROJECT_STYLE=go_zero # Whether to use i18n | 是否启用 i18n PROJECT_I18N=false # Swagger type, support yml,json | Swagger 文件类型,支持yml,json SWAGGER_TYPE := yml # Ent enabled features | Ent 启用的官方特性 ENT_FEATURE=sql/execquery,sql/modifier,sql/upsert,intercept # ---- You may not need to modify the codes below | 下面的代码大概率不需要更改 ---- GO ?= go GOFMT ?= gofmt "-s" GOFILES := $(shell find . -name "*.go") LDFLAGS := -s -w # Generate .PHONY: gen-api gen-api: # Generate API files | 生成 API 的代码 goctls api go --api ./api/desc/all.api \ --dir ./api \ --trans_err=true \ --remote $(TEMPLATE_REMOTE) swagger generate spec --output=./n-admin-server.$(SWAGGER_TYPE) --scan-models @echo "Generate API files successfully" .PHONY: gen-rpc gen-rpc: # Generate RPC files from proto | 生成 RPC 的代码 goctls rpc protoc ./rpc/$(SERVICE)/$(SERVICE).proto \ --style=$(PROJECT_STYLE) \ --go_out=./rpc/$(SERVICE)/types \ --go-grpc_out=./rpc/$(SERVICE)/types \ --zrpc_out=./rpc/$(SERVICE) \ --remote $(TEMPLATE_REMOTE) \ --branch $(TEMPLATE_BRANCH) @echo "Generate RPC files successfully" .PHONY: gen-rpc-file gen-rpc-file: # Generate RPC files from proto | 生成 RPC 的代码 goctls rpc protoc ./rpc/$(FILE_SERVICE)/$(FILE_SERVICE).proto \ --style=$(PROJECT_STYLE) \ --go_out=./rpc/$(FILE_SERVICE)/types \ --go-grpc_out=./rpc/$(FILE_SERVICE)/types \ --zrpc_out=./rpc/$(FILE_SERVICE) \ --remote $(TEMPLATE_REMOTE) \ --branch $(TEMPLATE_BRANCH) @echo "Generate RPC files successfully" .PHONY: gen-ent gen-ent: # Generate Ent codes | 生成 Ent 的代码 go run -mod=mod entgo.io/ent/cmd/ent generate \ --feature $(ENT_FEATURE) \ --template glob="./doc/ent/template/*.tmpl" \ ./rpc/$(SERVICE)/ent/schema @echo "Generate Ent files successfully"