Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

go.yuchanns.xyz/lua

Package Overview
Dependencies
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

go.yuchanns.xyz/lua

Go Modules
Version
v0.0.0-20250926085311-8a3513baa81b
Version published
Created
Source

lua

Lua Go binding in purego

Caution

⚠️This library is working in progress 🚧 And APIs are not stable yet, maybe cause breaking changes many times. I make it public only for unlimited GitHub Actions minutes. It is not recommended to use at this moment.

Installation

go get go.yuchanns.xyz/lua

Usage

package main

import (
	"fmt"

	"go.yuchanns.xyz/lua"
)

func main() {
	err := lua.Init("/path/to/lua/dynlib.so")
	if err != nil {
		fmt.Println("Error creating temp file:", err)
		return
	}
	defer lua.Deinit()

	// Create a new Lua state
	L := lua.NewState()
	defer L.Close()

	L.OpenLibs()

	// Load a Lua script
	if err := L.DoString(`print("Hello, Lua!")`); err != nil {
		fmt.Println("Error:", err)
		return
	}

	// Call a Go function from Lua
	L.PushCFunction(lua.NewCallback(func(L *lua.State) int {
		x := L.CheckNumber(1)
		L.PushNumber(x * 2)
		return 1
	}))
	if err := L.SetGlobal("double_number"); err != nil {
		fmt.Println("Error:", err)
		return
	}
	if err := L.DoString(`print(double_number(21))`); err != nil {
		fmt.Println("Error:", err)
		return
	}
}

Development

Clone

git clone --recurse-submodules https://github.com/yuchanns/lua

Build Dependencies

We use luamake to build Lua.

luamake

Run Tests

cd lua54 && go test -v .

FAQs

Package last updated on 26 Sep 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts