https://github.com/zombiezen/go-lua
Lua wrapped as Go package
https://github.com/zombiezen/go-lua
Last synced: 2 months ago
JSON representation
Lua wrapped as Go package
- Host: GitHub
- URL: https://github.com/zombiezen/go-lua
- Owner: zombiezen
- License: other
- Created: 2023-09-22T22:43:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-13T00:58:31.000Z (about 2 years ago)
- Last Synced: 2024-12-21T20:46:27.982Z (about 1 year ago)
- Language: C
- Size: 627 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# `zombiezen.com/go/lua`
This is [Lua 5.4.6](https://www.lua.org/versions.html#5.4), wrapped as a Go package.
It's experimental and suited to fit my needs.
## Install
```shell
go get zombiezen.com/go/lua
```
## Getting Started
```go
import "zombiezen.com/go/lua"
// Create an execution environment
// and make the standard libraries available.
state := new(lua.State)
defer state.Close()
if err := lua.OpenLibraries(state); err != nil {
return err
}
// Load Lua code as a chunk/function.
// Calling this function then executes it.
const luaSource = `print("Hello, World!")`
if err := state.LoadString(luaSource, luaSource, "t"); err != nil {
return err
}
if err := state.Call(0, 0, 0); err != nil {
return err
}
```
## License
[MIT](LICENSE) for compatibility with Lua itself.