Skip to content

complex64/protoc-gen-gorm

Repository files navigation

protoc-gen-gorm

Tests Linters Go Report Card Maintainability Go Reference

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.

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