xtype

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Nov 9, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	In  = "source"
	Out = "target"
)
View Source
const ThisVar = "c"

ThisVar is used as name for the reference to the converter interface.

Variables

This section is empty.

Functions

This section is empty.

Types

type JenID

type JenID struct {
	Code     *jen.Statement
	Variable bool
}

JenID a jennifer code wrapper with extra infos.

func OtherID

func OtherID(code *jen.Statement) *JenID

OtherID is used, when the ID isn't a variable id.

func VariableID

func VariableID(code *jen.Statement) *JenID

VariableID is used, when the ID can be referenced. F.ex it is not a function call.

type MethodKind

type MethodKind byte
const (
	InSourceOutTarget MethodKind = iota + 1
	InSourceIn2Target
)

type Signature

type Signature struct {
	Source string
	Target string
	Kind   MethodKind
}

Signature represents a signature for conversion.

type StructField

type StructField struct {
	Name string
	Type *Type
}

StructField holds the type of a struct field and its name.

type Type

type Type struct {
	T             types.Type
	Interface     bool
	InterfaceType *types.Interface
	Struct        bool
	StructType    *types.Struct
	Named         bool
	NamedType     *types.Named
	Pointer       bool
	PointerType   *types.Pointer
	PointerInner  *Type
	List          bool
	ListFixed     bool
	ListInner     *Type
	Map           bool
	MapType       *types.Map
	MapKey        *Type
	MapValue      *Type
	Basic         bool
	BasicType     *types.Basic
}

Type is a helper wrapper for types.Type.

func TypeOf

func TypeOf(t types.Type) *Type

TypeOf creates a Type.

func WrapWithPtr

func WrapWithPtr(ty *Type) *Type

func (*Type) EmbedField added in v1.0.2

func (t *Type) EmbedField() []lo.Tuple2[string, *Type]

func (*Type) ID

func (t *Type) ID() string

ID returns a deteministically generated id that may be used as variable.

func (*Type) StructField

func (t *Type) StructField(name, tag string, ignoreCase bool, ignore map[string]struct{}, searchTags []string) (*StructField, error)

StructField returns the type of a struct field and its name upon successful match or an error if it is not found. This method will also return a detailed error if matchIgnoreCase is enabled and there are multiple non-exact matches.

func (*Type) TypeAsJen

func (t *Type) TypeAsJen() *jen.Statement

TypeAsJen returns a jen representation of the type.

func (*Type) UnescapedID

func (t *Type) UnescapedID() string

UnescapedID returns a deteministically generated id that may be used as variable reserved keywords aren't escaped.

Jump to

Keyboard shortcuts

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