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 // Cache parsed types 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 }
Parses Go source file and returns WebRPC Schema.
This Parser was designed to run sequentially, without any concurrency, so we can leverage maps to cache the already parsed types, while not having to deal with sync primitives.
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.