Documentation
¶
Index ¶
- Variables
- func ScalarGoTypeName(t ProtoScalar) string
- type Config
- type Field
- type FileResolver
- type Option
- type ProtoField
- type ProtoMapper
- func (p *ProtoMapper) ConvertersRenderer() Renderer
- func (p *ProtoMapper) Fields() *dicts.FieldDict
- func (p *ProtoMapper) ResolveTypes(resolver FileResolver, fileNames ...string) error
- func (p *ProtoMapper) TypeMapper() TypeMapper
- func (p *ProtoMapper) TypeRenderer() Renderer
- func (p *ProtoMapper) Types() *dicts.TypeDict
- func (p *ProtoMapper) WithOptions(opts ...Option) *ProtoMapper
- type ProtoMapperFunc
- type ProtoOption
- type ProtoScalar
- type ProtoType
- type Renderer
- type Type
- type TypeMapper
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 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 FileResolver ¶
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 ProtoMapper ¶ added in v0.0.2
type ProtoMapper struct {
// contains filtered or unexported fields
}
func NewProtoMapper ¶
func NewProtoMapper(cfg *Config) *ProtoMapper
NewProtoMapper setup new protomapper.
func (*ProtoMapper) ConvertersRenderer ¶ added in v0.0.2
func (p *ProtoMapper) ConvertersRenderer() Renderer
ConvertersRenderer get converters renderer.
func (*ProtoMapper) Fields ¶ added in v0.0.2
func (p *ProtoMapper) Fields() *dicts.FieldDict
Fields get fields.
func (*ProtoMapper) ResolveTypes ¶ added in v0.0.2
func (p *ProtoMapper) ResolveTypes(resolver FileResolver, fileNames ...string) error
ResolveTypes resolver *.proto files and collect defined types.
func (*ProtoMapper) TypeMapper ¶ added in v0.0.2
func (p *ProtoMapper) TypeMapper() TypeMapper
TypeMapper get type mapper.
func (*ProtoMapper) TypeRenderer ¶ added in v0.0.2
func (p *ProtoMapper) TypeRenderer() Renderer
TypeRenderer get type renderer.
func (*ProtoMapper) Types ¶ added in v0.0.2
func (p *ProtoMapper) Types() *dicts.TypeDict
Types get types.
func (*ProtoMapper) WithOptions ¶ added in v0.0.2
func (p *ProtoMapper) WithOptions(opts ...Option) *ProtoMapper
WithOptions add options for protomapper.
type ProtoMapperFunc ¶
type ProtoMapperFunc func(protoField ProtoField) func(src, dest string) string
type ProtoOption ¶
type ProtoScalar ¶
type ProtoScalar = ast.ScalarNode
type TypeMapper ¶
type TypeMapper interface {
FromProtoType(t ProtoType) (Type, error)
FromProtoField(f ProtoField) (Field, error)
}
TypeMapper mapper for protobuf types.
Click to show internal directories.
Click to hide internal directories.