Documentation
¶
Index ¶
- func CallOptionalFunc(ctx context.Context, i *interp.Interpreter, ...) (bool, error)
- func CompileAndRegister(ctx context.Context, source string, options CompileOptions) (*interp.Interpreter, error)
- func CompileFromDir(ctx context.Context, dir string, options CompileOptions) (*interp.Interpreter, string, error)
- func FindFunctionsPath(dir string) string
- func HookAPIExports() interp.Exports
- func ParseKVArgs(args []any) map[string]any
- type CompileOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CallOptionalFunc ¶
func CallOptionalFunc(ctx context.Context, i *interp.Interpreter, packageName, funcName, subject string, args []any) (bool, error)
CallOptionalFunc 调用脚本包中的可选函数;函数不存在时返回 false, nil。 生命周期函数复用 Register 的参数校验规则,并允许函数返回 error。
func CompileAndRegister ¶
func CompileAndRegister(ctx context.Context, source string, options CompileOptions) (*interp.Interpreter, error)
CompileAndRegister 编译脚本源码,并调用脚本包中的 Register 函数。
func CompileFromDir ¶
func CompileFromDir(ctx context.Context, dir string, options CompileOptions) (*interp.Interpreter, string, error)
CompileFromDir 从目录中查找并编译 functions 脚本,返回解释器实例和源码内容。 如果目录中没有 functions 文件,返回 nil, "", nil。
func FindFunctionsPath ¶
FindFunctionsPath 返回扩展目录下优先匹配的 functions 脚本路径。 主题和插件共用同一套查找规则:优先 functions.go,其次 functions.goyaegi。
func HookAPIExports ¶
HookAPIExports 返回主题和插件脚本共用的 hook API yaegi 导出表。 保持唯一来源,避免 internal/plugin 与 internal/theme 各维护一份类型/常量清单。 yaegi 的 Exports API 要求用 reflect.Value 描述宿主侧导出的类型、函数和常量, 这里的反射是解释器边界所必需,不参与业务运行时分发。
func ParseKVArgs ¶
ParseKVArgs 解析 key-value 参数对为 map[string]any。 例如 ("n", 5, "tag", "go") → {"n": 5, "tag": "go"}。
Types ¶
Click to show internal directories.
Click to hide internal directories.