pluginutils

package
v1.0.34 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const ListPathDepthMax = 10

Variables

This section is empty.

Functions

func EndWithDefault added in v1.0.26

func EndWithDefault(field protoreflect.FieldDescriptor) bool

func EndWithJsonScalar added in v1.0.26

func EndWithJsonScalar(field protoreflect.FieldDescriptor) bool

func GetField added in v1.0.26

func GetField(msg *protogen.Message, path string) *protogen.Field

func GetFieldProtoreflect added in v1.0.26

func GetFieldProtoreflect(md protoreflect.MessageDescriptor, path string) protoreflect.FieldDescriptor

func Intersect added in v1.0.26

func Intersect(mx []string, my []string, ms ...[]string) []string

Intersect returns the intersection of all the paths in the input field masks.

func JsonFieldPath added in v1.0.26

func JsonFieldPath(rootMsg *protogen.Message) func(path string) string

func ListAllPaths added in v1.0.26

func ListAllPaths(msg protoreflect.MessageDescriptor) []string

func ListPaths added in v1.0.26

func ListPaths(prefix string, msg protoreflect.MessageDescriptor, endWith ListPathEndWith) []string

func RangeField added in v1.0.26

func RangeField(msg descriptorx.MessageDescriptor, path string, fn func(field descriptorx.FieldDescriptor, restPath string) bool) bool

func RangeFieldPath added in v1.0.26

func RangeFieldPath(path string, f func(field string, restPath string) bool) bool

RangeFieldPath is like strings.Split(path, "."), but avoids allocations by iterating over each field in place and calling a iterator function.

func Substract added in v1.0.26

func Substract(mx []string, my []string, ms ...[]string) []string

func Union added in v1.0.26

func Union(mx []string, my []string, ms ...[]string) []string

Union returns the union of all the paths in the input field masks.

Types

type FileGenerator

type FileGenerator struct {
	W *protogen.GeneratedFile // The file to write to
	F *protogen.File          // The proto file descr
}

func (FileGenerator) P

func (opt FileGenerator) P(v ...any)

P is a shorthand for (*protogen.GeneratedFile).P()

func (FileGenerator) PComment added in v1.0.12

func (opt FileGenerator) PComment(comments ...string)

PComment allows multiple lines string as comment.

func (FileGenerator) PCommentf added in v1.0.12

func (opt FileGenerator) PCommentf(format string, args ...interface{})

PCommentf allows formatted string as comment.

func (FileGenerator) PTmpl added in v1.0.21

func (opt FileGenerator) PTmpl(tmpl *template.Template, data interface{}, funcs ...template.FuncMap)

func (FileGenerator) PTmplStr added in v1.0.21

func (opt FileGenerator) PTmplStr(tmpl string, data interface{}, funcs ...template.FuncMap)

func (FileGenerator) Pf

func (opt FileGenerator) Pf(format string, v ...any)

Pf is same as P, but with formatted string.

type ForEachFileRunner added in v1.0.12

type ForEachFileRunner interface {
	Run(fn func(genOpt GenerateOptions) error)
}

type GenerateOptions added in v1.0.12

type GenerateOptions struct {
	FileGenerator
	PluginInfo
}

func (GenerateOptions) PHeader added in v1.0.12

func (opt GenerateOptions) PHeader(p *protogen.Plugin)

func (GenerateOptions) PPackage added in v1.0.12

func (opt GenerateOptions) PPackage()

type ListPathEndWith added in v1.0.26

type ListPathEndWith func(field protoreflect.FieldDescriptor) bool

type PluginInfo added in v1.0.12

type PluginInfo struct {
	PluginName        string
	VersionStr        string
	GenFileSuffix     string
	SupportedFeatures uint64
}

type PreForEachFileRunner added in v1.0.12

type PreForEachFileRunner interface {
	ForEachFileThat(fn func(protoFile *protogen.File) bool) ForEachFileRunner
}

func NewForEachFileRunner added in v1.0.12

func NewForEachFileRunner(info PluginInfo) PreForEachFileRunner

ForEachFileRunner helps to generate one file for each file that is being generated

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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