Documentation
¶
Overview ¶
Package parser extracts function signatures and types from Go source files.
Index ¶
- func GoTypeToJSExtraction(t GoType, argExpr string, workerMode bool) string
- func GoTypeToJSReturn(t GoType, valueExpr string) string
- func GoTypeToTS(t GoType) string
- func HasSelectInMain(path string) (bool, error)
- type GoField
- type GoFunction
- type GoParameter
- type GoType
- type ParsedFile
- type TypeKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GoTypeToJSExtraction ¶
GoTypeToJSExtraction generates JavaScript code to extract a value from js.Value argExpr is the expression representing the js.Value argument (e.g., "args[0]") workerMode determines whether to generate worker-compatible callback code
func GoTypeToJSReturn ¶
GoTypeToJSReturn generates JavaScript return conversion code valueExpr is the Go expression to convert (e.g., "result")
func GoTypeToTS ¶
GoTypeToTS converts a GoType to TypeScript type string
func HasSelectInMain ¶ added in v1.0.1
HasSelectInMain checks if a Go source file has a main function containing select {}. This is required for WASM modules to stay alive and receive JavaScript calls.
Types ¶
type GoField ¶
type GoField struct {
Name string // Field name
Type GoType // Field type
JSONTag string // JSON tag value (if present)
}
GoField represents a single field in a struct
type GoFunction ¶
type GoFunction struct {
Name string // Function name
Params []GoParameter // Function parameters
Returns []GoType // Return types
Doc string // Documentation comment
}
GoFunction represents a parsed exported function
type GoParameter ¶
GoParameter represents a single function parameter
type GoType ¶
type GoType struct {
Name string // Type name (e.g., "string", "User", "[]string")
Kind TypeKind // Category of the type
Elem *GoType // Element type for slices/arrays/pointers
Key *GoType // Key type for maps
Value *GoType // Value type for maps
Fields []GoField // Fields for struct types
IsError bool // True if this is the error type
// For KindFunction (void callbacks only)
CallbackParams []GoType // Parameter types of the callback (nil if not a callback)
IsVoid bool // True if callback has no return value (for validator)
}
GoType represents a parsed Go type with full structural information
type ParsedFile ¶
type ParsedFile struct {
Package string // Package name
Functions []GoFunction // Exported functions
Types map[string]*GoType // Type definitions in the file
}
ParsedFile represents a parsed Go source file
func ParseSourceFile ¶
func ParseSourceFile(path string) (*ParsedFile, error)
ParseSourceFile parses a Go source file and extracts exported functions and types