printer

package
v0.0.0-...-d0ced46 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

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

func NewPrinter(out io.Writer) *Printer

NewPrinter creates a new Printer which will output protobuf definition text (i.e. ".proto" file) to the given writer.

func (*Printer) AppendLeadingComments

func (p *Printer) AppendLeadingComments(ptr any, lines []string)

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

EnumValue prints an enum value definition.

func (*Printer) Field

func (p *Printer) Field(field *descriptorpb.FieldDescriptorProto)

Field prints a field definition.

func (*Printer) MaybeLeadingComments

func (p *Printer) MaybeLeadingComments(ptr any)

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

func (p *Printer) Package(name string)

Package prints package declaration.

func (*Printer) Printf

func (p *Printer) Printf(format string, a ...any)

Printf prints to p.Out unless there was an error.

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

SetFile specifies the file containing the descriptors being printed. Used to relativize names and print comments.

Jump to

Keyboard shortcuts

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