protobuf

package
v1.4.1-beta.2 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2016 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProtoFile added in v1.3.0

func NewProtoFile() *generator.DefaultFileType

func NewProtobufNamer

func NewProtobufNamer() *protobufNamer

func RewriteGeneratedGogoProtobufFile

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

func RewriteTypesWithProtobufStructTags

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

func Run

func Run(g *Generator)

Types

type ExtractFunc

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

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

func New

func New() *Generator

func (*Generator) BindFlags

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

type ImportTracker

type ImportTracker struct {
	namer.DefaultImportTracker
}

func NewImportTracker

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

func (*ImportTracker) AddNullable

func (tracker *ImportTracker) AddNullable()

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

type OptionalFunc added in v1.4.0

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

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

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

Jump to

Keyboard shortcuts

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