Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Generate ¶
func Generate(w io.Writer, pkgName string, svc *ServiceInfo) error
Generate writes the .gen.go file for the service to w.
func GenerateFile ¶
func GenerateFile(outputPath string, pkgName string, svc *ServiceInfo) error
GenerateFile writes the .gen.go file to the specified path. outputPath is the full path for the output .gen.go file.
func GenerateSchema ¶
GenerateSchema produces a JSON Schema map[string]any from a go/types Type. It handles: string, int/uint variants, float variants, bool, slices, maps, structs, pointers, any. For structs: reads json tags for field names and omitempty, reads doc comments from the AST for field descriptions, reads //tool:enum annotations for enum values.
Types ¶
type MethodInfo ¶
type MethodInfo struct {
GoName string // Go method name (e.g., "GetWeather")
ToolName string // tool name: //tool:name value, or snake_case(GoName)
Desc string // from //tool:desc annotation
ReqType types.Type // the request parameter type (2nd param, after ctx)
RespType types.Type // the first return type
FieldComments map[string]string // key: "TypeName.FieldName" -> combined doc comment + //tool: annotations
}
MethodInfo holds metadata for a single tool method.
type ServiceInfo ¶
type ServiceInfo struct {
Name string // from //tool:service annotation
PkgPath string // full package import path
Methods []MethodInfo
}
ServiceInfo holds the parsed service metadata.
func ParseService ¶
func ParseService(filename string) (*ServiceInfo, error)
ParseService parses a Go source file and extracts the first //tool:service annotated interface. Returns ServiceInfo with all tool methods and their parameter/return types resolved via go/types.