protox

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2026 License: BSD-2-Clause Imports: 11 Imported by: 0

README

protox

Usage

1. Copy protox.proto files.

Add the protox.proto into your proto folder. The folder includes by folder configured in inputs section in buf.yaml

proto_directory/
  \_ protox/
     \_ protox.proto
2. Import protox.proto in your on .proto file.
syntax = "proto3";

package test;

import "protox.proto";
Use field and message descripters
message Test {
  // ignore the field in json marshal and unmarshal
  int64 id = 1 [(protox.gojson) = '-'];
  // json name is 'NAME', and only used to marshal into json, but can not unmarshal from json
  optional string name   = 2 [(protox.gojson) = "NAME,readonly"];
  // json name is '_public', and only used to unmarshal from json, but can not marshal into json
  optional string Public = 3 [(protox.gojson) = "_public,writeonly"];

  // command fields
  string publicId = 5;
  string type = 8; 
  string description = 9;
  int64 projectId = 11;
  // protox.Timestamp will be marshaled into a timestamp integer in seconds
  protox.Timestamp createTime = 12;

  // this strutcure will be serialized into json while being inserted into database
  // the json serializer will ignore the (protox.gojson) option defined above.
  option (protox.gosql) = {
    serializer: "json"
  };
  // custom a golang method for structure
  option (protox.gomethod) = {
    name  : "Table",
    return: "Test"
  };
}

3. Use protox plugin in buf.yaml
go install github.com/cloudfly/protoxy/cmd/protox@latest
plugins:
  - local: protox
    out: gen
    opt: 
      - paths=source_relative
      - out=gen

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// optional protox.GoMethodOption gomethod = 78901;
	E_Gomethod = &file_protox_proto_extTypes[0]
	// optional protox.SQLOption gosql = 78902;
	E_Gosql = &file_protox_proto_extTypes[1]
)

Extension fields to descriptorpb.MessageOptions.

View Source
var (
	// optional string gojson = 78902;
	E_Gojson = &file_protox_proto_extTypes[2]
	// optional protox.OrmxOption ormx = 78903;
	E_Ormx = &file_protox_proto_extTypes[3]
)

Extension fields to descriptorpb.FieldOptions.

View Source
var (
	// optional string goerror = 78903;
	E_Goerror = &file_protox_proto_extTypes[4]
)

Extension fields to descriptorpb.EnumValueOptions.

View Source
var File_protox_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type GoMethodOption

