Documentation ¶
Index ¶
- type Printer
- func (p *Printer) AppendLeadingComments(ptr any, lines []string)
- func (p *Printer) Enum(enum *descriptorpb.EnumDescriptorProto)
- func (p *Printer) EnumValue(v *descriptorpb.EnumValueDescriptorProto)
- func (p *Printer) Field(field *descriptorpb.FieldDescriptorProto)
- func (p *Printer) MaybeLeadingComments(ptr any)
- func (p *Printer) Message(msg *descriptorpb.DescriptorProto)
- func (p *Printer) Method(method *descriptorpb.MethodDescriptorProto)
- func (p *Printer) OneOf(msg *descriptorpb.DescriptorProto, oneOfIndex int)
- func (p *Printer) Package(name string)
- func (p *Printer) Printf(format string, a ...any)
- func (p *Printer) Service(service *descriptorpb.ServiceDescriptorProto, methodIndex int)
- func (p *Printer) SetFile(f *descriptorpb.FileDescriptorProto) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Printer ¶
type Printer struct { Out indented.Writer // Err is not nil if writing to Out failed. Err error // contains filtered or unexported fields }
Printer prints a proto3 definition from a description.
func NewPrinter ¶
NewPrinter creates a new Printer which will output protobuf definition text (i.e. ".proto" file) to the given writer.
func (*Printer) AppendLeadingComments ¶
AppendLeadingComments allows adding additional leading comments to any printable descriptorpb object associated with this printer.
Each line will be prepended with " " and appended with "\n".
e.g.
p := NewPrinter(os.Stdout) p.AppendLeadingComments(protodesc.ToDescriptorProto(myMsg.ProtoReflect()), []string{ "This is a line.", "This is the next line.", })
func (*Printer) Enum ¶
func (p *Printer) Enum(enum *descriptorpb.EnumDescriptorProto)
Enum prints an enum definition.
func (*Printer) EnumValue ¶
func (p *Printer) EnumValue(v *descriptorpb.EnumValueDescriptorProto)
EnumValue prints an enum value definition.
func (*Printer) Field ¶
func (p *Printer) Field(field *descriptorpb.FieldDescriptorProto)
Field prints a field definition.
func (*Printer) MaybeLeadingComments ¶
MaybeLeadingComments prints leading comments of the descriptorpb proto if found.
func (*Printer) Message ¶
func (p *Printer) Message(msg *descriptorpb.DescriptorProto)
Message prints a message definition.
func (*Printer) Method ¶
func (p *Printer) Method(method *descriptorpb.MethodDescriptorProto)
Method prints a service method definition.
func (*Printer) OneOf ¶
func (p *Printer) OneOf(msg *descriptorpb.DescriptorProto, oneOfIndex int)
OneOf prints a oneof definition.
func (*Printer) Service ¶
func (p *Printer) Service(service *descriptorpb.ServiceDescriptorProto, methodIndex int)
Service prints a service definition. If methodIndex != -1, only one method is printed. If serviceIndex != -1, leading comments are printed if found.
func (*Printer) SetFile ¶
func (p *Printer) SetFile(f *descriptorpb.FileDescriptorProto) error
SetFile specifies the file containing the descriptors being printed. Used to relativize names and print comments.