format

package
v0.0.0-...-0fe3ff9 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTypeParams

func GenerateTypeParams(registry *TypeFormatterRegistry, named *types.Named) string

func GetFieldName

func GetFieldName(f *types.Var) string

func GetJSONFieldName

func GetJSONFieldName(tag string, mode options.Mode) string

Types

type AliasFormatter

type AliasFormatter struct {
	TypeFormatterBase
}

func (*AliasFormatter) CanFormat

func (f *AliasFormatter) CanFormat(expr types.Type) bool

func (*AliasFormatter) Constructor

func (f *AliasFormatter) Constructor(fieldName string, expr types.Type) string

func (*AliasFormatter) Declaration

func (f *AliasFormatter) Declaration(fieldName string, expr types.Type) string

func (*AliasFormatter) Signature

func (f *AliasFormatter) Signature(expr types.Type) string

type ArrayFormatter

type ArrayFormatter struct {
	TypeFormatterBase
}

func (*ArrayFormatter) CanFormat

func (f *ArrayFormatter) CanFormat(expr types.Type) bool

func (*ArrayFormatter) Declaration

func (f *ArrayFormatter) Declaration(fieldName string, expr types.Type) string

func (*ArrayFormatter) DefaultValue

func (f *ArrayFormatter) DefaultValue(expr types.Type) string

func (*ArrayFormatter) Signature

func (f *ArrayFormatter) Signature(expr types.Type) string

type ConcreteStructFormatter

type ConcreteStructFormatter struct {
	TypeFormatterBase
}

func (*ConcreteStructFormatter) Annotation

func (t *ConcreteStructFormatter) Annotation(expr *types.TypeName) string

func (*ConcreteStructFormatter) CanFormat

func (f *ConcreteStructFormatter) CanFormat(expr types.Type) bool

func (*ConcreteStructFormatter) Declaration

func (f *ConcreteStructFormatter) Declaration(fieldName string, expr types.Type) string

func (*ConcreteStructFormatter) Deserialization

func (f *ConcreteStructFormatter) Deserialization(expr *types.TypeName) string

func (*ConcreteStructFormatter) Name

func (f *ConcreteStructFormatter) Name(expr *types.TypeName, includeTypeParams bool) string

func (*ConcreteStructFormatter) Serialization

func (f *ConcreteStructFormatter) Serialization(expr *types.TypeName) string

func (*ConcreteStructFormatter) Signature

func (f *ConcreteStructFormatter) Signature(expr types.Type) string

type GenericStructFormatter

type GenericStructFormatter struct {
	TypeFormatterBase
}

func (*GenericStructFormatter) Annotation

func (f *GenericStructFormatter) Annotation(expr *types.TypeName) string

func (*GenericStructFormatter) CanFormat

func (f *GenericStructFormatter) CanFormat(expr types.Type) bool

func (*GenericStructFormatter) Declaration

func (f *GenericStructFormatter) Declaration(fieldName string, expr types.Type) string

func (*GenericStructFormatter) Deserialization

func (f *GenericStructFormatter) Deserialization(expr *types.TypeName) string

func (*GenericStructFormatter) Name

func (f *GenericStructFormatter) Name(expr *types.TypeName, includeTypeParams bool) string

func (*GenericStructFormatter) Serialization

func (f *GenericStructFormatter) Serialization(expr *types.TypeName) string

func (*GenericStructFormatter) Signature

func (f *GenericStructFormatter) Signature(expr types.Type) string

type MapFormatter

type MapFormatter struct {
	TypeFormatterBase
}

func (*MapFormatter) CanFormat

func (f *MapFormatter) CanFormat(expr types.Type) bool

func (*MapFormatter) Declaration

func (f *MapFormatter) Declaration(fieldName string, expr types.Type) string

func (*MapFormatter) DefaultValue

func (f *MapFormatter) DefaultValue(expr types.Type) string

func (*MapFormatter) Signature

func (f *MapFormatter) Signature(expr types.Type) string

