convert

package
v1.3.8 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoToLuaValue

func GoToLuaValue(L *lua.LState, value any) lua.LValue

GoToLuaValue converts a Go value to a corresponding Lua value suitable for Lua state operations.

func LuaValue

func LuaValue(lValue lua.LValue) (any, error)

LuaValue converts a Lua value to its corresponding Go type. It takes a lua.LValue as input and returns the converted value and an error. The function supports converting Lua strings to Go strings, Lua numbers to Go float64, Lua booleans to Go bool, and Lua nil to Go nil. If the Lua value is of any other type, it returns an error.

func LuaValueToGo added in v1.3.0

func LuaValueToGo(value lua.LValue) any

LuaValueToGo converts a lua.LValue to a corresponding Go value (nil, bool, float64, string, or map).

func StringCmd

func StringCmd(value *redis.StringCmd, valType string, L *lua.LState) error

StringCmd attempts to convert a given *redis.StringCmd value into the specified type.

Parameters: value: The redis.StringCmd value to be converted. valType: The type that the redis.StringCmd should be converted to. Acceptable values include:

  • "string": converts the redis.StringCmd to a Lua string.
  • "number": converts the redis.StringCmd to a Lua number. If the conversion fails, it returns an error.
  • "boolean": converts the redis.StringCmd to a Lua boolean. If the conversion fails, it returns an error.

L: The Lua state against which these conversions are made. This method pushes the converted value onto the L lua.LState if the conversion is successful.

It returns nil if the conversion is successful. It returns an error if the conversion fails or if the conversion is attempted on an unsupported type.

Example usage:

err := convertStringCmd(myStringCmd, "number", myLuaState)
if err != nil {
    log.Fatal(err)
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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