{"id":23155086,"url":"https://github.com/tengattack/gluasocket","last_synced_at":"2025-07-12T13:04:22.632Z","repository":{"id":144210475,"uuid":"245685090","full_name":"tengattack/gluasocket","owner":"tengattack","description":"Mirrors for BixData/gluasocket","archived":false,"fork":false,"pushed_at":"2020-03-07T18:33:38.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-04T16:49:05.229Z","etag":null,"topics":[],"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/tengattack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2020-03-07T18:32:44.000Z","updated_at":"2020-03-07T18:35:07.000Z","dependencies_parsed_at":"2023-08-15T19:51:49.126Z","dependency_job_id":null,"html_url":"https://github.com/tengattack/gluasocket","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tengattack/gluasocket","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tengattack%2Fgluasocket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tengattack%2Fgluasocket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tengattack%2Fgluasocket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tengattack%2Fgluasocket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tengattack","download_url":"https://codeload.github.com/tengattack/gluasocket/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tengattack%2Fgluasocket/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264995105,"owners_count":23694883,"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","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":[],"created_at":"2024-12-17T20:15:19.110Z","updated_at":"2025-07-12T13:04:22.610Z","avatar_url":"https://github.com/tengattack.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LuaSocket for GopherLua\n\nA native Go implementation of [LuaSocket](https://github.com/diegonehab/luasocket) for the [GopherLua](https://github.com/yuin/gopher-lua) VM.\n\n## Using\n\n### Loading Modules\n\n```go\nimport (\n\t\"github.com/BixData/gluasocket\"\n)\n\n// Bring up a GopherLua VM\nL := lua.NewState()\ndefer L.Close()\n\n// Preload LuaSocket modules\ngluasocket.Preload(L)\n```\n\n### Read lines from a socket\n\n```go\nscript := `\n  local client = require 'socket'.connect('127.0.01', 8000)\n  local line1 = client:receive('*l')\n  local line2 = client:receive('*l')\n  client:close()\n  return line1, line2`\nL.DoString(script)\nline1 := L.ToString(-2)\nline2 := L.ToString(-1)\n```\n\n### Get system time\n\n```go\nL.DoString(\"return require 'socket'.gettime()\")\ngettimeValue := float64(L.ToNumber(-1))\n```\n\n## Testing\n\n```bash\n$ go test github.com/BixData/gluasocket...\nok  \tgithub.com/BixData/gluasocket\t0.045s\n?   \tgithub.com/BixData/gluasocket/ltn12\t[no test files]\n?   \tgithub.com/BixData/gluasocket/mime\t[no test files]\nok  \tgithub.com/BixData/gluasocket/mimecore\t0.040s\n?   \tgithub.com/BixData/gluasocket/socket\t[no test files]\nok  \tgithub.com/BixData/gluasocket/socketcore\t0.269s\n?   \tgithub.com/BixData/gluasocket/socketexcept\t[no test files]\n?   \tgithub.com/BixData/gluasocket/socketftp\t[no test files]\n?   \tgithub.com/BixData/gluasocket/socketheaders\t[no test files]\n?   \tgithub.com/BixData/gluasocket/sockethttp\t[no test files]\n?   \tgithub.com/BixData/gluasocket/socketsmtp\t[no test files]\n?   \tgithub.com/BixData/gluasocket/sockettp\t[no test files]\n?   \tgithub.com/BixData/gluasocket/socketurl\t[no test files]\n```\n\nSome original Lua-based LuaSocket unit tests are used and wrapped in Go unit test functions. Tests that perform `os.exit()` are modified to perform `error()` instead so that errors are made detectable.\n\n## Design\n\n### Divergence from LuaSocket source codes\n\n#### 1. Unit test calls to `os.exit()` replaced with `error()`\n\nThis was necessary in order to detect and report errors from a test runner. Filed [LuaSocket Issue #227](https://github.com/diegonehab/luasocket/issues/227).\n\n#### 2. Finalized Exceptions moved to pure-Lua\n\nLuaSocket's exception handling is based on Diego's [Finalized Exceptions](http://lua-users.org/wiki/FinalizedExceptions) whitepaper.\n\nAfter struggling to port the C-based `socket.newtry()` and `socket.protect()` functions to GopherLua, an easier path emerged when I discovered the pure-Lua implementations found in the unmerged [LuaSocket Pull Request #161](https://github.com/diegonehab/luasocket/pull/161), which introduces a new `socket.except` module, and makes tiny modifications to the `socket` module in order to use it. This served the purposes of this project perfectly.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftengattack%2Fgluasocket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftengattack%2Fgluasocket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftengattack%2Fgluasocket/lists"}