{"id":20459752,"url":"https://github.com/rosbit/luago","last_synced_at":"2026-01-12T02:35:45.797Z","repository":{"id":178200992,"uuid":"661289676","full_name":"rosbit/luago","owner":"rosbit","description":"make lua (5.4) be embeddable very easily in Golang. it is NOT a binding.","archived":false,"fork":false,"pushed_at":"2024-03-18T00:48:05.000Z","size":310,"stargazers_count":12,"open_issues_count":2,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-13T05:51:42.281Z","etag":null,"topics":["embeddable","golang","lua"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rosbit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-07-02T11:37:52.000Z","updated_at":"2024-12-30T01:36:25.000Z","dependencies_parsed_at":"2024-02-06T03:23:40.699Z","dependency_job_id":"2673c4b7-599d-4dd0-bdb2-e457df72d04b","html_url":"https://github.com/rosbit/luago","commit_stats":null,"previous_names":["rosbit/go-lua","rosbit/luago"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/rosbit/luago","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosbit%2Fluago","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosbit%2Fluago/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosbit%2Fluago/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosbit%2Fluago/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rosbit","download_url":"https://codeload.github.com/rosbit/luago/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosbit%2Fluago/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267285699,"owners_count":24064212,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embeddable","golang","lua"],"created_at":"2024-11-15T12:17:10.989Z","updated_at":"2026-01-12T02:35:45.784Z","avatar_url":"https://github.com/rosbit.png","language":"Go","readme":"# luago, makes lua be embedded easily\n\n[Lua](http://www.lua.org/) is a powerful, efficient, lightweight, embeddable scripting language.\nFor most of developers who are not familiar with C language, it is very tedious to call lua\\_pushxxx() and\nlua\\_pop() to make use of the power of Lua. Though there are some binding\nimplementations of Lua for languages other than C, most of them inherit the\nmethods of using API of Lua.\n\n`luago` is a package wrapping Lua and making it a **pragmatic embeddable** language.\nWith some helper functions provided by `luago`, calling Golang functions from Lua, \nor calling Lua functions from Golang are both very simple. So, with the help of `luago`, Lua\ncan be embedded in Golang application easily.\n\n### Install\n\nThe package is fully go-getable, So, just type\n\n  `go get github.com/rosbit/luago`\n\nto install.\n\n### Usage\n\n#### 1. Evaluates expressions\n\n```go\npackage main\n\nimport (\n  lua \"github.com/rosbit/luago\"\n  \"fmt\"\n)\n\nfunc main() {\n  ctx, err := lua.NewContext()\n  if err != nil {\n    fmt.Printf(\"%v\\n\", err)\n    return\n  }\n\n  if err = ctx.LoadString(\"res = a + b\", map[string]interface{}{\n     \"a\": 10,\n     \"b\": 1,\n  }); err == nil {\n     res, _ := ctx.GetGlobal(\"res\")\n     fmt.Println(\"result is:\", res)\n  }\n}\n```\n\n#### 2. Go calls Lua function\n\nSuppose there's a Lua file named `a.lua` like this:\n\n```lua\nfunction add(a, b)\n    return a+b\nend\n```\n\none can call the Lua function `add()` in Go code like the following:\n\n```go\npackage main\n\nimport (\n  lua \"github.com/rosbit/luago\"\n  \"fmt\"\n)\n\nvar add func(int, int)int\n\nfunc main() {\n  ctx, err := lua.NewContext()\n  if err != nil {\n     fmt.Printf(\"%v\\n\", err)\n     return\n  }\n\n  if err = ctx.LoadFile(\"a.lua\", nil); err != nil {\n     fmt.Printf(\"%v\\n\", err)\n     return\n  }\n\n  // method 1: bind Lua function with a golang var\n  if err := ctx.BindFunc(\"add\", \u0026add); err != nil {\n     fmt.Printf(\"%v\\n\", err)\n     return\n  }\n  res := add(1, 2)\n\n  // method 2: call Lua function using CallFunc\n  res, err := ctx.CallFunc(\"add\", 1, 2)\n  if err != nil {\n     fmt.Printf(\"%v\\n\", err)\n     return\n  }\n\n  fmt.Println(\"result is:\", res)\n}\n```\n\n#### 3. Lua calls Go function\n\nLua calling Go function is also easy. In the Go code, calling `LoadFile` with a map as env will\nmake Golang functions as Lua global functions. There's the example:\n\n```go\npackage main\n\nimport \"github.com/rosbit/luago\"\n\n// function to be called by Lua\nfunc adder(a1 float64, a2 float64) float64 {\n    return a1 + a2\n}\n\nfunc main() {\n  ctx, err := lua.NewContext()\n  if err != nil {\n      fmt.Printf(\"%v\\n\", err)\n      return\n  }\n\n  if err := ctx.LoadFile(\"b.lua\", map[string]interface{}{\n      \"adder\": adder,\n  })  // b.lua containing code calling \"adder\"\n}\n```\n\nIn Lua code, one can call the registered function directly. There's the example `b.lua`.\n\n```lua\nr = adder(1, 100)   -- the function \"adder\" is implemented in Go\nprint(r)\n```\n\n### Status\n\nThe package is not fully tested, so be careful.\n\n### Contribution\n\nPull requests are welcome! Also, if you want to discuss something send a pull request with proposal and changes.\n\n__Convention:__ fork the repository and make changes on your fork in a feature branch.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosbit%2Fluago","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frosbit%2Fluago","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosbit%2Fluago/lists"}