functions

package
v0.0.16 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Code generated by gobindlua; DO NOT EDIT.

Example
package main

import (
	"log"

	lua "github.com/yuin/gopher-lua"
)

const script = `
local functions = require "functions"

function lua_left_pad(str, pad)
	local ret = ""

	for i=1,pad,1 do
		ret = "lua" .. ret
	end

	return ret .. str
end

functions.print_me(functions.split("foo_bar", "_"), functions.split("eggs&ham", "&"))

print("NotIncluded was excluded from the bindings: " .. tostring(functions.not_included == nil))

--[[ You can seamlessly pass Lua and Go functions as parameters. ]]
functions.do_func(lua_left_pad)
functions.do_func(functions.go_left_pad)
`

func main() {
	L := lua.NewState()
	defer L.Close()

	// For pure functions, we use the PreloadModule function instead of gobindlua.Register.
	L.PreloadModule("functions", FunctionsModuleLoader)

	if err := L.DoString(script); err != nil {
		log.Fatal(err)
	}

}
Output:

[foo bar] [eggs ham]
NotIncluded was excluded from the bindings: true
Result of fn("foo", 3) call: lualualuafoo
Result of fn("foo", 3) call: gogogofoo

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoFunc added in v0.0.16

func DoFunc(fn func(string, int) string)

func FunctionsModuleLoader added in v0.0.9

func FunctionsModuleLoader(L *lua.LState) int

func GoLeftPad added in v0.0.16

func GoLeftPad(str string, pad int) string

func NotIncluded

func NotIncluded()

func PrintMe

func PrintMe(args ...any)

func Split

func Split(s string, spl string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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