helpers

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CamelCaseName = TypeResolverFunc(func(typ types.Type, pbType ast.Type) string {
	if typ != nil {
		return strcase.ToCamel(typ.GetName())
	}
	named, ok := pbType.(ast.Named)
	if ok {
		return strcase.ToCamel(named.GetName())
	}
	panic(fmt.Sprintf("neither go type nor pb named type provided: %s, %s", typ, pbType))
})
View Source
var DefaultImportsResolver = ImportsResolverFunc(func(typ types.Type, pbType ast.Type) []string {
	return nil
})
View Source
var SnakeCaseGoTypeFile = TypeResolverFunc(func(typ types.Type, pbType ast.Type) string {
	return strcase.ToSnake(typ.GetName()) + ".go"
})
View Source
var StandardFieldResolver = FieldResolverFunc(func(field types.Field, pbType ast.Type) string {
	return field.GetName() + " " + field.GetType().GetName()
})

Functions

func GoTypeName

func GoTypeName(t ast.Type) string

func PbGoEnumName

func PbGoEnumName(e *ast.Enum) string

func PbGoFieldName

func PbGoFieldName(pbField ast.Field) string

func PbGoStructName

func PbGoStructName(msg *ast.Message) string

func PkgFromDir

func PkgFromDir(dir string) string

Types

type FieldResolverFunc

type FieldResolverFunc func(field types.Field, pbType ast.Type) string

func (FieldResolverFunc) Resolve

func (f FieldResolverFunc) Resolve(field types.Field, pbType ast.Type) string

type ImportsResolverFunc

type ImportsResolverFunc func(typ types.Type, pbType ast.Type) []string

func (ImportsResolverFunc) Resolve

func (f ImportsResolverFunc) Resolve(typ types.Type, pbType ast.Type) []string

type TypeResolverFunc

type TypeResolverFunc func(typ types.Type, pbType ast.Type) string

func (TypeResolverFunc) Resolve

func (f TypeResolverFunc) Resolve(typ types.Type, pbType ast.Type) string

Jump to

Keyboard shortcuts

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