{"id":20459730,"url":"https://github.com/rosbit/jsgo","last_synced_at":"2025-04-13T05:51:15.754Z","repository":{"id":57487602,"uuid":"161312735","full_name":"rosbit/jsgo","owner":"rosbit","description":"A mini but powerful, standalone but extendable JS interpreter written in Go. A JS module is just a Go struct In jsgo.","archived":false,"fork":false,"pushed_at":"2021-12-20T11:23:36.000Z","size":26,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-26T22:36:08.019Z","etag":null,"topics":["duktape","embedding","go","golang","javascript","js","jsgo","mini","nodejs"],"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}},"created_at":"2018-12-11T09:53:22.000Z","updated_at":"2023-12-28T00:57:45.000Z","dependencies_parsed_at":"2022-08-29T10:20:46.489Z","dependency_job_id":null,"html_url":"https://github.com/rosbit/jsgo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosbit%2Fjsgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosbit%2Fjsgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosbit%2Fjsgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rosbit%2Fjsgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rosbit","download_url":"https://codeload.github.com/rosbit/jsgo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248670500,"owners_count":21142901,"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":["duktape","embedding","go","golang","javascript","js","jsgo","mini","nodejs"],"created_at":"2024-11-15T12:17:07.648Z","updated_at":"2025-04-13T05:51:15.729Z","avatar_url":"https://github.com/rosbit.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsgo (A JavaScript interpreter written in Go)\n\n**jsgo** is implemented in Go, and it is an sample application of\n[Duktape Bridge for Go](https://github.com/rosbit/duktape-bridge). It is intended to\nprovide a method of making Go structures to be JavaScript modules. So one can create\nframework related jobs with Go, and fulfill the changable logic in JS.\n\n**jsgo** embeds the [Duktape](https://duktape.org) JavaScript, so it\ncan be used as an Ecmascript E5/E5.1 interpreter. Right now, it contains some modules\nsuch as `http`, `fs`, `url`, `db`, etc. What I have done is just providing a sample of\nimplementing a JavaScript module in Go. One can produce more modules or change modules\nif needed.  Enjoy **jsgo**.\n\n### Binary and Download\n   If you don't to want to build `jsgo`, go to [jsgo binary](https://github.com/rosbit/jsgo/releases)\n   to download the proper version. Save it as jsgo, `chmod +x jsgo`, it can be used as\n   a js interpreter, or as http server, etc..\n\n### Build\n\n**jsgo** only depends on [Duktape Bridge for Go](https://github.com/rosbit/duktape-bridge)\nand [go-flags](https://github.com/jessevdk/go-flags). To build an executable `jsgo`, at any\ndirectory, perform the command:\n\n   ```bash\n   GOPATH=`pwd` go get -u github.com/rosbit/jsgo\n   ```\nNow you get a standalone executable `bin/jsgo`, copy it to anywhere you want. It's small\nand has no runtime dependency, it is a full JavaScript interpreter.\n\nIf you want a `jsgo` with `db` module, which can be acted as a mysql/sqlite3 client. Run this command:\n\n   ```bash\n   GOPATH=`pwd` go get -u -tags=db github.com/rosbit/jsgo   # with -tags=db\n   ```\nRun `bin/jsgo -m`, `db` will appear in the list. Also this `jsgo` has no runtime dependency.\n\n### Usage\n\n#### List built-in modules\n\n  - run `bin/jsgo -m`\n\n#### Run simple codes\n\nJust run `bin/jsgo -e 'js-code-in-quote-marks'`, e.g.:\n\n  - `bin/jsgo -e 'print(\"hello jsgo\")'`\n  - `bin/jsgo -e '1 + 1'`\n\n#### Run JavaScript script file\n\nJust run `bin/jsgo \u003cjs-file\u003e`\n\nSuppose there's a js file `a.js`:\n\n   ```js\n   console.log('hello jsgo');\n   ```\n\nRun `bin/jsgo a.js`, That's all.\n\nThere are sample JavaScript files under `src/github.com/rosbit/jsgo/js_samples`, which will show how\nto use builtin jsgo modules such as `http`, `fs`, `url`, `db`:\n\n   - httpd1.js (Node.js version)\n\n     ```js\n     var http = require('http')\n       \n     var server = http.createServer(function (request, response) {\n          response.writeHead(200, {'Content-Type': 'text/plain'})\n          response.end('Hello World\\n')\n     }).listen(8888)\n\n     console.log('Server running at http://127.0.0.1:8888/')\n     ```\n   - httpd2.js (response body returned directly)\n\n     ```js\n     var http = require('http')\n     \n     var server = http.createServer(function (request, response) {\n        return {\n            desc: 'json sample',\n            ival: 1,\n            iaval: [1, 2, 3],\n            saval: ['this', 'is', 'a', 'test'],\n            mval: {a: 'map', b: 'val', c: 'here'}\n        }\n     }).listen(8888)\n\n     console.log('Server running at http://127.0.0.1:8888/')\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__Convention:__ fork the repository and make changes on your fork in a feature branch.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosbit%2Fjsgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frosbit%2Fjsgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frosbit%2Fjsgo/lists"}