protobuf

package
v1.2.0-rancher-1 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2016 License: Apache-2.0 Imports: 25 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 NewProtobufNamer

func NewProtobufNamer() *protobufNamer

func RewriteGeneratedGogoProtobufFile

func RewriteGeneratedGogoProtobufFile(name string, packageName string, extractFn ExtractFunc, 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 {
	// contains filtered or unexported fields
}

ImportTracker handles Protobuf package imports

TODO: pay attention to the package name (instead of renaming every package). TODO: Figure out the best way to make names for packages that collide.

func NewImportTracker

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

func (*ImportTracker) AddNullable

func (tracker *ImportTracker) AddNullable()

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

func (*ImportTracker) AddType

func (tracker *ImportTracker) AddType(t *types.Type)

func (*ImportTracker) AddTypes

func (tracker *ImportTracker) AddTypes(types ...*types.Type)

func (*ImportTracker) ImportLines

func (tracker *ImportTracker) ImportLines() []string

func (*ImportTracker) LocalNameOf

func (tracker *ImportTracker) LocalNameOf(path string) string

LocalNameOf returns the name you would use to refer to the package at the specified path within the body of a file.

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)
	CastTypeName(name types.Name) string
}

Jump to

Keyboard shortcuts

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