type PointerFormatter

type PointerFormatter struct {
	TypeFormatterBase
}

func (*PointerFormatter) CanFormat

func (f *PointerFormatter) CanFormat(expr types.Type) bool

func (*PointerFormatter) Constructor

func (f *PointerFormatter) Constructor(fieldName string, _ types.Type) string

func (*PointerFormatter) Declaration

func (f *PointerFormatter) Declaration(fieldName string, expr types.Type) string

func (*PointerFormatter) Signature

func (f *PointerFormatter) Signature(expr types.Type) string

type PrimitiveFormatter

type PrimitiveFormatter struct {
	TypeFormatterBase
}

func (*PrimitiveFormatter) CanFormat

func (f *PrimitiveFormatter) CanFormat(expr types.Type) bool

func (*PrimitiveFormatter) Declaration

func (f *PrimitiveFormatter) Declaration(fieldName string, expr types.Type) string

func (*PrimitiveFormatter) Signature

func (f *PrimitiveFormatter) Signature(expr types.Type) string

type StructFormatter

type StructFormatter interface {
	TypeFormatter
	Name(expr *types.TypeName, includeTypeParams bool) string
	Serialization(expr *types.TypeName) string
	Deserialization(expr *types.TypeName) string
	Annotation(expr *types.TypeName) string
}

type TimeFormatter

type TimeFormatter struct {
	TypeFormatterBase
}

func (*TimeFormatter) CanFormat

func (f *TimeFormatter) CanFormat(expr types.Type) bool

func (*TimeFormatter) Declaration

func (f *TimeFormatter) Declaration(fieldName string, expr types.Type) string

func (*TimeFormatter) Signature

func (f *TimeFormatter) Signature(_ types.Type) string

type TypeFormatter

type TypeFormatter interface {
	SetRegistry(registry *TypeFormatterRegistry)
	CanFormat(expr types.Type) bool
	Signature(expr types.Type) string
	DefaultValue(expr types.Type) string
	Declaration(fieldName string, expr types.Type) string
	Constructor(fieldName string, expr types.Type) string
}

type TypeFormatterBase

type TypeFormatterBase struct {
	Registry *TypeFormatterRegistry
	Options  options.Options
}

func (*TypeFormatterBase) Constructor

func (f *TypeFormatterBase) Constructor(fieldName string, _ types.Type) string

func (*TypeFormatterBase) DefaultValue

func (t *TypeFormatterBase) DefaultValue(expr types.Type) string

func (*TypeFormatterBase) SetRegistry

func (t *TypeFormatterBase) SetRegistry(registry *TypeFormatterRegistry)

type TypeFormatterRegistry

type TypeFormatterRegistry struct {
	Formatters []TypeFormatter
	// contains filtered or unexported fields
}

func NewTypeFormatterRegistry

func NewTypeFormatterRegistry() *TypeFormatterRegistry

func (*TypeFormatterRegistry) AddKnownType

func (t *TypeFormatterRegistry) AddKnownType(typ types.Type)

func (*TypeFormatterRegistry) GetTypeFormatter

func (t *TypeFormatterRegistry) GetTypeFormatter(expr types.Type) TypeFormatter

func (*TypeFormatterRegistry) IsKnownNamedType

func (t *TypeFormatterRegistry) IsKnownNamedType(namedType *types.Named) bool

func (*TypeFormatterRegistry) RegisterTypeFormatter

func (t *TypeFormatterRegistry) RegisterTypeFormatter(formatter TypeFormatter)

type TypeParamsFormatter

type TypeParamsFormatter struct {
	TypeFormatterBase
}

func (*TypeParamsFormatter) CanFormat

func (f *TypeParamsFormatter) CanFormat(expr types.Type) bool

func (*TypeParamsFormatter) Declaration

func (f *TypeParamsFormatter) Declaration(fieldName string, expr types.Type) string

func (*TypeParamsFormatter) Signature

func (f *TypeParamsFormatter) Signature(expr types.Type) string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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