Documentation
¶
Index ¶
- type JsonTag
- type Parser
- func (p *Parser) CollectEnums() error
- func (p *Parser) GoTypeImport(typ types.Type) string
- func (p *Parser) GoTypeName(typ types.Type) string
- func (p *Parser) GoTypeNameToWebrpc(typ string) string
- func (p *Parser) ParseAny(typeName string, iface *types.Interface) (*schema.VarType, error)
- func (p *Parser) ParseBasic(typ *types.Basic) (*schema.VarType, error)
- func (p *Parser) ParseInterfaceMethods(iface *types.Interface, name string) error
- func (p *Parser) ParseMap(typeName string, m *types.Map) (*schema.VarType, error)
- func (p *Parser) ParseNamedType(goTypeName string, typ types.Type) (varType *schema.VarType, err error)
- func (p *Parser) ParseSlice(typeName string, sliceTyp *types.Slice) (*schema.VarType, error)
- func (p *Parser) ParseStruct(goTypeName string, structTyp *types.Struct) (*schema.VarType, error)
- func (p *Parser) ParseType(typ types.Type) (*schema.VarType, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JsonTag ¶
func GetJsonTag ¶
type Parser ¶
type Parser struct { Schema *schema.WebRPCSchema // ParsedTypes is a cache to improve performance and so we can traverse circular dependencies. ParsedTypes map[types.Type]*schema.VarType ParsedEnumTypes map[string]*schema.Type // Helps lookup enum types by pkg easily. InlineMode bool // When traversing `json:",inline"`, we don't want to store the struct type as WebRPC message. ImportedPaths map[string]struct{} SchemaPkgName string // Schema file's package name. Pkg *packages.Package }
Parser walks the Go AST tree of a given package and returns WebRPC Schema.
Walks the AST tree sequentially, without concurrency, to handle circular and recursive types. Aggressively caches parsed types to improve performance.
func (*Parser) CollectEnums ¶
CollectEnums collects ENUM definitions, ie.:
// approved = 0 // pending = 1 // closed = 2 // new = 3 type Status gospeak.Enum[int]
func (*Parser) GoTypeNameToWebrpc ¶ added in v0.7.6
func (*Parser) ParseInterfaceMethods ¶
func (*Parser) ParseNamedType ¶
func (*Parser) ParseSlice ¶
func (*Parser) ParseStruct ¶
Click to show internal directories.
Click to hide internal directories.