function

package
v0.0.0-...-de63469 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Call

type Call struct {
	Name   string
	Params *Params
}

type Callable

type Callable func(ignoreParams ...any) (resultInterfaces []any)

type Definition

type Definition struct {
	Name        string `json:"name"` // function name should be unique
	Description string `json:"description"`
	Parameters  any    `json:"parameters"`
}

Definition provides the calling information of a function

func (*Definition) String

func (d *Definition) String() string

type FuncInfo

type FuncInfo struct {
	Name       string               `json:"name"`
	Comments   string               `json:"comments"`
	SourceCode string               `json:"source_code"`
	Params     map[string]ParamInfo `json:"-"` // ignore by json
}

func GetFunctionDetails

func GetFunctionDetails(fn any) (*FuncInfo, error)

type Function

type Function struct {
	// contains filtered or unexported fields
}

Function struct stores the registered function

func CreateFunction

func CreateFunction(fn any, def Definition, ignoreIdx ...int) (*Function, error)

CreateFunction creates a Function from a function

func (*Function) Call

func (f *Function) Call(params *Params, ignoreParams ...any) (resultInterfaces []any, err error)

func (*Function) GetCallable

func (f *Function) GetCallable(p *Params) (Callable, error)

func (*Function) GetDef

func (f *Function) GetDef() *Definition

func (*Function) GetFn

func (f *Function) GetFn() any

func (*Function) GetIgnoreIdx

func (f *Function) GetIgnoreIdx() []int

func (*Function) GetName

func (f *Function) GetName() string

func (*Function) GetOrGenFuncInfo

func (f *Function) GetOrGenFuncInfo() (*FuncInfo, error)

type ParamInfo

type ParamInfo struct {
	Name  string
	Index int
}

type Params

type Params struct {
	Params    []any
	RawParams []string // will be used when Params is nil, each RawParam is a json string
}

func (*Params) Get

func (p *Params) Get(i int) any

func (*Params) GetRaw

func (p *Params) GetRaw(i int) string

func (*Params) IsRaw

func (p *Params) IsRaw() bool

func (*Params) Len

func (p *Params) Len() int

Jump to

Keyboard shortcuts

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