protoc-gen-gorm
![Go Reference](https://pkg.go.dev/badge/github.com/complex64/protoc-gen-gorm.svg)
Generate GORM v2 Models and APIs from your .proto files.
protoc-gen-gorm
is a plugin for protoc (or buf), a Protocol Buffer ("proto") compiler.
Under active development as of January 2023.
Used in production at GameAnalytics in 2022.
Please find the documentation here.
Additionally, there are several code examples, including a full gRPC/REST/CRUD service.
Install
go install github.com/complex64/protoc-gen-gorm@latest
Features
- Targets Gorm v2 (
gorm.io/gorm
)
- Generates GORM-compatible model struct types for your message types:
UserModel
for your User
message
- Generates methods to convert from proto message to model:
ToModel()
on the proto message, and ToProto()
on the model
- Generates CRUD helper methods for rapid and convenient implementation of APIs:
Create()
, Get()
, List()
, Update()
, Patch()
, and Delete()
- Can encode fields as JSON strings when instructed to
Additionally:
- All features are covered by tests
- Minimal external dependencies
Planned Features:
- Support for record lifecycle hooks (on demand)
- Support for associations
- Support for custom types
- Support for database-specific types
- Support for embedded structs
- Code examples
- Helpful code comments
- Comments on generated code
Contributing
Please have a quick look at CONTRIBUTING.md