Skip to content

Latest commit

 

History

History

examples

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Examples

Runnable programs for the luapure embedding API. Each is a standalone main.go importing github.com/htcom-code/lua-pure/lua (no other dependencies), so they compile under go build ./... and stay current with the API.

Run one with go run ./examples/<name>:

example shows
basic the README quickstart — expose a Go function, run a script, read results
embed hand a Go table to a script; ToValue/FromValue data round-trip
userdata bind a Go type as userdata with a method table and CheckUserData
sandbox NewSandbox + per-call _ENV (RunWith) + a SetContext deadline
channel a Go channel as userdata: two goroutines/LStates message-pass
channel-timeout cancellable channel recv via L.Context() + a SetContext deadline
openlib write a library that installs like a built-in (OpenString-style): a free OpenX(L) opener that exposes Go helpers as a global
customlib register host modules with Requiref (eager) and Preload (lazy)
debugger in-process Debugger: set a breakpoint, inspect the frame, Eval in scope, resume

For small, doc-integrated snippets see the runnable Example functions in lua/example_test.go (they render in make doc-web). The full API surface is in make doc; differences from PUC are in docs/COMPATIBILITY.md.