Documentation ¶
Overview ¶
Code generated by mkunion. DO NOT EDIT.
Code generated by mkunion. DO NOT EDIT.
Index ¶
- Variables
- func AliasLikeToJSON(x *AliasLike) ([]byte, error)
- func AndGuardToJSON(x *AndGuard) ([]byte, error)
- func AnyToJSON(x *Any) ([]byte, error)
- func BooleanLikeToJSON(x *BooleanLike) ([]byte, error)
- func EnumToJSON(x *Enum) ([]byte, error)
- func ExtractDocumentTags(doc *ast.CommentGroup) map[string]Tag
- func ExtractPkgImportNames(x Shape) map[string]string
- func ExtractTags(tag string) map[string]Tag
- func Float32ToJSON(x *Float32) ([]byte, error)
- func Float64ToJSON(x *Float64) ([]byte, error)
- func GuardToJSON(x Guard) ([]byte, error)
- func GuessPkgName(x reflect.Type) string
- func GuessPkgNameFromPkgImportName(x string) string
- func InjectPkgImportName(pkgNameToImportName map[string]string) func(x Shape)
- func InjectPkgName(pkgName string) func(x Shape)
- func Int16ToJSON(x *Int16) ([]byte, error)
- func Int32ToJSON(x *Int32) ([]byte, error)
- func Int64ToJSON(x *Int64) ([]byte, error)
- func Int8ToJSON(x *Int8) ([]byte, error)
- func IntToJSON(x *Int) ([]byte, error)
- func IsAlias(t *ast.TypeSpec) bool
- func IsBinary(x Shape) bool
- func IsPointer(x Shape) bool
- func IsRequired(x Guard) bool
- func IsStarExpr(x ast.Expr) bool
- func IsString(x Shape) bool
- func ListLikeToJSON(x *ListLike) ([]byte, error)
- func MapLikeToJSON(x *MapLike) ([]byte, error)
- func MatchGuardR0(x Guard, f1 func(x *Enum), f2 func(x *Required), f3 func(x *AndGuard))
- func MatchGuardR1[T0 any](x Guard, f1 func(x *Enum) T0, f2 func(x *Required) T0, f3 func(x *AndGuard) T0) T0
- func MatchGuardR2[T0, T1 any](x Guard, f1 func(x *Enum) (T0, T1), f2 func(x *Required) (T0, T1), ...) (T0, T1)
- func MatchGuardR3[T0, T1, T2 any](x Guard, f1 func(x *Enum) (T0, T1, T2), f2 func(x *Required) (T0, T1, T2), ...) (T0, T1, T2)
- func MatchNumberKindR0(x NumberKind, f1 func(x *UInt), f2 func(x *UInt8), f3 func(x *UInt16), ...)
- func MatchNumberKindR1[T0 any](x NumberKind, f1 func(x *UInt) T0, f2 func(x *UInt8) T0, f3 func(x *UInt16) T0, ...) T0
- func MatchNumberKindR2[T0, T1 any](x NumberKind, f1 func(x *UInt) (T0, T1), f2 func(x *UInt8) (T0, T1), ...) (T0, T1)
- func MatchNumberKindR3[T0, T1, T2 any](x NumberKind, f1 func(x *UInt) (T0, T1, T2), f2 func(x *UInt8) (T0, T1, T2), ...) (T0, T1, T2)
- func MatchPrimitiveKindR0(x PrimitiveKind, f1 func(x *BooleanLike), f2 func(x *StringLike), ...)
- func MatchPrimitiveKindR1[T0 any](x PrimitiveKind, f1 func(x *BooleanLike) T0, f2 func(x *StringLike) T0, ...) T0
- func MatchPrimitiveKindR2[T0, T1 any](x PrimitiveKind, f1 func(x *BooleanLike) (T0, T1), ...) (T0, T1)
- func MatchPrimitiveKindR3[T0, T1, T2 any](x PrimitiveKind, f1 func(x *BooleanLike) (T0, T1, T2), ...) (T0, T1, T2)
- func MatchShapeR0(x Shape, f1 func(x *Any), f2 func(x *RefName), f3 func(x *PointerLike), ...)
- func MatchShapeR1[T0 any](x Shape, f1 func(x *Any) T0, f2 func(x *RefName) T0, ...) T0
- func MatchShapeR2[T0, T1 any](x Shape, f1 func(x *Any) (T0, T1), f2 func(x *RefName) (T0, T1), ...) (T0, T1)
- func MatchShapeR3[T0, T1, T2 any](x Shape, f1 func(x *Any) (T0, T1, T2), f2 func(x *RefName) (T0, T1, T2), ...) (T0, T1, T2)
- func NumberKindToGoName(x NumberKind) string
- func NumberKindToJSON(x NumberKind) ([]byte, error)
- func NumberLikeToJSON(x *NumberLike) ([]byte, error)
- func PointerLikeToJSON(x *PointerLike) ([]byte, error)
- func PrimitiveKindToJSON(x PrimitiveKind) ([]byte, error)
- func PrimitiveLikeToJSON(x *PrimitiveLike) ([]byte, error)
- func Ptr[A any](x A) *A
- func RefNameToJSON(x *RefName) ([]byte, error)
- func Register(x Shape)
- func RequiredToJSON(x *Required) ([]byte, error)
- func ShapeToJSON(x Shape) ([]byte, error)
- func StringLikeToJSON(x *StringLike) ([]byte, error)
- func StructLikeToJSON(x *StructLike) ([]byte, error)
- func TagGetValue(x map[string]Tag, tag, defaults string) string
- func Tags(x Shape) map[string]Tag
- func TagsToDesc(tags map[string]Tag) *string
- func ToGoFullTypeNameFromReflect(x reflect.Type) string
- func ToGoPkgImportName(x Shape) string
- func ToGoPkgName(x Shape) string
- func ToGoTypeName(x Shape, options ...ToGoTypeNameOption) string
- func ToGoTypeNameFromReflect(x reflect.Type) string
- func ToGoTypeParamsNames(x Shape) []string
- func ToJsonSchema(s Shape) string
- func ToOpenAIFunctionDefinition(name, desc string, in Shape) openai.FunctionDefinition
- func ToStr(x Shape) string
- func ToTypeScript(x Shape, option *TypeScriptOptions) string
- func UInt16ToJSON(x *UInt16) ([]byte, error)
- func UInt32ToJSON(x *UInt32) ([]byte, error)
- func UInt64ToJSON(x *UInt64) ([]byte, error)
- func UInt8ToJSON(x *UInt8) ([]byte, error)
- func UIntToJSON(x *UInt) ([]byte, error)
- func UnionLikeToJSON(x *UnionLike) ([]byte, error)
- func UnwrapPointer(x string) string
- type AliasLike
- type AndGuard
- type Any
- type BooleanLike
- type Enum
- type FieldLike
- type Float32
- type Float64
- type FromASTOption
- type Guard
- type GuardUnionJSON
- type GuardVisitor
- type InferredInfo
- func (f *InferredInfo) PackageImportName() string
- func (f *InferredInfo) PackageName() string
- func (f *InferredInfo) RetrieveShapeNamedAs(name string) Shape
- func (f *InferredInfo) RetrieveShapes() []Shape
- func (f *InferredInfo) RetrieveShapesTaggedAs(tagName string) []Shape
- func (f *InferredInfo) RetrieveStruct(name string) *StructLike
- func (f *InferredInfo) RetrieveStructs() []*StructLike
- func (f *InferredInfo) RetrieveUnion(name string) *UnionLike
- func (f *InferredInfo) RetrieveUnions() []*UnionLike
- func (f *InferredInfo) Visit(n ast.Node) ast.Visitor
- type Int
- type Int16
- type Int32
- type Int64
- type Int8
- type ListLike
- type MapLike
- type NumberKind
- type NumberKindUnionJSON
- type NumberKindVisitor
- type NumberLike
- type PointerLike
- type PrimitiveKind
- type PrimitiveKindUnionJSON
- type PrimitiveKindVisitor
- type PrimitiveLike
- type RefName
- type Required
- type Shape
- func AliasLikeShape() Shape
- func AndGuardShape() Shape
- func AnyShape() Shape
- func BooleanLikeShape() Shape
- func CleanTypeThatAreOvershadowByTypeParam(typ Shape, params []TypeParam) Shape
- func EnumShape() Shape
- func Float32Shape() Shape
- func Float64Shape() Shape
- func FromAST(x any, fx ...FromASTOption) Shape
- func FromGo(x any) Shape
- func FromGoReflect(x reflect.Type, infiniteRecursionFix map[string]Shape) Shape
- func GuardShape() Shape
- func IndexWith(y Shape, ref *RefName) Shape
- func InstantiateTypeThatAreOvershadowByTypeParam(typ Shape, replacement map[string]Shape) Shape
- func Int16Shape() Shape
- func Int32Shape() Shape
- func Int64Shape() Shape
- func Int8Shape() Shape
- func IntShape() Shape
- func ListLikeShape() Shape
- func LookupPkgShapeOnDisk(pkgImportName string) []Shape
- func LookupShape(x *RefName) (Shape, bool)
- func LookupShapeOnDisk(x *RefName) (Shape, bool)
- func LookupShapeReflectAndIndex[A any]() (Shape, bool)
- func MapLikeShape() Shape
- func NumberKindShape() Shape
- func NumberLikeShape() Shape
- func PointerLikeShape() Shape
- func PrimitiveKindShape() Shape
- func PrimitiveLikeShape() Shape
- func RefNameShape() Shape
- func RequiredShape() Shape
- func ShapeFromJSON(x []byte) (Shape, error)
- func ShapeShape() Shape
- func StringLikeShape() Shape
- func StructLikeShape() Shape
- func ToGoTypeParamsTypes(x Shape) []Shape
- func ToTypeScriptOptimisation(x Shape) Shape
- func TypeParamShape() Shape
- func UInt16Shape() Shape
- func UInt32Shape() Shape
- func UInt64Shape() Shape
- func UInt8Shape() Shape
- func UIntShape() Shape
- func UnionLikeShape() Shape
- type ShapeUnionJSON
- type ShapeVisitor
- type StringLike
- type StructLike
- type Tag
- type ToGoTypeNameOption
- type TypeParam
- type TypeScriptOptions
- type TypeScriptRenderer
- type UInt
- type UInt16
- type UInt32
- type UInt64
- type UInt8
- type UnionLike
Constants ¶
This section is empty.
Variables ¶
var (
ErrShapeNotFound = fmt.Errorf(`To register shape manually, use shape.Register(myShape) in your package init() function or, use shape.LookupShapeOnDisk(x) to scan your filesystem for shapes.`)
)
var TypeStringToNumberKindMap = map[string]NumberKind{ "uint": &UInt{}, "uint8": &UInt8{}, "uint16": &UInt16{}, "uint32": &UInt32{}, "uint64": &UInt64{}, "int": &Int{}, "int8": &Int8{}, "int16": &Int16{}, "int32": &Int32{}, "int64": &Int64{}, "float32": &Float32{}, "float64": &Float64{}, "byte": &UInt8{}, "rune": &Int32{}, }
Functions ¶
func AliasLikeToJSON ¶ added in v1.20.2
func AndGuardToJSON ¶ added in v1.20.0
func BooleanLikeToJSON ¶ added in v1.20.0
func BooleanLikeToJSON(x *BooleanLike) ([]byte, error)
func EnumToJSON ¶ added in v1.20.0
func ExtractDocumentTags ¶ added in v1.21.0
func ExtractDocumentTags(doc *ast.CommentGroup) map[string]Tag
func ExtractPkgImportNames ¶ added in v1.21.0
func ExtractTags ¶ added in v1.20.0
func Float32ToJSON ¶ added in v1.20.1
func Float64ToJSON ¶ added in v1.20.1
func GuardToJSON ¶ added in v1.20.0
func GuessPkgName ¶ added in v1.21.0
func GuessPkgNameFromPkgImportName ¶ added in v1.21.0
func InjectPkgImportName ¶ added in v1.20.2
func InjectPkgName ¶
func Int16ToJSON ¶ added in v1.20.1
func Int32ToJSON ¶ added in v1.20.1
func Int64ToJSON ¶ added in v1.20.1
func Int8ToJSON ¶ added in v1.20.1
func IsRequired ¶ added in v1.22.0
func IsStarExpr ¶ added in v1.20.0
func ListLikeToJSON ¶ added in v1.20.0
func MapLikeToJSON ¶ added in v1.20.0
func MatchGuardR0 ¶ added in v1.22.0
func MatchGuardR1 ¶ added in v1.22.0
func MatchGuardR2 ¶
func MatchGuardR3 ¶ added in v1.22.0
func MatchNumberKindR0 ¶ added in v1.22.0
func MatchNumberKindR1 ¶ added in v1.22.0
func MatchNumberKindR1[T0 any]( x NumberKind, f1 func(x *UInt) T0, f2 func(x *UInt8) T0, f3 func(x *UInt16) T0, f4 func(x *UInt32) T0, f5 func(x *UInt64) T0, f6 func(x *Int) T0, f7 func(x *Int8) T0, f8 func(x *Int16) T0, f9 func(x *Int32) T0, f10 func(x *Int64) T0, f11 func(x *Float32) T0, f12 func(x *Float64) T0, ) T0
func MatchNumberKindR2 ¶ added in v1.20.1
func MatchNumberKindR2[T0, T1 any]( x NumberKind, f1 func(x *UInt) (T0, T1), f2 func(x *UInt8) (T0, T1), f3 func(x *UInt16) (T0, T1), f4 func(x *UInt32) (T0, T1), f5 func(x *UInt64) (T0, T1), f6 func(x *Int) (T0, T1), f7 func(x *Int8) (T0, T1), f8 func(x *Int16) (T0, T1), f9 func(x *Int32) (T0, T1), f10 func(x *Int64) (T0, T1), f11 func(x *Float32) (T0, T1), f12 func(x *Float64) (T0, T1), ) (T0, T1)
func MatchNumberKindR3 ¶ added in v1.22.0
func MatchNumberKindR3[T0, T1, T2 any]( x NumberKind, f1 func(x *UInt) (T0, T1, T2), f2 func(x *UInt8) (T0, T1, T2), f3 func(x *UInt16) (T0, T1, T2), f4 func(x *UInt32) (T0, T1, T2), f5 func(x *UInt64) (T0, T1, T2), f6 func(x *Int) (T0, T1, T2), f7 func(x *Int8) (T0, T1, T2), f8 func(x *Int16) (T0, T1, T2), f9 func(x *Int32) (T0, T1, T2), f10 func(x *Int64) (T0, T1, T2), f11 func(x *Float32) (T0, T1, T2), f12 func(x *Float64) (T0, T1, T2), ) (T0, T1, T2)
func MatchPrimitiveKindR0 ¶ added in v1.22.0
func MatchPrimitiveKindR0( x PrimitiveKind, f1 func(x *BooleanLike), f2 func(x *StringLike), f3 func(x *NumberLike), )
func MatchPrimitiveKindR1 ¶ added in v1.22.0
func MatchPrimitiveKindR1[T0 any]( x PrimitiveKind, f1 func(x *BooleanLike) T0, f2 func(x *StringLike) T0, f3 func(x *NumberLike) T0, ) T0
func MatchPrimitiveKindR2 ¶ added in v1.22.0
func MatchPrimitiveKindR2[T0, T1 any]( x PrimitiveKind, f1 func(x *BooleanLike) (T0, T1), f2 func(x *StringLike) (T0, T1), f3 func(x *NumberLike) (T0, T1), ) (T0, T1)
func MatchPrimitiveKindR3 ¶ added in v1.22.0
func MatchPrimitiveKindR3[T0, T1, T2 any]( x PrimitiveKind, f1 func(x *BooleanLike) (T0, T1, T2), f2 func(x *StringLike) (T0, T1, T2), f3 func(x *NumberLike) (T0, T1, T2), ) (T0, T1, T2)
func MatchShapeR0 ¶ added in v1.22.0
func MatchShapeR0( x Shape, f1 func(x *Any), f2 func(x *RefName), f3 func(x *PointerLike), f4 func(x *AliasLike), f5 func(x *PrimitiveLike), f6 func(x *ListLike), f7 func(x *MapLike), f8 func(x *StructLike), f9 func(x *UnionLike), )
func MatchShapeR1 ¶ added in v1.22.0
func MatchShapeR1[T0 any]( x Shape, f1 func(x *Any) T0, f2 func(x *RefName) T0, f3 func(x *PointerLike) T0, f4 func(x *AliasLike) T0, f5 func(x *PrimitiveLike) T0, f6 func(x *ListLike) T0, f7 func(x *MapLike) T0, f8 func(x *StructLike) T0, f9 func(x *UnionLike) T0, ) T0
func MatchShapeR2 ¶
func MatchShapeR2[T0, T1 any]( x Shape, f1 func(x *Any) (T0, T1), f2 func(x *RefName) (T0, T1), f3 func(x *PointerLike) (T0, T1), f4 func(x *AliasLike) (T0, T1), f5 func(x *PrimitiveLike) (T0, T1), f6 func(x *ListLike) (T0, T1), f7 func(x *MapLike) (T0, T1), f8 func(x *StructLike) (T0, T1), f9 func(x *UnionLike) (T0, T1), ) (T0, T1)
func MatchShapeR3 ¶ added in v1.22.0
func MatchShapeR3[T0, T1, T2 any]( x Shape, f1 func(x *Any) (T0, T1, T2), f2 func(x *RefName) (T0, T1, T2), f3 func(x *PointerLike) (T0, T1, T2), f4 func(x *AliasLike) (T0, T1, T2), f5 func(x *PrimitiveLike) (T0, T1, T2), f6 func(x *ListLike) (T0, T1, T2), f7 func(x *MapLike) (T0, T1, T2), f8 func(x *StructLike) (T0, T1, T2), f9 func(x *UnionLike) (T0, T1, T2), ) (T0, T1, T2)
func NumberKindToGoName ¶ added in v1.21.0
func NumberKindToGoName(x NumberKind) string
func NumberKindToJSON ¶ added in v1.20.1
func NumberKindToJSON(x NumberKind) ([]byte, error)
func NumberLikeToJSON ¶ added in v1.20.0
func NumberLikeToJSON(x *NumberLike) ([]byte, error)
func PointerLikeToJSON ¶ added in v1.22.0
func PointerLikeToJSON(x *PointerLike) ([]byte, error)
func PrimitiveKindToJSON ¶ added in v1.22.0
func PrimitiveKindToJSON(x PrimitiveKind) ([]byte, error)
func PrimitiveLikeToJSON ¶ added in v1.22.0
func PrimitiveLikeToJSON(x *PrimitiveLike) ([]byte, error)
func RefNameToJSON ¶ added in v1.20.0
func RequiredToJSON ¶ added in v1.20.0
func ShapeToJSON ¶ added in v1.20.0
func StringLikeToJSON ¶ added in v1.20.0
func StringLikeToJSON(x *StringLike) ([]byte, error)
func StructLikeToJSON ¶ added in v1.20.0
func StructLikeToJSON(x *StructLike) ([]byte, error)
func TagsToDesc ¶ added in v1.20.0
func ToGoFullTypeNameFromReflect ¶ added in v1.21.0
ToGoFullTypeNameFromReflect returns full type name with package name example:
github.com/widmogrod/mkunion/x/schema.Any string
func ToGoPkgImportName ¶ added in v1.21.0
func ToGoPkgName ¶ added in v1.21.0
func ToGoTypeName ¶ added in v1.21.0
func ToGoTypeName(x Shape, options ...ToGoTypeNameOption) string
func ToGoTypeNameFromReflect ¶ added in v1.21.0
ToGoTypeNameFromReflect returns type name without package name example:
schema.Any string
func ToGoTypeParamsNames ¶ added in v1.21.0
func ToJsonSchema ¶ added in v1.20.0
ToJsonSchema converts a Shape to a JSON Schema following specification https://json-schema.org/specification
func ToOpenAIFunctionDefinition ¶ added in v1.20.0
func ToTypeScript ¶
func ToTypeScript(x Shape, option *TypeScriptOptions) string
func UInt16ToJSON ¶ added in v1.20.1
func UInt32ToJSON ¶ added in v1.20.1
func UInt64ToJSON ¶ added in v1.20.1
func UInt8ToJSON ¶ added in v1.20.1
func UIntToJSON ¶ added in v1.23.0
func UnionLikeToJSON ¶ added in v1.20.0
func UnwrapPointer ¶ added in v1.21.0
Types ¶
type AliasLike ¶ added in v1.20.2
type AliasLike struct { Name string PkgName string PkgImportName string IsAlias bool Type Shape Tags map[string]Tag }
func AliasLikeFromJSON ¶ added in v1.20.2
func (*AliasLike) AcceptShape ¶ added in v1.20.2
func (r *AliasLike) AcceptShape(v ShapeVisitor) any
func (*AliasLike) MarshalJSON ¶ added in v1.20.2
func (*AliasLike) UnmarshalJSON ¶ added in v1.20.2
type AndGuard ¶
type AndGuard struct {
L []Guard
}
Regexp struct { Regexp string }
Between struct { Min int Max int }
func AndGuardFromJSON ¶ added in v1.20.0
func (*AndGuard) AcceptGuard ¶
func (r *AndGuard) AcceptGuard(v GuardVisitor) any
func (*AndGuard) MarshalJSON ¶ added in v1.20.0
func (*AndGuard) UnmarshalJSON ¶ added in v1.20.0
type Any ¶
type Any struct{}
func AnyFromJSON ¶ added in v1.20.0
func (*Any) AcceptShape ¶
func (r *Any) AcceptShape(v ShapeVisitor) any
func (*Any) MarshalJSON ¶ added in v1.20.0
func (*Any) UnmarshalJSON ¶ added in v1.20.0
type BooleanLike ¶
type BooleanLike struct{}
func BooleanLikeFromJSON ¶ added in v1.20.0
func BooleanLikeFromJSON(x []byte) (*BooleanLike, error)
func (*BooleanLike) AcceptPrimitiveKind ¶ added in v1.22.0
func (r *BooleanLike) AcceptPrimitiveKind(v PrimitiveKindVisitor) any
func (*BooleanLike) MarshalJSON ¶ added in v1.20.0
func (r *BooleanLike) MarshalJSON() ([]byte, error)
func (*BooleanLike) UnmarshalJSON ¶ added in v1.20.0
func (r *BooleanLike) UnmarshalJSON(data []byte) error
type Enum ¶ added in v1.20.0
type Enum struct {
Val []string
}
func EnumFromJSON ¶ added in v1.20.0
func (*Enum) AcceptGuard ¶ added in v1.20.0
func (r *Enum) AcceptGuard(v GuardVisitor) any
func (*Enum) MarshalJSON ¶ added in v1.20.0
func (*Enum) UnmarshalJSON ¶ added in v1.20.0
type Float32 ¶ added in v1.20.1
type Float32 struct{}
func Float32FromJSON ¶ added in v1.20.1
func (*Float32) AcceptNumberKind ¶ added in v1.20.1
func (r *Float32) AcceptNumberKind(v NumberKindVisitor) any
func (*Float32) MarshalJSON ¶ added in v1.20.1
func (*Float32) UnmarshalJSON ¶ added in v1.20.1
type Float64 ¶ added in v1.20.1
type Float64 struct{}
func Float64FromJSON ¶ added in v1.20.1
func (*Float64) AcceptNumberKind ¶ added in v1.20.1
func (r *Float64) AcceptNumberKind(v NumberKindVisitor) any
func (*Float64) MarshalJSON ¶ added in v1.20.1
func (*Float64) UnmarshalJSON ¶ added in v1.20.1
type FromASTOption ¶ added in v1.20.2
type FromASTOption func(x Shape)
type Guard ¶
type Guard interface {
AcceptGuard(g GuardVisitor) any
}
func ConcatGuard ¶ added in v1.20.0
func GuardFromJSON ¶ added in v1.20.0
func TagsToGuard ¶ added in v1.20.0
type GuardUnionJSON ¶ added in v1.20.0
type GuardUnionJSON struct { Type string `json:"$type,omitempty"` Enum json.RawMessage `json:"shape.Enum,omitempty"` Required json.RawMessage `json:"shape.Required,omitempty"` AndGuard json.RawMessage `json:"shape.AndGuard,omitempty"` }
type GuardVisitor ¶
type InferredInfo ¶ added in v1.20.0
type InferredInfo struct {
// contains filtered or unexported fields
}
func InferFromFile ¶ added in v1.20.0
func InferFromFile(filename string) (*InferredInfo, error)
func (*InferredInfo) PackageImportName ¶ added in v1.21.0
func (f *InferredInfo) PackageImportName() string
func (*InferredInfo) PackageName ¶ added in v1.20.0
func (f *InferredInfo) PackageName() string
func (*InferredInfo) RetrieveShapeNamedAs ¶ added in v1.21.0
func (f *InferredInfo) RetrieveShapeNamedAs(name string) Shape
func (*InferredInfo) RetrieveShapes ¶ added in v1.21.0
func (f *InferredInfo) RetrieveShapes() []Shape
func (*InferredInfo) RetrieveShapesTaggedAs ¶ added in v1.21.0
func (f *InferredInfo) RetrieveShapesTaggedAs(tagName string) []Shape
func (*InferredInfo) RetrieveStruct ¶ added in v1.20.0
func (f *InferredInfo) RetrieveStruct(name string) *StructLike
func (*InferredInfo) RetrieveStructs ¶ added in v1.20.2
func (f *InferredInfo) RetrieveStructs() []*StructLike
func (*InferredInfo) RetrieveUnion ¶ added in v1.20.0
func (f *InferredInfo) RetrieveUnion(name string) *UnionLike
func (*InferredInfo) RetrieveUnions ¶ added in v1.20.0
func (f *InferredInfo) RetrieveUnions() []*UnionLike
type Int ¶ added in v1.23.0
type Int struct{}
func IntFromJSON ¶ added in v1.23.0
func (*Int) AcceptNumberKind ¶ added in v1.23.0
func (r *Int) AcceptNumberKind(v NumberKindVisitor) any
func (*Int) MarshalJSON ¶ added in v1.23.0
func (*Int) UnmarshalJSON ¶ added in v1.23.0
type Int16 ¶ added in v1.20.1
type Int16 struct{}
func Int16FromJSON ¶ added in v1.20.1
func (*Int16) AcceptNumberKind ¶ added in v1.20.1
func (r *Int16) AcceptNumberKind(v NumberKindVisitor) any
func (*Int16) MarshalJSON ¶ added in v1.20.1
func (*Int16) UnmarshalJSON ¶ added in v1.20.1
type Int32 ¶ added in v1.20.1
type Int32 struct{}
func Int32FromJSON ¶ added in v1.20.1
func (*Int32) AcceptNumberKind ¶ added in v1.20.1
func (r *Int32) AcceptNumberKind(v NumberKindVisitor) any
func (*Int32) MarshalJSON ¶ added in v1.20.1
func (*Int32) UnmarshalJSON ¶ added in v1.20.1
type Int64 ¶ added in v1.20.1
type Int64 struct{}
func Int64FromJSON ¶ added in v1.20.1
func (*Int64) AcceptNumberKind ¶ added in v1.20.1
func (r *Int64) AcceptNumberKind(v NumberKindVisitor) any
func (*Int64) MarshalJSON ¶ added in v1.20.1
func (*Int64) UnmarshalJSON ¶ added in v1.20.1
type Int8 ¶ added in v1.20.1
type Int8 struct{}
func Int8FromJSON ¶ added in v1.20.1
func (*Int8) AcceptNumberKind ¶ added in v1.20.1
func (r *Int8) AcceptNumberKind(v NumberKindVisitor) any
func (*Int8) MarshalJSON ¶ added in v1.20.1
func (*Int8) UnmarshalJSON ¶ added in v1.20.1
type ListLike ¶
type ListLike struct { //Extend *ListLike //Guard Guard Element Shape // ArrayLen is a pointer to int, when it's nil, it means it's a slice. ArrayLen *int }
func ListLikeFromJSON ¶ added in v1.20.0
func (*ListLike) AcceptShape ¶
func (r *ListLike) AcceptShape(v ShapeVisitor) any
func (*ListLike) MarshalJSON ¶ added in v1.20.0
func (*ListLike) UnmarshalJSON ¶ added in v1.20.0
type MapLike ¶
func MapLikeFromJSON ¶ added in v1.20.0
func (*MapLike) AcceptShape ¶
func (r *MapLike) AcceptShape(v ShapeVisitor) any
func (*MapLike) MarshalJSON ¶ added in v1.20.0
func (*MapLike) UnmarshalJSON ¶ added in v1.20.0
type NumberKind ¶ added in v1.20.1
type NumberKind interface {
AcceptNumberKind(g NumberKindVisitor) any
}
func NumberKindFromJSON ¶ added in v1.20.1
func NumberKindFromJSON(x []byte) (NumberKind, error)
type NumberKindUnionJSON ¶ added in v1.20.1
type NumberKindUnionJSON struct { Type string `json:"$type,omitempty"` UInt json.RawMessage `json:"shape.UInt,omitempty"` UInt8 json.RawMessage `json:"shape.UInt8,omitempty"` UInt16 json.RawMessage `json:"shape.UInt16,omitempty"` UInt32 json.RawMessage `json:"shape.UInt32,omitempty"` UInt64 json.RawMessage `json:"shape.UInt64,omitempty"` Int json.RawMessage `json:"shape.Int,omitempty"` Int8 json.RawMessage `json:"shape.Int8,omitempty"` Int16 json.RawMessage `json:"shape.Int16,omitempty"` Int32 json.RawMessage `json:"shape.Int32,omitempty"` Int64 json.RawMessage `json:"shape.Int64,omitempty"` Float32 json.RawMessage `json:"shape.Float32,omitempty"` Float64 json.RawMessage `json:"shape.Float64,omitempty"` }
type NumberKindVisitor ¶ added in v1.20.1
type NumberKindVisitor interface { VisitUInt(v *UInt) any VisitUInt8(v *UInt8) any VisitUInt16(v *UInt16) any VisitUInt32(v *UInt32) any VisitUInt64(v *UInt64) any VisitInt(v *Int) any VisitInt8(v *Int8) any VisitInt16(v *Int16) any VisitInt32(v *Int32) any VisitInt64(v *Int64) any VisitFloat32(v *Float32) any VisitFloat64(v *Float64) any }
type NumberLike ¶
type NumberLike struct {
Kind NumberKind
}
func NumberLikeFromJSON ¶ added in v1.20.0
func NumberLikeFromJSON(x []byte) (*NumberLike, error)
func (*NumberLike) AcceptPrimitiveKind ¶ added in v1.22.0
func (r *NumberLike) AcceptPrimitiveKind(v PrimitiveKindVisitor) any
func (*NumberLike) MarshalJSON ¶ added in v1.20.0
func (r *NumberLike) MarshalJSON() ([]byte, error)
func (*NumberLike) UnmarshalJSON ¶ added in v1.20.0
func (r *NumberLike) UnmarshalJSON(data []byte) error
type PointerLike ¶ added in v1.22.0
type PointerLike struct {
Type Shape
}
func PointerLikeFromJSON ¶ added in v1.22.0
func PointerLikeFromJSON(x []byte) (*PointerLike, error)
func (*PointerLike) AcceptShape ¶ added in v1.22.0
func (r *PointerLike) AcceptShape(v ShapeVisitor) any
func (*PointerLike) MarshalJSON ¶ added in v1.22.0
func (r *PointerLike) MarshalJSON() ([]byte, error)
func (*PointerLike) UnmarshalJSON ¶ added in v1.22.0
func (r *PointerLike) UnmarshalJSON(data []byte) error
type PrimitiveKind ¶ added in v1.22.0
type PrimitiveKind interface {
AcceptPrimitiveKind(g PrimitiveKindVisitor) any
}
func PrimitiveKindFromJSON ¶ added in v1.22.0
func PrimitiveKindFromJSON(x []byte) (PrimitiveKind, error)
type PrimitiveKindUnionJSON ¶ added in v1.22.0
type PrimitiveKindUnionJSON struct { Type string `json:"$type,omitempty"` BooleanLike json.RawMessage `json:"shape.BooleanLike,omitempty"` StringLike json.RawMessage `json:"shape.StringLike,omitempty"` NumberLike json.RawMessage `json:"shape.NumberLike,omitempty"` }
type PrimitiveKindVisitor ¶ added in v1.22.0
type PrimitiveKindVisitor interface { VisitBooleanLike(v *BooleanLike) any VisitStringLike(v *StringLike) any VisitNumberLike(v *NumberLike) any }
type PrimitiveLike ¶ added in v1.22.0
type PrimitiveLike struct {
Kind PrimitiveKind
}
func PrimitiveLikeFromJSON ¶ added in v1.22.0
func PrimitiveLikeFromJSON(x []byte) (*PrimitiveLike, error)
func (*PrimitiveLike) AcceptShape ¶ added in v1.22.0
func (r *PrimitiveLike) AcceptShape(v ShapeVisitor) any
func (*PrimitiveLike) MarshalJSON ¶ added in v1.22.0
func (r *PrimitiveLike) MarshalJSON() ([]byte, error)
func (*PrimitiveLike) UnmarshalJSON ¶ added in v1.22.0
func (r *PrimitiveLike) UnmarshalJSON(data []byte) error
type RefName ¶
func ExtractRefs ¶ added in v1.21.0
func MkRefNameFromReflect ¶ added in v1.21.0
func MkRefNameFromString ¶ added in v1.21.0
func RefNameFromJSON ¶ added in v1.20.0
func (*RefName) AcceptShape ¶
func (r *RefName) AcceptShape(v ShapeVisitor) any
func (*RefName) MarshalJSON ¶ added in v1.20.0
func (*RefName) UnmarshalJSON ¶ added in v1.20.0
type Required ¶ added in v1.20.0
type Required struct{}
func RequiredFromJSON ¶ added in v1.20.0
func (*Required) AcceptGuard ¶ added in v1.20.0
func (r *Required) AcceptGuard(v GuardVisitor) any
func (*Required) MarshalJSON ¶ added in v1.20.0
func (*Required) UnmarshalJSON ¶ added in v1.20.0
type Shape ¶
type Shape interface {
AcceptShape(g ShapeVisitor) any
}
func AliasLikeShape ¶ added in v1.20.2
func AliasLikeShape() Shape
func AndGuardShape ¶ added in v1.20.0
func AndGuardShape() Shape
func BooleanLikeShape ¶ added in v1.20.0
func BooleanLikeShape() Shape
func CleanTypeThatAreOvershadowByTypeParam ¶ added in v1.21.0
func Float32Shape ¶ added in v1.20.1
func Float32Shape() Shape
func Float64Shape ¶ added in v1.20.1
func Float64Shape() Shape
func FromAST ¶ added in v1.20.2
func FromAST(x any, fx ...FromASTOption) Shape
func FromGoReflect ¶
func GuardShape ¶ added in v1.20.0
func GuardShape() Shape
func InstantiateTypeThatAreOvershadowByTypeParam ¶ added in v1.21.0
func Int16Shape ¶ added in v1.20.1
func Int16Shape() Shape
func Int32Shape ¶ added in v1.20.1
func Int32Shape() Shape
func Int64Shape ¶ added in v1.20.1
func Int64Shape() Shape
func ListLikeShape ¶ added in v1.20.0
func ListLikeShape() Shape
func LookupPkgShapeOnDisk ¶ added in v1.21.0
LookupPkgShapeOnDisk scans filesystem for all shapes in pkgImportName. it's suited for generators, that parse AST
func LookupShape ¶ added in v1.20.0
LookupShape scans registry for shapes. it's suited for runtime and compiled code
func LookupShapeOnDisk ¶ added in v1.21.0
LookupShapeOnDisk scans filesystem for shapes. it's suited for generators, that parse AST
func LookupShapeReflectAndIndex ¶ added in v1.21.0
func MapLikeShape ¶ added in v1.20.0
func MapLikeShape() Shape
func NumberKindShape ¶ added in v1.20.1
func NumberKindShape() Shape
func NumberLikeShape ¶ added in v1.20.0
func NumberLikeShape() Shape
func PointerLikeShape ¶ added in v1.22.0
func PointerLikeShape() Shape
func PrimitiveKindShape ¶ added in v1.22.0
func PrimitiveKindShape() Shape
func PrimitiveLikeShape ¶ added in v1.22.0
func PrimitiveLikeShape() Shape
func RefNameShape ¶ added in v1.20.0
func RefNameShape() Shape
func RequiredShape ¶ added in v1.20.0
func RequiredShape() Shape
func ShapeFromJSON ¶ added in v1.20.0
func ShapeShape ¶ added in v1.20.0
func ShapeShape() Shape
func StringLikeShape ¶ added in v1.20.0
func StringLikeShape() Shape
func StructLikeShape ¶ added in v1.20.0
func StructLikeShape() Shape
func ToGoTypeParamsTypes ¶ added in v1.21.0
func ToTypeScriptOptimisation ¶ added in v1.20.1
func TypeParamShape ¶ added in v1.21.0
func TypeParamShape() Shape
func UInt16Shape ¶ added in v1.20.1
func UInt16Shape() Shape
func UInt32Shape ¶ added in v1.20.1
func UInt32Shape() Shape
func UInt64Shape ¶ added in v1.20.1
func UInt64Shape() Shape
func UInt8Shape ¶ added in v1.20.1
func UInt8Shape() Shape
func UnionLikeShape ¶ added in v1.20.0
func UnionLikeShape() Shape
type ShapeUnionJSON ¶ added in v1.20.0
type ShapeUnionJSON struct { Type string `json:"$type,omitempty"` Any json.RawMessage `json:"shape.Any,omitempty"` RefName json.RawMessage `json:"shape.RefName,omitempty"` PointerLike json.RawMessage `json:"shape.PointerLike,omitempty"` AliasLike json.RawMessage `json:"shape.AliasLike,omitempty"` PrimitiveLike json.RawMessage `json:"shape.PrimitiveLike,omitempty"` ListLike json.RawMessage `json:"shape.ListLike,omitempty"` MapLike json.RawMessage `json:"shape.MapLike,omitempty"` StructLike json.RawMessage `json:"shape.StructLike,omitempty"` UnionLike json.RawMessage `json:"shape.UnionLike,omitempty"` }
type ShapeVisitor ¶
type ShapeVisitor interface { VisitAny(v *Any) any VisitRefName(v *RefName) any VisitPointerLike(v *PointerLike) any VisitAliasLike(v *AliasLike) any VisitPrimitiveLike(v *PrimitiveLike) any VisitListLike(v *ListLike) any VisitMapLike(v *MapLike) any VisitStructLike(v *StructLike) any VisitUnionLike(v *UnionLike) any }
type StringLike ¶
type StringLike struct { }
StringLike is a string type, and when it has name, it means it named type. For example:
type C string
func StringLikeFromJSON ¶ added in v1.20.0
func StringLikeFromJSON(x []byte) (*StringLike, error)
func (*StringLike) AcceptPrimitiveKind ¶ added in v1.22.0
func (r *StringLike) AcceptPrimitiveKind(v PrimitiveKindVisitor) any
func (*StringLike) MarshalJSON ¶ added in v1.20.0
func (r *StringLike) MarshalJSON() ([]byte, error)
func (*StringLike) UnmarshalJSON ¶ added in v1.20.0
func (r *StringLike) UnmarshalJSON(data []byte) error
type StructLike ¶
type StructLike struct { Name string PkgName string PkgImportName string TypeParams []TypeParam Fields []*FieldLike Tags map[string]Tag }
func StructLikeFromJSON ¶ added in v1.20.0
func StructLikeFromJSON(x []byte) (*StructLike, error)
func (*StructLike) AcceptShape ¶
func (r *StructLike) AcceptShape(v ShapeVisitor) any
func (*StructLike) MarshalJSON ¶ added in v1.20.0
func (r *StructLike) MarshalJSON() ([]byte, error)
func (*StructLike) UnmarshalJSON ¶ added in v1.20.0
func (r *StructLike) UnmarshalJSON(data []byte) error
type ToGoTypeNameOption ¶ added in v1.21.0
type ToGoTypeNameOption string
func WithInstantiation ¶ added in v1.21.0
func WithInstantiation() ToGoTypeNameOption
func WithPkgImportName ¶ added in v1.21.0
func WithPkgImportName() ToGoTypeNameOption
func WithRootPackage ¶ added in v1.21.0
func WithRootPackage(pkgName string) ToGoTypeNameOption
type TypeParam ¶ added in v1.20.2
func (*TypeParam) MarshalJSON ¶ added in v1.21.0
func (*TypeParam) UnmarshalJSON ¶ added in v1.21.0
type TypeScriptOptions ¶
type TypeScriptOptions struct {
// contains filtered or unexported fields
}
func (*TypeScriptOptions) IsCurrentPkgName ¶
func (o *TypeScriptOptions) IsCurrentPkgName(pkgName string) bool
func (*TypeScriptOptions) NeedsToImportPkgName ¶
func (o *TypeScriptOptions) NeedsToImportPkgName(pkg packageName, imp packageImportName)
type TypeScriptRenderer ¶
type TypeScriptRenderer struct {
// contains filtered or unexported fields
}
func NewTypeScriptRenderer ¶
func NewTypeScriptRenderer() *TypeScriptRenderer
func (*TypeScriptRenderer) AddShape ¶ added in v1.21.0
func (r *TypeScriptRenderer) AddShape(x Shape)
func (*TypeScriptRenderer) FollowImports ¶ added in v1.21.0
func (r *TypeScriptRenderer) FollowImports()
func (*TypeScriptRenderer) FollowRef ¶ added in v1.21.0
func (r *TypeScriptRenderer) FollowRef(x Shape)
func (*TypeScriptRenderer) WriteToDir ¶
func (r *TypeScriptRenderer) WriteToDir(dir string) error
type UInt ¶ added in v1.23.0
type UInt struct{}
func UIntFromJSON ¶ added in v1.23.0
func (*UInt) AcceptNumberKind ¶ added in v1.23.0
func (r *UInt) AcceptNumberKind(v NumberKindVisitor) any
func (*UInt) MarshalJSON ¶ added in v1.23.0
func (*UInt) UnmarshalJSON ¶ added in v1.23.0
type UInt16 ¶ added in v1.20.1
type UInt16 struct{}
func UInt16FromJSON ¶ added in v1.20.1
func (*UInt16) AcceptNumberKind ¶ added in v1.20.1
func (r *UInt16) AcceptNumberKind(v NumberKindVisitor) any
func (*UInt16) MarshalJSON ¶ added in v1.20.1
func (*UInt16) UnmarshalJSON ¶ added in v1.20.1
type UInt32 ¶ added in v1.20.1
type UInt32 struct{}
func UInt32FromJSON ¶ added in v1.20.1
func (*UInt32) AcceptNumberKind ¶ added in v1.20.1
func (r *UInt32) AcceptNumberKind(v NumberKindVisitor) any
func (*UInt32) MarshalJSON ¶ added in v1.20.1
func (*UInt32) UnmarshalJSON ¶ added in v1.20.1
type UInt64 ¶ added in v1.20.1
type UInt64 struct{}
func UInt64FromJSON ¶ added in v1.20.1
func (*UInt64) AcceptNumberKind ¶ added in v1.20.1
func (r *UInt64) AcceptNumberKind(v NumberKindVisitor) any
func (*UInt64) MarshalJSON ¶ added in v1.20.1
func (*UInt64) UnmarshalJSON ¶ added in v1.20.1
type UInt8 ¶ added in v1.20.1
type UInt8 struct{}
func UInt8FromJSON ¶ added in v1.20.1
func (*UInt8) AcceptNumberKind ¶ added in v1.20.1
func (r *UInt8) AcceptNumberKind(v NumberKindVisitor) any
func (*UInt8) MarshalJSON ¶ added in v1.20.1
func (*UInt8) UnmarshalJSON ¶ added in v1.20.1
type UnionLike ¶
type UnionLike struct { Name string PkgName string PkgImportName string Variant []Shape Tags map[string]Tag }
func UnionLikeFromJSON ¶ added in v1.20.0
func (*UnionLike) AcceptShape ¶
func (r *UnionLike) AcceptShape(v ShapeVisitor) any