protox

package module
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2026 License: BSD-2-Clause Imports: 8 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
managed:
  enabled: true
  override:
    - file_option: go_package_prefix
      value: github.com/username/project
  disable:
    - path: protox/protox.proto

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// repeated protox.GoMethodOption method = 78901;
	E_Method = &file_protox_proto_extTypes[0]
	// optional protox.SQLOption sql = 78902;
	E_Sql = &file_protox_proto_extTypes[1]
	// optional protox.InheritOption inherit = 78903;
	E_Inherit = &file_protox_proto_extTypes[2]
)

Extension fields to descriptorpb.MessageOptions.

View Source
var (
	// optional string json = 78902;
	E_Json = &file_protox_proto_extTypes[3]
	// optional string tag = 78904;
	E_Tag = &file_protox_proto_extTypes[4]
)

Extension fields to descriptorpb.FieldOptions.

View Source
var (
	// optional string error = 78903;
	E_Error = &file_protox_proto_extTypes[5]
)

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"`
	ReturnString *string `protobuf:"bytes,2,opt,name=returnString,proto3,oneof" json:"returnString,omitempty"`
	ReturnInt64  *int64  `protobuf:"varint,3,opt,name=returnInt64,proto3,oneof" json:"returnInt64,omitempty"`
	ReturnBool   *bool   `protobuf:"varint,4,opt,name=returnBool,proto3,oneof" json:"returnBool,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) GetReturnBool added in v0.0.9

func (x *GoMethodOption) GetReturnBool() bool

func (*GoMethodOption) GetReturnInt64 added in v0.0.9

func (x *GoMethodOption) GetReturnInt64() int64

func (*GoMethodOption) GetReturnString added in v0.0.9

func (x *GoMethodOption) GetReturnString() 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 InheritOption added in v0.0.11

type InheritOption struct {
	Message string   `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	Omit    []string `protobuf:"bytes,2,rep,name=omit,proto3" json:"omit,omitempty"`
	// contains filtered or unexported fields
}

func (*InheritOption) Descriptor deprecated added in v0.0.11

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

Deprecated: Use InheritOption.ProtoReflect.Descriptor instead.

func (*InheritOption) GetMessage added in v0.0.11

func (x *InheritOption) GetMessage() string

func (*InheritOption) GetOmit added in v0.0.11

func (x *InheritOption) GetOmit() []string

func (*InheritOption) ProtoMessage added in v0.0.11

func (*InheritOption) ProtoMessage()

func (*InheritOption) ProtoReflect added in v0.0.11

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

func (*InheritOption) Reset added in v0.0.11

func (x *InheritOption) Reset()

func (*InheritOption) String added in v0.0.11

func (x *InheritOption) 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 {
	Millis uint64 `protobuf:"varint,1,opt,name=millis,proto3" json:"millis,omitempty"`
	// contains filtered or unexported fields
}

func (*Timestamp) Descriptor deprecated

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

Deprecated: Use Timestamp.ProtoReflect.Descriptor instead.

func (*Timestamp) GetMillis added in v0.0.11

func (x *Timestamp) GetMillis() uint64

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) 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