code-generator: Index | Files

package protobuf

import ""

go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any existing IDL tags on the Go struct.


Package Files

cmd.go generator.go import_tracker.go namer.go package.go parser.go tags.go

func NewProtoFile Uses

func NewProtoFile() *generator.DefaultFileType

func NewProtobufNamer Uses

func NewProtobufNamer() *protobufNamer

func RewriteGeneratedGogoProtobufFile Uses

func RewriteGeneratedGogoProtobufFile(name string, extractFn ExtractFunc, optionalFn OptionalFunc, header []byte) error

func RewriteTypesWithProtobufStructTags Uses

func RewriteTypesWithProtobufStructTags(name string, structTags map[string]map[string]string) error

func Run Uses

func Run(g *Generator)

type ExtractFunc Uses

type ExtractFunc func(*ast.TypeSpec) bool

ExtractFunc extracts information from the provided TypeSpec and returns true if the type should be removed from the destination file.

type Generator Uses

type Generator struct {
    Common               args.GeneratorArgs
    APIMachineryPackages string
    Packages             string
    OutputBase           string
    VendorOutputBase     string
    ProtoImport          []string
    Conditional          string
    Clean                bool
    OnlyIDL              bool
    KeepGogoproto        bool
    SkipGeneratedRewrite bool
    DropEmbeddedFields   string

func New Uses

func New() *Generator

func (*Generator) BindFlags Uses

func (g *Generator) BindFlags(flag *flag.FlagSet)

type ImportTracker Uses

type ImportTracker struct {

func NewImportTracker Uses

func NewImportTracker(local types.Name, typesToAdd ...*types.Type) *ImportTracker

func (*ImportTracker) AddNullable Uses

func (tracker *ImportTracker) AddNullable()

AddNullable ensures that support for the nullable Gogo-protobuf extension is added.

type OptionalFunc Uses

type OptionalFunc func(name string) bool

OptionalFunc returns true if the provided local name is a type that has protobuf.nullable=true and should have its marshal functions adjusted to remove the 'Items' accessor.

type ProtobufFromGoNamer Uses

type ProtobufFromGoNamer interface {
    GoNameToProtoName(name types.Name) types.Name

ProtobufFromGoNamer finds the protobuf name of a type (and its package, and the package path) from its Go name.

type ProtobufLocator Uses

type ProtobufLocator interface {
    ProtoTypeFor(t *types.Type) (*types.Type, error)
    GoTypeForName(name types.Name) *types.Type
    CastTypeName(name types.Name) string

Package protobuf imports 27 packages (graph) and is imported by 2 packages. Updated 2020-06-02. Refresh now. Tools for package owners.