Documentation ¶
Overview ¶
go-to-protobuf generates a Protobuf IDL from a Go struct, respecting any existing IDL tags on the Go struct.
Index ¶
- func NewProtobufNamer() *protobufNamer
- func RewriteGeneratedGogoProtobufFile(name string, packageName string, extractFn ExtractFunc, header []byte) error
- func RewriteTypesWithProtobufStructTags(name string, structTags map[string]map[string]string) error
- func Run(g *Generator)
- type ExtractFunc
- type Generator
- type ImportTracker
- type ProtobufFromGoNamer
- type ProtobufLocator
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
Types ¶
type ExtractFunc ¶
ExtractFunc extracts information from the provided TypeSpec and returns true if the type should be removed from the destination file.
type Generator ¶
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 ¶
ProtobufFromGoNamer finds the protobuf name of a type (and its package, and the package path) from its Go name.