Lua2go
Easy access to your Go (Golang) modules from Lua and NGINX!
Install / Use
/learn @theganyo/Lua2goREADME
Accessing Go via Lua
This module enables easy access to Go modules from LuaJit and therefore, NGINX with the LuaJit module. So if you need the capabilities of Go in your NGINX processing, you've come to the right place!
Note: Lua2Go is now available from LuaRocks: http://luarocks.org/modules/scottganyo/lua2go
To use (see also the example:
-
Write your Go module and
exportyour functions://export add func add(operand1 int, operand2 int) int { return operand1 + operand2 } -
Build your go module as a shared library:
go build -buildmode=c-shared -o example.so example.go -
Include a bit of setup in your Lua file:
local lua2go = require('lua2go') local example = lua2go.Load('./example.so') -
Register your
externdeclarations from your header file (example.h) in your Lua:lua2go.Externs[[ extern GoInt add(GoInt p0, GoInt p1); ]] -
Call your Go function from Lua (see example for more detail):
local result = lua2go.ToGo(example.add(1, 1)) -
Run your app:
luajit myapp.lua -
Bask in the glory of all that you've accomplished!
-
To see how Lua2Go can be incorporated into NGINX, check out the benchmark example.
Enjoy!
Related Skills
node-connect
342.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
85.3kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
342.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
342.5kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
