protomapper

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: MIT Imports: 8 Imported by: 0

README

protomapper

Genrates code for mapping between proto messages and plane go structs

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FilepathResolver = func(path ...string) FileResolver {
	return func(s string) (string, error) {
		path := append(path, s)
		return filepath.Join(path...), nil
	}
}

FilepathResolver resolver for files in directory path.

Functions

func NewProtoMapper

func NewProtoMapper(cfg *Config) *protoMapper

NewProtoMapper setup new protomapper.

func ScalarGoTypeName

func ScalarGoTypeName(t ProtoScalar) string

ScalarGoTypeName get corresponding go type for protobuf scalar type.

Types

type Config

type Config struct {
	// AppName - app name to include in generated comment.
	AppName string
	// TypesDir - folder, where types will be generated.
	TypesDir string
	// TypesGoPackage - go package name for generated types.
	TypesGoPackage string
	// ConvertersDir - folder, where type converters will be generated.
	ConvertersDir string
	// ConvertersGoPkg - go package for converters.
	ConvertersGoPkg string
	// TypesImport - import types package in converters.
	TypesImport string
	// PbImport - import protobuf generated package in converters.
	PbImport string
}

Config protomapper configuration.

type Field

type Field = types.Field

type FileResolver

type FileResolver func(string) (string, error)

type Option

type Option interface {
	// contains filtered or unexported methods
}

func WithExcludeMessageFields

func WithExcludeMessageFields(exclude func(field ProtoField) bool) Option

func WithFieldMapper

func WithFieldMapper(field Field, fromProto, toProto ProtoMapperFunc) Option

type ProtoField

type ProtoField = ast.Field

type ProtoMapperFunc

type ProtoMapperFunc func(protoField ProtoField) func(src, dest string) string

type ProtoOption

type ProtoOption = ast.Option

type ProtoScalar

type ProtoScalar = ast.ScalarNode

type ProtoType

type ProtoType = ast.Type

type Renderer

type Renderer interface {
	Render(t Type) error
}

Renderer renderer for types.

type Type

type Type = types.Type

type TypeMapper

type TypeMapper interface {
	FromProtoType(t ProtoType) (Type, error)
	FromProtoField(f ProtoField) (Field, error)
}

TypeMapper mapper for protobuf types.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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