protogenlite

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package protogenlite provides a minimal protoc plugin model for generators that only need file/service/method metadata and Go import qualification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment string

Comment stores a single comment string.

func (Comment) String

func (c Comment) String() string

String returns the comment text.

type Comments

type Comments struct {
	Leading Comment
}

Comments stores descriptor comments.

type File

type File struct {
	Proto                   *descriptorpb.FileDescriptorProto
	Desc                    *FileDesc
	Generate                bool
	GoImportPath            GoImportPath
	GoPackageName           string
	GeneratedFilenamePrefix string
	Messages                []*Message
	Services                []*Service
}

File stores the minimal generated view of a proto file.

type FileDesc

type FileDesc struct {
	// contains filtered or unexported fields
}

FileDesc exposes the minimal file descriptor helpers used by generators.

func (*FileDesc) Path

func (d *FileDesc) Path() string

Path returns the source proto path.

type GeneratedFile

type GeneratedFile struct {
	// contains filtered or unexported fields
}

GeneratedFile accumulates a generated Go source file.

func (*GeneratedFile) Content

func (g *GeneratedFile) Content() ([]byte, error)

Content returns the generated file contents.

func (*GeneratedFile) P

func (g *GeneratedFile) P(args ...any)

P appends a line to the generated output.

func (*GeneratedFile) QualifiedGoIdent

func (g *GeneratedFile) QualifiedGoIdent(id GoIdent) string

QualifiedGoIdent returns the identifier qualified for the current file.

type GoIdent

type GoIdent struct {
	GoName       string
	GoImportPath GoImportPath
}

GoIdent identifies a Go name within a package.

type GoImportPath

type GoImportPath string

GoImportPath identifies a Go package import path.

func (GoImportPath) Ident

func (p GoImportPath) Ident(name string) GoIdent

Ident constructs a Go identifier in the import path.

type Message

type Message struct {
	Proto    *descriptorpb.DescriptorProto
	File     *File
	FullName string
	GoName   string
	GoIdent  GoIdent
	Messages []*Message
}

Message stores the minimal generated view of a proto message.

type Method

type Method struct {
	Proto    *descriptorpb.MethodDescriptorProto
	Parent   *Service
	Desc     *MethodDesc
	GoName   string
	Input    *Message
	Output   *Message
	Comments Comments
}

Method stores the minimal generated view of a proto method.

type MethodDesc

type MethodDesc struct {
	// contains filtered or unexported fields
}

MethodDesc exposes the minimal method descriptor helpers used by generators.

func (*MethodDesc) IsStreamingClient

func (d *MethodDesc) IsStreamingClient() bool

IsStreamingClient reports whether the method accepts a client stream.

func (*MethodDesc) IsStreamingServer

func (d *MethodDesc) IsStreamingServer() bool

IsStreamingServer reports whether the method returns a server stream.

func (*MethodDesc) Name

func (d *MethodDesc) Name() string

Name returns the proto method name.

type Options

type Options struct{}

Options configures a plugin run.

func (Options) Run

func (opts Options) Run(f func(*Plugin) error)

Run executes a protoc plugin using the minimal descriptor model.

type Plugin

type Plugin struct {
	Request                  *pluginpb.CodeGeneratorRequest
	Files                    []*File
	SupportedFeatures        uint64
	SupportedEditionsMinimum descriptorpb.Edition
	SupportedEditionsMaximum descriptorpb.Edition
	// contains filtered or unexported fields
}

Plugin stores a protoc plugin invocation.

func (*Plugin) NewGeneratedFile

func (p *Plugin) NewGeneratedFile(filename string, importPath GoImportPath) *GeneratedFile

NewGeneratedFile allocates a generated file in the plugin response.

func (*Plugin) Response

func (p *Plugin) Response() *pluginpb.CodeGeneratorResponse

Response builds the code generator response.

type Service

type Service struct {
	Proto    *descriptorpb.ServiceDescriptorProto
	File     *File
	Desc     *ServiceDesc
	GoName   string
	Methods  []*Method
	Comments Comments
}

Service stores the minimal generated view of a proto service.

type ServiceDesc

type ServiceDesc struct {
	// contains filtered or unexported fields
}

ServiceDesc exposes the minimal service descriptor helpers used by generators.

func (*ServiceDesc) FullName

func (d *ServiceDesc) FullName() string

FullName returns the fully-qualified proto service name.

Jump to

Keyboard shortcuts

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