Lua Extended Library is a Lua 5.4 native extension written in Go (via cgo) that provides practical system and utility modules with an async event loop.
It is designed to let Lua code look synchronous while the underlying work (file I/O and other native tasks) runs asynchronously and resumes through a cooperative event loop.
- This project is still under development and is considered unstable.
- It works on Windows, Linux, and macOS. For building on Windows, MSYS2 is required.
- Native Lua module compiled as a shared library (
extdlib.so) - Lua wrapper with friendly API (
extdlib.lua) - Async/event loop primitives to avoid callback-heavy code
- Utility modules for:
- Filesystem
- Path
- String helpers
- Regex
- Crypto
- Timer
- OS/process helpers
- HTTP (currently partial)
The Makefile checks these binaries and packages:
gogccpkg-configlua5.4- Lua 5.4 development package with pkg-config metadata (
lua5.4.pc), usually fromliblua5.4-dev
Also required:
make
sudo apt update
sudo apt install -y make golang gcc pkg-config lua5.4 liblua5.4-devThe Makefile auto-detects host architecture and maps it to Go arch:
x86_64->amd64aarch64/arm64->arm64armv7l->arm
make buildThis creates:
dist/extdlib.sodist/extdlib.lua
make testMost async-style APIs return:
(err, result)whereerrisnilon success
When using modules that depend on async bridge/event-loop behavior, call them inside eventloop.start(...) (or an async task).
local lxlib = require("dist.extdlib")
lxlib.eventloop.start(function()
local err, content = lxlib.fs.readFile("README.md")
if err then
print("read error:", err.message)
return
end
print("bytes:", #content)
end)local lxlib = require("dist.extdlib")
local p = lxlib.path.join("src", "utils", "file.lua")
print("path:", p)
print("base:", lxlib.path.basename(p))
print("upper:", lxlib.string.toUpper("hello"))local lxlib = require("dist.extdlib")
lxlib.eventloop.start(function()
local id = lxlib.timer.setInterval(500, function()
print("tick")
end)
lxlib.timer.setTimeout(2000, function()
lxlib.timer.clearTimer(id)
print("interval cleared")
end)
end)local lxlib = require("dist.extdlib")
lxlib.http.handle("GET", "/health", function(req, res)
res.status = 200
res.body = "ok"
end)
lxlib.http.listen("8080")- Implemented: FS, OS, Path, Timer, Crypto, String, Regex, Event Loop, Bridge
- Partial/in progress: HTTP
- Planned/not yet complete: JSON, Net/TCP
extdlib/Go native bindings and Lua wrappertests/Lua tests
- Build output is consumed in tests via
require("dist.extdlib"). - If
pkg-configcannot findlua5.4, install the Lua 5.4 dev package for your distro.