protoc-gen-go_orm

command module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 31, 2022 License: MIT Imports: 5 Imported by: 0

README

protoc-gen-go_orm

CI

Simply generate ORM model from proto

Install

go install github.com/sraphs/protoc-gen-go_orm@latest

Usage

Define your proto file in .proto format.

// internal/testdata/fields.proto
syntax = "proto3";

package testdata;

import "orm/opts.proto";

option go_package = "ent/testdata";

message Pet {
  option (orm.opts).gen = true;
  string name = 1 [(orm.field) = { tag: [ "db", "id", "pk", "autoincrement" ] }];
}

Run protoc to generate .pb.go and _orm.pb.go files.

protoc \
    --proto_path ./internal/testdata \
    --proto_path . \
    --go_out=paths=source_relative:./out \
    --go_orm_out=paths=source_relative:./out \
    ./internal/testdata/fields.proto

This will generate .pb.go and _orm.pb.go files in ./out directory.

// out/fields_orm.pb.go

package testdata

import (
	_ " github.com/sraphs/protoc-gen-go_orm/orm"
)

type PetORM struct {
	Name string `db:"id,pk,autoincrement"`
}

first tag is used as tag key, and other tags are used as tag value.

Contributing

We alway welcome your contributions 👏

  1. Fork the repository
  2. Create Feat_xxx branch
  3. Commit your code
  4. Create Pull Request

CHANGELOG

See Releases

License

MIT © sraph.com

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL