src

package
v0.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCode

func GenerateCode(iface InterfaceInfo, outputDir string) error

GenerateCode generates implementation code for an interface

func ProcessInterface

func ProcessInterface(iface InterfaceInfo, outputDir string) error

ProcessInterface handles processing of an interface for code generation

Types

type FieldInfo

type FieldInfo struct {
	Name      string
	Type      string
	MapSource string // mapsource 标签值
}

字段信息

type InterfaceInfo

type InterfaceInfo struct {
	Name        string       // 接口名称
	PackageName string       // 包名
	Depends     []string     // 依赖的包
	Methods     []MethodInfo // 接口方法
	FilePath    string       // 文件路径
	Comment     string       // 注释
}

表示解析到的接口信息

func ParseFile

func ParseFile(filePath string) ([]InterfaceInfo, error)

ParseFile 解析单个Go文件,查找带有特定注释的接口定义

type MethodInfo

type MethodInfo struct {
	Name    string      // 方法名称
	Params  []ParamInfo // 参数信息
	Results []ParamInfo // 返回值信息
	Comment []string    // 方法注释
}

表示接口方法信息

type ParamInfo

type ParamInfo struct {
	Name string // 参数名称
	Type string // 参数类型
}

表示参数或返回值信息

type StructInfo

type StructInfo struct {
	Name   string
	Fields []FieldInfo
}

创建一个用于生成代码的结构体信息

func FindStructInfo

func FindStructInfo(filePath string, structName string) (*StructInfo, error)

查找并解析结构体信息

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL