You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
kratos/examples/blog/Makefile

65 lines
1.7 KiB

GOPATH:=$(shell go env GOPATH)
VERSION=$(shell git describe --tags --always)
PROTO_FILES=$(shell find . -name *.proto)
KRATOS_VERSION=$(shell go mod graph |grep go-kratos/kratos/v2 |head -n 1 |awk -F '@' '{print $$2}')
KRATOS=$(GOPATH)/pkg/mod/github.com/go-kratos/kratos/v2@$(KRATOS_VERSION)
.PHONY: init
init:
go get -u github.com/go-kratos/kratos/cmd/kratos/v2
go get -u github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2
go get -u github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2
go get -u google.golang.org/protobuf/cmd/protoc-gen-go
go get -u google.golang.org/grpc/cmd/protoc-gen-go-grpc
.PHONY: proto
# generate proto
proto:
protoc --proto_path=. \
--proto_path=$(KRATOS)/api \
--proto_path=$(KRATOS)/third_party \
--proto_path=$(GOPATH)/src \
--go_out=paths=source_relative:. \
--go-grpc_out=paths=source_relative:. \
--go-http_out=paths=source_relative:. \
--go-errors_out=paths=source_relative:. $(PROTO_FILES)
.PHONY: validate
# generate pb validate for proto
validate:
protoc --proto_path=. \
--proto_path=$(KRATOS)/third_party \
--go_out=paths=source_relative:. \
--validate_out="lang=go:." \
$(PROTO_FILES)
.PHONY: swagger
# generate swagger file
swagger:
protoc --proto_path=. \
--proto_path=$(KRATOS)/third_party \
--openapiv2_out . \
--openapiv2_opt logtostderr=true \
$(PROTO_FILES)
.PHONY: run
run:
cd cmd/blog/ && go run .
.PHONY: ent
ent:
cd internal/data/ && ent generate ./ent/schema
.PHONY: generate
generate:
go generate ./...
.PHONY: build
build:
mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin/ ./...
.PHONY: test
test:
go test -v ./... -cover