Documentation
¶
Index ¶
- Variables
- func AllModuleNames() []string
- func ArgIToBool(idx int, args ...tengo.Object) (bool, error)
- func ArgIToByteSlice(idx int, args ...tengo.Object) ([]byte, error)
- func ArgIToDuration(idx int, args ...tengo.Object) (time.Duration, error, error)
- func ArgIToInt(idx int, args ...tengo.Object) (int, error)
- func ArgIToInt64(idx int, args ...tengo.Object) (int64, error)
- func ArgIToMap(idx int, args ...tengo.Object) (map[string]interface{}, error)
- func ArgIToString(idx int, args ...tengo.Object) (string, error)
- func ArgIToTime(idx int, args ...tengo.Object) (time.Time, error)
- func ArgToBool(args ...tengo.Object) (bool, error)
- func ArgToByteSlice(args ...tengo.Object) ([]byte, error)
- func ArgToDuration(args ...tengo.Object) (time.Duration, error, error)
- func ArgToInt(args ...tengo.Object) (int, error)
- func ArgToString(args ...tengo.Object) (string, error)
- func ArgsToStrings(minArg int, args ...tengo.Object) ([]string, error)
- func BoolObject(flag bool) tengo.Object
- func FuncABRE(fn func(bool) error) tengo.CallableFunc
- func FuncACRE(fn func(context.Context) error) tengo.CallableFunc
- func FuncADRE(fn func(time.Duration) error) tengo.CallableFunc
- func FuncAIRI(fn func(any) any) tengo.CallableFunc
- func FuncAISARSAE(fn func(int, string, interface{}) (string, []interface{}, error)) tengo.CallableFunc
- func FuncAISRS(fn func(int, string) string) tengo.CallableFunc
- func FuncARSsE(fn func() ([]string, error)) tengo.CallableFunc
- func FuncARYs(fn func() []byte) tengo.CallableFunc
- func FuncASARSAE(fn func(string, interface{}) (string, []interface{}, error)) tengo.CallableFunc
- func FuncASRI(fn func(string) int) tengo.CallableFunc
- func FuncASVRSAE(fn func(string, ...interface{}) (string, []interface{}, error)) tengo.CallableFunc
- func FuncATBR(fn func() (time.Time, bool)) tengo.CallableFunc
- func FuncAWARE(fn func(w io.Writer, data any) error) tengo.CallableFunc
- func FuncAWAREs(fn func(w io.Writer, data any) error) tengo.CallableFunc
- func FuncAYIR(fn func([]byte, int)) tengo.CallableFunc
- func GetModuleMap(names ...string) *tengo.ModuleMap
- func LoadConfig[T any, P Ptr[T]](filename string) (*T, error)
- func LoadConfigTo[T any, P Ptr[T]](filename string, out *T) error
- func LookupLoop[K comparable, V any](key K, keys []K, values []V) (V, bool)
- func MapGet[T any](o tengo.Object, key string, defVal T, fn func(tengo.Object) (T, bool)) T
- func MapToObject(v map[string]interface{}) (tengo.Object, error)
- func ObjectMapToMap(v map[string]tengo.Object) map[string]interface{}
- func ObjectToStrings(obj tengo.Object) ([]string, error)
- func RegisterModule(name string, mod map[string]tengo.Object)
- func StringsToObject(items []string) tengo.Object
- func Ternary[T any](cond bool, ifTrue T, ifFalse T) T
- func ToObject(o tengo.Object) (tengo.Object, bool)
- func ValueGet[T any](o tengo.Object, defVal T, fn func(tengo.Object) (T, bool)) T
- func WrapError(err error) tengo.Object
- type Context
- type InterfaceImpl
- func (o *InterfaceImpl) BinaryOp(_ token.Token, _ tengo.Object) (tengo.Object, error)
- func (o *InterfaceImpl) CanCall() bool
- func (o *InterfaceImpl) CanIterate() bool
- func (o *InterfaceImpl) IndexGet(_ tengo.Object) (res tengo.Object, err error)
- func (o *InterfaceImpl) IndexSet(_, _ tengo.Object) (err error)
- func (o *InterfaceImpl) Iterate() tengo.Iterator
- func (o *InterfaceImpl) String() string
- func (o *InterfaceImpl) TypeName() string
- type IoFunc
- type Ptr
- type Reader
- type Span
- type Writer
Constants ¶
This section is empty.
Variables ¶
var ErrUnsupportedConfigFormat = errors.New("unsupported configuration file format")
ErrUnsupportedConfigFormat return unsupported config file format
Functions ¶
func ArgIToBool ¶
ArgIToBool convert tengo function call arguments to boolean. If the argument count is not equal to one, it will return ErrWrongNumArguments
func ArgIToByteSlice ¶
ArgIToByteSlice convert tengo function call arguments to []byte. If the argument count is not equal to one, it will return ErrWrongNumArguments
func ArgIToDuration ¶
ArgIToDuration convert i to duriation err1 -> conversion error err2 -> argument mismatch
func ArgIToInt ¶
ArgIToInt convert tengo function call arguments to int. If the argument count is not equal to one, it will return ErrWrongNumArguments
func ArgIToInt64 ¶
ArgIToInt64 convert tengo function call arguments to string. If the argument count is not equal to one, it will return ErrWrongNumArguments
func ArgIToString ¶
ArgIToString convert tengo function call arguments to string. If the argument count is not equal to one, it will return ErrWrongNumArguments
func ArgIToTime ¶
ArgIToTime convert argument to context value
func ArgToBool ¶
ArgToBool convert tengo function call arguments to boolean. If the argument count is not equal to one, it will return ErrWrongNumArguments
func ArgToByteSlice ¶
ArgToByteSlice convert tengo function call arguments to []byte. If the argument count is not equal to one, it will return ErrWrongNumArguments
func ArgToDuration ¶
ArgToDuration convert i to duriation err1 -> conversion error err2 -> argument mismatch
func ArgToInt ¶
ArgToInt convert tengo function call arguments to int. If the argument count is not equal to one, it will return ErrWrongNumArguments
func ArgToString ¶
ArgToString convert tengo function call arguments to string. If the argument count is not equal to one, it will return ErrWrongNumArguments
func ArgsToStrings ¶
ArgsToStrings convert tengo function call arguments to string slice. If the argument count is less than minArg, it will return ErrWrongNumArguments
func BoolObject ¶
func BoolObject(flag bool) tengo.Object
func FuncACRE ¶
FuncACRE transform a function of 'func(ctx) error' signature into CallableFunc type.
func FuncAISARSAE ¶
func FuncAISRS ¶
FuncAISRS transform a function of 'func(int, string) string' signature into CallableFunc type.
func FuncARSsE ¶
FuncARSsE transform a function of 'func() ([]string, error)' signature into CallableFunc type.
func FuncARYs ¶
func FuncARYs(fn func() []byte) tengo.CallableFunc
FuncARYs transform a function of 'func() []byte' signature into CallableFunc type.
func FuncASARSAE ¶
func FuncASRI ¶
FuncASRI transform a function of 'func(string) int' signature into CallableFunc type.
func FuncASVRSAE ¶
func FuncATBR ¶
FuncATBR transform a function of 'func() (time.Time, bool)' signature into CallableFunc type.
func FuncAWAREs ¶
FuncAWAREs convert any function(io.Writer, interface{}) error to tengo.CallableFunc
func FuncAYIR ¶
FuncAYIR transform a function of 'func([]byte, int)' signature into CallableFunc type.
func GetModuleMap ¶
func GetModuleMap(names ...string) *tengo.ModuleMap
GetModuleMap returns the module map that includes all modules for the given module names. If module does not exist, it will panic.
func LoadConfig ¶
LoadConfig load configuration from given file. Supported formats: json
func LoadConfigTo ¶
LoadConfigTo load configuration from given file. Supported formats: json, hjson
func LookupLoop ¶
func LookupLoop[K comparable, V any](key K, keys []K, values []V) (V, bool)
LookupLoop implement switch-case like lookup table functionality.
func MapGet ¶
MapGet return value with given key in case object is map. If object is not map or value does not exists, it will return defaultV
func MapToObject ¶
MapToObject convert map[string]interface{} to tengo.Object
func ObjectMapToMap ¶
ObjectMapToMap converts map[string]tengo.Object to map[string]interface{}
func ObjectToStrings ¶
ObjectToStrings convert tengo.Object to []string
func RegisterModule ¶
RegisterModule with given name
func StringsToObject ¶
func StringsToObject(items []string) tengo.Object
StringsToObject convert []string to tengo.Object
func ToObject ¶
func ToObject(o tengo.Object) (tengo.Object, bool)
ToObject simply return argument and true
Types ¶
type Context ¶
Context is context.Context wrapper which is accessible from tengo
func ArgIToContext ¶
ArgIToContext convert argument to context value
func ArgToContext ¶
ArgToContext convert argument to context value
func NewContext ¶
NewContext creates scriptable context.Context
func (*Context) Equals ¶
Equals returns true if the value of the type is equal to the value of another object.
type InterfaceImpl ¶
type InterfaceImpl struct {
Name string
}
InterfaceImpl for wraping interface
func (*InterfaceImpl) BinaryOp ¶
func (o *InterfaceImpl) BinaryOp(_ token.Token, _ tengo.Object) (tengo.Object, error)
BinaryOp returns another object that is the result of a given binary operator and a right-hand side object.
func (*InterfaceImpl) CanCall ¶
func (o *InterfaceImpl) CanCall() bool
CanCall returns whether the tengo.Object can be Called.
func (*InterfaceImpl) CanIterate ¶
func (o *InterfaceImpl) CanIterate() bool
CanIterate returns whether the tengo.Object can be Iterated.
func (*InterfaceImpl) IndexGet ¶
func (o *InterfaceImpl) IndexGet(_ tengo.Object) (res tengo.Object, err error)
IndexGet returns an element at a given index.
func (*InterfaceImpl) IndexSet ¶
func (o *InterfaceImpl) IndexSet(_, _ tengo.Object) (err error)
IndexSet sets an element at a given index.
func (*InterfaceImpl) Iterate ¶
func (o *InterfaceImpl) Iterate() tengo.Iterator
Iterate returns an iterator.
func (*InterfaceImpl) String ¶
func (o *InterfaceImpl) String() string
func (*InterfaceImpl) TypeName ¶
func (o *InterfaceImpl) TypeName() string
TypeName returns the name of the type.
type IoFunc ¶
type IoFunc struct {
Fn *tengo.UserFunction
}
IoFunc wrapper
type Reader ¶
type Reader struct { InterfaceImpl Value io.Reader }
Reader represents a user function.
type Span ¶
Span stores duration for json decode/encode
func (Span) IsNegative ¶
IsNegative return true if duration is less than 0
func (Span) IsPositive ¶
IsPositive return true if duration is greater than 0
func (Span) MarshalJSON ¶
MarshalJSON converts duration to string
func (*Span) UnmarshalJSON ¶
UnmarshalJSON convert duration stream to time.Duration