go-woo / protoc-gen-ent

Protocol buffer generate ent. No handwritten schema required, they will be generated.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

What is protoc-gen-ent

The protoc-gen-ent can generate ent's schemas.

Why protoc-gen-ent

A project may have services that require or do not require ORM.

For services that do not require ORM, can define them in protobuf.

This will cause handwritten protobuf .proto file is inconsistent with the handwritten ent schema .go file.

If can generate ent's schema .go from protobuf .proto, In this way, all data structs and services will be as consistent as possible.

The protoc-gen-ent is such a tool.

How to use

Can see Makefile.

Can directly:

	go install github.com/go-woo/protoc-gen-ent@latest
	go get entgo.io/ent/cmd/ent
	go run entgo.io/ent/cmd/ent init Todo
	rm ./ent/schema/todo.go

	protoc --proto_path=. \
	       --proto_path=./third_party \
	       --go_out=paths=source_relative:. \
	       ./gent/gent.proto

Todo

  • Enum more detailed handling.

  • Support Value, JSON, Custom ID, Hook.

About

Protocol buffer generate ent. No handwritten schema required, they will be generated.

License:MIT License


Languages

Language:Go 100.0%