SHELL=cmd

#首行.PHONY命令忽略之前执行命令的结果
.PHONY: all genRpc genApi clean fmt tidy lint cover help

#生成rpc代码
genRpc:
	cd rpc && goctl rpc protoc resource.proto --go_out=./ --go-grpc_out=./ --zrpc_out=.
	
#生成api代码
genApi:
	cd api && goctl api go -api resource.api -dir .

#清理
clean:
	go clean
	rm -f ./api/api ./api/api.exe ./api/logs ./rpc/rpc ./rpc/rpc.exe ./rpc/logs
    
#格式化代码
fmt:
	golines ./
	go fmt ./
	go vet ./
	go fix ./
    
#拉取依赖包
tidy:
	go mod tidy
	
#静态分析
lint:
	golangci-lint run --enable-all
	
#单元测试覆盖率
cover:
	go test -v -covermode=set -coverprofile=cover.out bp.jydev.jianyu360.cn/BaseService/resourceCenter/public/service
	go tool cover -html=cover.out
	
#显示帮助
help:
	@echo "make genRpc 生成rpc代码"
	@echo "make genApi 生成api代码"
	@echo "make clean 清理"
	@echo "make fmt 格式化代码"
	@echo "make tidy 拉取依赖包"
	@echo "make lint 静态分析"
	@echo "make cover 单元测试覆盖率"