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.
Actively maintained as of October 2023.
Please find the documentation here.
Additionally, there are several code examples, including a full gRPC/REST/CRUD service.
go install github.com/complex64/protoc-gen-gorm@latest
- Targets Gorm v2 (
gorm.io/gorm) - Generates GORM-compatible model struct types for your message types:
UserModelfor yourUsermessage - Generates methods to convert from proto message to model:
ToModel()on the proto message, andToProto()on the model - Generates CRUD helper methods for rapid and convenient implementation of APIs:
Create(),Get(),List(),Update(),Patch(), andDelete() - 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
Please have a quick look at CONTRIBUTING.md