type GoMethodOption struct {
	Name   string  `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Return *string `protobuf:"bytes,2,opt,name=return,proto3,oneof" json:"return,omitempty"`
	// contains filtered or unexported fields
}

func (*GoMethodOption) Descriptor deprecated

func (*GoMethodOption) Descriptor() ([]byte, []int)

Deprecated: Use GoMethodOption.ProtoReflect.Descriptor instead.

func (*GoMethodOption) GetName

func (x *GoMethodOption) GetName() string

func (*GoMethodOption) GetReturn

func (x *GoMethodOption) GetReturn() string

func (*GoMethodOption) ProtoMessage

func (*GoMethodOption) ProtoMessage()

func (*GoMethodOption) ProtoReflect

func (x *GoMethodOption) ProtoReflect() protoreflect.Message

func (*GoMethodOption) Reset

func (x *GoMethodOption) Reset()

func (*GoMethodOption) String

func (x *GoMethodOption) String() string

type OrmxOption added in v0.0.6

type OrmxOption struct {
	Column  string  `protobuf:"bytes,78901,opt,name=column,proto3" json:"column,omitempty"`
	Insert  *bool   `protobuf:"varint,78902,opt,name=insert,proto3,oneof" json:"insert,omitempty"`
	Select  *bool   `protobuf:"varint,78903,opt,name=select,proto3,oneof" json:"select,omitempty"`
	Update  *bool   `protobuf:"varint,78904,opt,name=update,proto3,oneof" json:"update,omitempty"`
	Type    *string `protobuf:"bytes,78910,opt,name=type,proto3,oneof" json:"type,omitempty"`
	Operate *string `protobuf:"bytes,78911,opt,name=operate,proto3,oneof" json:"operate,omitempty"`
	Incr    *int32  `protobuf:"varint,78912,opt,name=incr,proto3,oneof" json:"incr,omitempty"`
	Desr    *int32  `protobuf:"varint,78913,opt,name=desr,proto3,oneof" json:"desr,omitempty"`
	// contains filtered or unexported fields
}

func (*OrmxOption) Descriptor deprecated added in v0.0.6

func (*OrmxOption) Descriptor() ([]byte, []int)

Deprecated: Use OrmxOption.ProtoReflect.Descriptor instead.

func (*OrmxOption) GetColumn added in v0.0.6

func (x *OrmxOption) GetColumn() string

func (*OrmxOption) GetDesr added in v0.0.6

func (x *OrmxOption) GetDesr() int32

func (*OrmxOption) GetIncr added in v0.0.6

func (x *OrmxOption) GetIncr() int32

func (*OrmxOption) GetInsert added in v0.0.6

func (x *OrmxOption) GetInsert() bool

func (*OrmxOption) GetOperate added in v0.0.6

func (x *OrmxOption) GetOperate() string

func (*OrmxOption) GetSelect added in v0.0.6

func (x *OrmxOption) GetSelect() bool

func (*OrmxOption) GetType added in v0.0.6

func (x *OrmxOption) GetType() string

func (*OrmxOption) GetUpdate added in v0.0.6

func (x *OrmxOption) GetUpdate() bool

func (*OrmxOption) ProtoMessage added in v0.0.6

func (*OrmxOption) ProtoMessage()

func (*OrmxOption) ProtoReflect added in v0.0.6

func (x *OrmxOption) ProtoReflect() protoreflect.Message

func (*OrmxOption) Reset added in v0.0.6

func (x *OrmxOption) Reset()

func (*OrmxOption) String added in v0.0.6

func (x *OrmxOption) String() string

type SQLOption

type SQLOption struct {
	Serializer *string `protobuf:"bytes,2,opt,name=serializer,proto3,oneof" json:"serializer,omitempty"`
	// contains filtered or unexported fields
}

func (*SQLOption) Descriptor deprecated

func (*SQLOption) Descriptor() ([]byte, []int)

Deprecated: Use SQLOption.ProtoReflect.Descriptor instead.

func (*SQLOption) GetSerializer

func (x *SQLOption) GetSerializer() string

func (*SQLOption) ProtoMessage

func (*SQLOption) ProtoMessage()

func (*SQLOption) ProtoReflect

func (x *SQLOption) ProtoReflect() protoreflect.Message

func (*SQLOption) Reset

func (x *SQLOption) Reset()

func (*SQLOption) String

func (x *SQLOption) String() string

type Timestamp

type Timestamp struct {
	Seconds uint32 `protobuf:"varint,1,opt,name=seconds,proto3" json:"seconds,omitempty"`
	Nanos   uint32 `protobuf:"varint,2,opt,name=nanos,proto3" json:"nanos,omitempty"`
	// contains filtered or unexported fields
}

func TimestampFromTime

func TimestampFromTime(t time.Time) *Timestamp

func (*Timestamp) Descriptor deprecated

func (*Timestamp) Descriptor() ([]byte, []int)

Deprecated: Use Timestamp.ProtoReflect.Descriptor instead.

func (*Timestamp) GetNanos

func (x *Timestamp) GetNanos() uint32

func (*Timestamp) GetSeconds

func (x *Timestamp) GetSeconds() uint32

func (Timestamp) MarshalJSON

func (x Timestamp) MarshalJSON() ([]byte, error)

func (*Timestamp) ProtoMessage

func (*Timestamp) ProtoMessage()

func (*Timestamp) ProtoReflect

func (x *Timestamp) ProtoReflect() protoreflect.Message

func (*Timestamp) Reset

func (x *Timestamp) Reset()

func (*Timestamp) Scan

func (x *Timestamp) Scan(src any) error

func (*Timestamp) String

func (x *Timestamp) String() string

func (*Timestamp) Time

func (x *Timestamp) Time() time.Time

func (*Timestamp) UnmarshalJSON

func (x *Timestamp) UnmarshalJSON(content []byte) error

func (Timestamp) Value

func (x Timestamp) Value() (driver.Value, error)

Directories

Path Synopsis
cmd
protox command

Jump to

Keyboard shortcuts

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