Add a Lua scripting layer to a Go application so users or admins can write automation scripts without recompiling
Let players write Lua mods for a Go-based game that run inside the game's process safely
Embed a sandboxed scripting engine in a Go configuration tool so rules can be changed without redeploying
Run hundreds of concurrent per-user Lua sessions in a Go server with tuned memory limits per state
GopherLua is a Lua interpreter built entirely in Go. It implements the Lua 5.1 language (plus the goto statement from Lua 5.2), meaning it can run Lua scripts, but it does so without any C code or external dependencies. The main purpose is to let Go programs embed a scripting language: you write your application in Go, and then you can let users or administrators write scripts in Lua that your application runs at runtime. The Go API is designed to be straightforward. You create a state, load a Lua file or string, call Lua functions from Go, and pass Go functions back into the Lua environment. Unlike the original Lua C library which uses a stack-based API (where you push and pop values to exchange data), GopherLua uses direct Go objects, which the README describes as more user-friendly even if slightly slower. Performance is roughly comparable to Python 3 on the micro-benchmarks the project has run. All Lua values are represented in Go through an interface called LValue. Numbers are float64, strings are Go strings, tables are Go structs, and so on. You can check what type a value is using type assertions or a Type() method. There are helper functions for handling Lua's rule that both nil and false count as false in conditionals. Go functions can be registered as Lua globals, allowing you to expose your application's functionality to scripts. The state's internal memory can be tuned: you can set the initial size and maximum size of the registry (the internal value stack), and configure whether the call stack grows automatically or stays at a fixed size. These options matter if you are running many concurrent Lua states, such as in a server application handling many simultaneous users, where memory efficiency becomes important. GopherLua also supports Go channels as a first-class Lua type, which allows Lua scripts to participate in Go's goroutine-based concurrency model. A collection of third-party libraries for GopherLua is listed in the README.
← yuin on gitmyhub — every repo by this author, as a profile.
Verify against the repo before relying on details.