Skip to content

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

License

Notifications You must be signed in to change notification settings

go-woo/protoc-gen-ent

Repository files navigation

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages