Documentation ¶
Overview ¶
Code generated by mkunion. DO NOT EDIT.
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 ExtractTags(tag string) map[string]FieldTag
- func Float32ToJSON(x *Float32) ([]byte, error)
- func Float64ToJSON(x *Float64) ([]byte, error)
- func GuardSchemaDef() *schema.UnionVariants[Guard]
- func GuardToJSON(x Guard) ([]byte, error)
- 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 IsAlias(t *ast.TypeSpec) bool
- func IsStarExpr(x ast.Expr) bool
- func JsonParseObject(x []byte, f func(key string, value []byte) error) error
- func ListLikeToJSON(x *ListLike) ([]byte, error)
- func MapLikeToJSON(x *MapLike) ([]byte, error)
- func MatchGuard[TOut any](x Guard, f1 func(x *Enum) TOut, f2 func(x *Required) TOut, ...) TOut
- func MatchGuardR2[TOut1, TOut2 any](x Guard, f1 func(x *Enum) (TOut1, TOut2), f2 func(x *Required) (TOut1, TOut2), ...) (TOut1, TOut2)
- func MatchNumberKind[TOut any](x NumberKind, f1 func(x *UInt8) TOut, f2 func(x *UInt16) TOut, ...) TOut
- func MatchNumberKindR2[TOut1, TOut2 any](x NumberKind, f1 func(x *UInt8) (TOut1, TOut2), ...) (TOut1, TOut2)
- func MatchShape[TOut any](x Shape, f1 func(x *Any) TOut, f2 func(x *RefName) TOut, ...) TOut
- func MatchShapeR2[TOut1, TOut2 any](x Shape, f1 func(x *Any) (TOut1, TOut2), f2 func(x *RefName) (TOut1, TOut2), ...) (TOut1, TOut2)
- func MustMatchGuard[TOut any](x Guard, f1 func(x *Enum) TOut, f2 func(x *Required) TOut, ...) TOut
- func MustMatchGuardR0(x Guard, f1 func(x *Enum), f2 func(x *Required), f3 func(x *AndGuard))
- func MustMatchGuardR2[TOut1, TOut2 any](x Guard, f1 func(x *Enum) (TOut1, TOut2), f2 func(x *Required) (TOut1, TOut2), ...) (TOut1, TOut2)
- func MustMatchNumberKind[TOut any](x NumberKind, f1 func(x *UInt8) TOut, f2 func(x *UInt16) TOut, ...) TOut
- func MustMatchNumberKindR0(x NumberKind, f1 func(x *UInt8), f2 func(x *UInt16), f3 func(x *UInt32), ...)
- func MustMatchNumberKindR2[TOut1, TOut2 any](x NumberKind, f1 func(x *UInt8) (TOut1, TOut2), ...) (TOut1, TOut2)
- func MustMatchShape[TOut any](x Shape, f1 func(x *Any) TOut, f2 func(x *RefName) TOut, ...) TOut
- func MustMatchShapeR0(x Shape, f1 func(x *Any), f2 func(x *RefName), f3 func(x *AliasLike), ...)
- func MustMatchShapeR2[TOut1, TOut2 any](x Shape, f1 func(x *Any) (TOut1, TOut2), f2 func(x *RefName) (TOut1, TOut2), ...) (TOut1, TOut2)
- func NumberKindSchemaDef() *schema.UnionVariants[NumberKind]
- func NumberKindToJSON(x NumberKind) ([]byte, error)
- func NumberLikeToJSON(x *NumberLike) ([]byte, error)
- func RefFullName(x *RefName) string
- func RefNameToJSON(x *RefName) ([]byte, error)
- func RequiredToJSON(x *Required) ([]byte, error)
- func ShapeSchemaDef() *schema.UnionVariants[Shape]
- func ShapeToJSON(x Shape) ([]byte, error)
- func StringLikeToJSON(x *StringLike) ([]byte, error)
- func StructFullName(x *StructLike) string
- func StructLikeToJSON(x *StructLike) ([]byte, error)
- func TagsToDesc(tags map[string]FieldTag) *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 UnionFullName(x *UnionLike) string
- func UnionLikeToJSON(x *UnionLike) ([]byte, error)
- type AliasLike
- type AndGuard
- type Any
- type BooleanLike
- type Enum
- type FieldLike
- type FieldTag
- type Float32
- type Float64
- type FromASTOption
- type Guard
- type GuardUnionJSON
- type GuardVisitor
- type InferredInfo
- func (f *InferredInfo) PossibleUnionTypes() []string
- func (f *InferredInfo) PossibleVariantsTypes(unionName string) []string
- 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 Int16
- type Int32
- type Int64
- type Int8
- type ListLike
- type MapLike
- type NumberKind
- type NumberKindUnionJSON
- type NumberKindVisitor
- type NumberLike
- type RefName
- type Required
- type Shape
- func AliasLikeShape() Shape
- func AndGuardShape() Shape
- func AnyShape() Shape
- func BooleanLikeShape() 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 Int16Shape() Shape
- func Int32Shape() Shape
- func Int64Shape() Shape
- func Int8Shape() Shape
- func ListLikeShape() Shape
- func LookupShape(x *RefName) (Shape, bool)
- func MapLikeShape() Shape
- func NumberKindShape() Shape
- func NumberLikeShape() Shape
- func RefNameShape() Shape
- func RequiredShape() Shape
- func ShapeFromJSON(x []byte) (Shape, error)
- func ShapeShape() Shape
- func StringLikeShape() Shape
- func StructLikeShape() Shape
- func ToTypeScriptOptimisation(x Shape) Shape
- func UInt16Shape() Shape
- func UInt32Shape() Shape
- func UInt64Shape() Shape
- func UInt8Shape() Shape
- func UnionLikeShape() Shape
- type ShapeUnionJSON
- type ShapeVisitor
- type StringLike
- type StructLike
- type TypeParam
- type TypeScriptOptions
- type TypeScriptRenderer
- type UInt16
- type UInt32
- type UInt64
- type UInt8
- type UnionLike
Constants ¶
This section is empty.
Variables ¶
var TypeStringToNumberKindMap = map[string]NumberKind{ "uint8": &UInt8{}, "uint16": &UInt16{}, "uint32": &UInt32{}, "uint64": &UInt64{}, "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 ExtractTags ¶ added in v1.20.0
func Float32ToJSON ¶ added in v1.20.1
func Float64ToJSON ¶ added in v1.20.1
func GuardSchemaDef ¶
func GuardSchemaDef() *schema.UnionVariants[Guard]
func GuardToJSON ¶ added in v1.20.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 IsStarExpr ¶ added in v1.20.0
func JsonParseObject ¶ added in v1.20.0
func ListLikeToJSON ¶ added in v1.20.0
func MapLikeToJSON ¶ added in v1.20.0
func MatchGuard ¶
func MatchGuardR2 ¶
func MatchNumberKind ¶ added in v1.20.1
func MatchNumberKind[TOut any]( x NumberKind, f1 func(x *UInt8) TOut, f2 func(x *UInt16) TOut, f3 func(x *UInt32) TOut, f4 func(x *UInt64) TOut, f5 func(x *Int8) TOut, f6 func(x *Int16) TOut, f7 func(x *Int32) TOut, f8 func(x *Int64) TOut, f9 func(x *Float32) TOut, f10 func(x *Float64) TOut, df func(x NumberKind) TOut, ) TOut
func MatchNumberKindR2 ¶ added in v1.20.1
func MatchNumberKindR2[TOut1, TOut2 any]( x NumberKind, f1 func(x *UInt8) (TOut1, TOut2), f2 func(x *UInt16) (TOut1, TOut2), f3 func(x *UInt32) (TOut1, TOut2), f4 func(x *UInt64) (TOut1, TOut2), f5 func(x *Int8) (TOut1, TOut2), f6 func(x *Int16) (TOut1, TOut2), f7 func(x *Int32) (TOut1, TOut2), f8 func(x *Int64) (TOut1, TOut2), f9 func(x *Float32) (TOut1, TOut2), f10 func(x *Float64) (TOut1, TOut2), df func(x NumberKind) (TOut1, TOut2), ) (TOut1, TOut2)
func MatchShape ¶
func MatchShape[TOut any]( x Shape, f1 func(x *Any) TOut, f2 func(x *RefName) TOut, f3 func(x *AliasLike) TOut, f4 func(x *BooleanLike) TOut, f5 func(x *StringLike) TOut, f6 func(x *NumberLike) TOut, f7 func(x *ListLike) TOut, f8 func(x *MapLike) TOut, f9 func(x *StructLike) TOut, f10 func(x *UnionLike) TOut, df func(x Shape) TOut, ) TOut
func MatchShapeR2 ¶
func MatchShapeR2[TOut1, TOut2 any]( x Shape, f1 func(x *Any) (TOut1, TOut2), f2 func(x *RefName) (TOut1, TOut2), f3 func(x *AliasLike) (TOut1, TOut2), f4 func(x *BooleanLike) (TOut1, TOut2), f5 func(x *StringLike) (TOut1, TOut2), f6 func(x *NumberLike) (TOut1, TOut2), f7 func(x *ListLike) (TOut1, TOut2), f8 func(x *MapLike) (TOut1, TOut2), f9 func(x *StructLike) (TOut1, TOut2), f10 func(x *UnionLike) (TOut1, TOut2), df func(x Shape) (TOut1, TOut2), ) (TOut1, TOut2)
func MustMatchGuard ¶
func MustMatchGuardR0 ¶
func MustMatchGuardR2 ¶
func MustMatchNumberKind ¶ added in v1.20.1
func MustMatchNumberKind[TOut any]( x NumberKind, f1 func(x *UInt8) TOut, f2 func(x *UInt16) TOut, f3 func(x *UInt32) TOut, f4 func(x *UInt64) TOut, f5 func(x *Int8) TOut, f6 func(x *Int16) TOut, f7 func(x *Int32) TOut, f8 func(x *Int64) TOut, f9 func(x *Float32) TOut, f10 func(x *Float64) TOut, ) TOut
func MustMatchNumberKindR0 ¶ added in v1.20.1
func MustMatchNumberKindR2 ¶ added in v1.20.1
func MustMatchNumberKindR2[TOut1, TOut2 any]( x NumberKind, f1 func(x *UInt8) (TOut1, TOut2), f2 func(x *UInt16) (TOut1, TOut2), f3 func(x *UInt32) (TOut1, TOut2), f4 func(x *UInt64) (TOut1, TOut2), f5 func(x *Int8) (TOut1, TOut2), f6 func(x *Int16) (TOut1, TOut2), f7 func(x *Int32) (TOut1, TOut2), f8 func(x *Int64) (TOut1, TOut2), f9 func(x *Float32) (TOut1, TOut2), f10 func(x *Float64) (TOut1, TOut2), ) (TOut1, TOut2)
func MustMatchShape ¶
func MustMatchShape[TOut any]( x Shape, f1 func(x *Any) TOut, f2 func(x *RefName) TOut, f3 func(x *AliasLike) TOut, f4 func(x *BooleanLike) TOut, f5 func(x *StringLike) TOut, f6 func(x *NumberLike) TOut, f7 func(x *ListLike) TOut, f8 func(x *MapLike) TOut, f9 func(x *StructLike) TOut, f10 func(x *UnionLike) TOut, ) TOut
func MustMatchShapeR0 ¶
func MustMatchShapeR0( x Shape, f1 func(x *Any), f2 func(x *RefName), f3 func(x *AliasLike), f4 func(x *BooleanLike), f5 func(x *StringLike), f6 func(x *NumberLike), f7 func(x *ListLike), f8 func(x *MapLike), f9 func(x *StructLike), f10 func(x *UnionLike), )
func MustMatchShapeR2 ¶
func MustMatchShapeR2[TOut1, TOut2 any]( x Shape, f1 func(x *Any) (TOut1, TOut2), f2 func(x *RefName) (TOut1, TOut2), f3 func(x *AliasLike) (TOut1, TOut2), f4 func(x *BooleanLike) (TOut1, TOut2), f5 func(x *StringLike) (TOut1, TOut2), f6 func(x *NumberLike) (TOut1, TOut2), f7 func(x *ListLike) (TOut1, TOut2), f8 func(x *MapLike) (TOut1, TOut2), f9 func(x *StructLike) (TOut1, TOut2), f10 func(x *UnionLike) (TOut1, TOut2), ) (TOut1, TOut2)
func NumberKindSchemaDef ¶ added in v1.20.1
func NumberKindSchemaDef() *schema.UnionVariants[NumberKind]
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 RefFullName ¶ added in v1.20.0
func RefNameToJSON ¶ added in v1.20.0
func RequiredToJSON ¶ added in v1.20.0
func ShapeSchemaDef ¶
func ShapeSchemaDef() *schema.UnionVariants[Shape]
func ShapeToJSON ¶ added in v1.20.0
func StringLikeToJSON ¶ added in v1.20.0
func StringLikeToJSON(x *StringLike) ([]byte, error)
func StructFullName ¶ added in v1.20.0
func StructFullName(x *StructLike) string
func StructLikeToJSON ¶ added in v1.20.0
func StructLikeToJSON(x *StructLike) ([]byte, error)
func TagsToDesc ¶ added in v1.20.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 UnionFullName ¶ added in v1.20.0
func UnionLikeToJSON ¶ added in v1.20.0
Types ¶
type AliasLike ¶ added in v1.20.2
go:generate go run ../../cmd/mkunion/main.go -name=Shape
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{}
go:generate go run ../../cmd/mkunion/main.go -name=Shape
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{}
go:generate go run ../../cmd/mkunion/main.go -name=Shape
func BooleanLikeFromJSON ¶ added in v1.20.0
func BooleanLikeFromJSON(x []byte) (*BooleanLike, error)
func (*BooleanLike) AcceptShape ¶
func (r *BooleanLike) AcceptShape(v ShapeVisitor) any
func (*BooleanLike) MarshalJSON ¶ added in v1.20.0
func (self *BooleanLike) MarshalJSON() ([]byte, error)
func (*BooleanLike) UnmarshalJSON ¶ added in v1.20.0
func (self *BooleanLike) UnmarshalJSON(x []byte) error
type Enum ¶ added in v1.20.0
type Enum struct {
Val []string
}
go:generate go run ../../cmd/mkunion/main.go -name=Guard
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{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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:"github.com/widmogrod/mkunion/x/shape.Enum,omitempty"` Required json.RawMessage `json:"github.com/widmogrod/mkunion/x/shape.Required,omitempty"` AndGuard json.RawMessage `json:"github.com/widmogrod/mkunion/x/shape.AndGuard,omitempty"` }
mkunion-extension:json
type GuardVisitor ¶
type InferredInfo ¶ added in v1.20.0
type InferredInfo struct { PackageName string PkgImportName string // contains filtered or unexported fields }
func InferFromFile ¶ added in v1.20.0
func InferFromFile(filename string) (*InferredInfo, error)
func (*InferredInfo) PossibleUnionTypes ¶ added in v1.20.0
func (f *InferredInfo) PossibleUnionTypes() []string
func (*InferredInfo) PossibleVariantsTypes ¶ added in v1.20.0
func (f *InferredInfo) PossibleVariantsTypes(unionName string) []string
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 Int16 ¶ added in v1.20.1
type Int16 struct{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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 ElementIsPointer bool // ArrayLen is a pointer to int, when it's nil, it means it's a slice. ArrayLen *int }
go:generate go run ../../cmd/mkunion/main.go -name=Shape
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 ¶
type MapLike struct { //Extend *MapLike //Guard Guard Key Shape Val Shape KeyIsPointer bool ValIsPointer bool }
go:generate go run ../../cmd/mkunion/main.go -name=Shape
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"` 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"` 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"` }
mkunion-extension:json
type NumberKindVisitor ¶ added in v1.20.1
type NumberLike ¶
type NumberLike struct {
Kind NumberKind
}
go:generate go run ../../cmd/mkunion/main.go -name=Shape
func NumberLikeFromJSON ¶ added in v1.20.0
func NumberLikeFromJSON(x []byte) (*NumberLike, error)
func (*NumberLike) AcceptShape ¶
func (r *NumberLike) AcceptShape(v ShapeVisitor) any
func (*NumberLike) MarshalJSON ¶ added in v1.20.0
func (self *NumberLike) MarshalJSON() ([]byte, error)
func (*NumberLike) UnmarshalJSON ¶ added in v1.20.0
func (self *NumberLike) UnmarshalJSON(x []byte) error
type RefName ¶
type RefName struct { Name string PkgName string PkgImportName string IsPointer bool Indexed []Shape }
go:generate go run ../../cmd/mkunion/main.go -name=Shape
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{}
go:generate go run ../../cmd/mkunion/main.go -name=Guard
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 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 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 LookupShape ¶ added in v1.20.0
func MapLikeShape ¶ added in v1.20.0
func MapLikeShape() Shape
func NumberLikeShape ¶ added in v1.20.0
func NumberLikeShape() 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 StringLikeShape ¶ added in v1.20.0
func StringLikeShape() Shape
func StructLikeShape ¶ added in v1.20.0
func StructLikeShape() Shape
func ToTypeScriptOptimisation ¶ added in v1.20.1
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"` AliasLike json.RawMessage `json:"shape.AliasLike,omitempty"` BooleanLike json.RawMessage `json:"shape.BooleanLike,omitempty"` StringLike json.RawMessage `json:"shape.StringLike,omitempty"` NumberLike json.RawMessage `json:"shape.NumberLike,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"` }
mkunion-extension:json
type ShapeVisitor ¶
type ShapeVisitor interface { VisitAny(v *Any) any VisitRefName(v *RefName) any VisitAliasLike(v *AliasLike) any VisitBooleanLike(v *BooleanLike) any VisitStringLike(v *StringLike) any VisitNumberLike(v *NumberLike) 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) AcceptShape ¶
func (r *StringLike) AcceptShape(v ShapeVisitor) any
func (*StringLike) MarshalJSON ¶ added in v1.20.0
func (self *StringLike) MarshalJSON() ([]byte, error)
func (*StringLike) UnmarshalJSON ¶ added in v1.20.0
func (self *StringLike) UnmarshalJSON(x []byte) error
type StructLike ¶
type StructLike struct { Name string PkgName string PkgImportName string TypeParams []TypeParam Fields []*FieldLike }
go:generate go run ../../cmd/mkunion/main.go -name=Shape
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 (self *StructLike) MarshalJSON() ([]byte, error)
func (*StructLike) UnmarshalJSON ¶ added in v1.20.0
func (self *StructLike) UnmarshalJSON(x []byte) error
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) AddStruct ¶
func (r *TypeScriptRenderer) AddStruct(like *StructLike)
func (*TypeScriptRenderer) AddUnion ¶
func (r *TypeScriptRenderer) AddUnion(x *UnionLike)
func (*TypeScriptRenderer) WriteToDir ¶
func (r *TypeScriptRenderer) WriteToDir(dir string) error
type UInt16 ¶ added in v1.20.1
type UInt16 struct{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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{}
go:generate go run ../../cmd/mkunion/main.go -name=NumberKind
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 ¶
go:generate go run ../../cmd/mkunion/main.go -name=Shape
func UnionLikeFromJSON ¶ added in v1.20.0
func (*UnionLike) AcceptShape ¶
func (r *UnionLike) AcceptShape(v ShapeVisitor) any