{"id":20550480,"url":"https://github.com/guywaldman/gonode","last_synced_at":"2025-08-30T17:07:58.669Z","repository":{"id":251551727,"uuid":"837739234","full_name":"guywaldman/gonode","owner":"guywaldman","description":"Easy Node.js addons using Go","archived":false,"fork":false,"pushed_at":"2024-08-03T22:14:29.000Z","size":14,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-21T13:00:41.380Z","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/guywaldman.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}},"created_at":"2024-08-03T22:00:31.000Z","updated_at":"2025-06-21T07:38:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"42777b00-da42-4577-9141-3496765d7835","html_url":"https://github.com/guywaldman/gonode","commit_stats":null,"previous_names":["guywaldman/gonode"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/guywaldman/gonode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guywaldman%2Fgonode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guywaldman%2Fgonode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guywaldman%2Fgonode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guywaldman%2Fgonode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guywaldman","download_url":"https://codeload.github.com/guywaldman/gonode/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guywaldman%2Fgonode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272878320,"owners_count":25008336,"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-08-30T02:00:09.474Z","response_time":77,"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":[],"created_at":"2024-11-16T02:25:11.217Z","updated_at":"2025-08-30T17:07:58.651Z","avatar_url":"https://github.com/guywaldman.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gonode\n\n`gonode` is a tool to help you write Go code that easily translates to Node.js addons and bindings, complete with TypeScript definitions.\n\n## How it works\n\nNode.js addons are written in C++ and are compiled into a shared library.  \nGo has support for C FFI (Foreign Function Interface) which allows you to call C++ functions from Go, or in this case export Go functions to C++.  \n\n`go build` is used to compile the Go code into a shared library, which then needs some glue code to be able to call these functions from Node.js (i.e.,\ninitialize the module, export the functions, etc.).  \n\nThe steps are as follows:\n\n- Export functions from Go using Go's `//export` comment and add a `go generate` directive which calls `gonode`:\n  ```go\n\tpackage calculator\n\n\t//go:generate gonode -dir .\n\n\t//export Sum\n\tfunc Sum(x, y float64) float64 {\n\t\treturn x + y\n\t}\n  ```\n\n- Compile the Go code into a shared library using `go build`:\n  ```bash\n  $ go build -buildmode c-archive -o build/calculator.a calculator.go\n  ```\n\n- Generate the glue code using `gonode`:\n\t```bash\n\tgo generate ./...\n\t```\n\n- In your Node.js project, generate bindings using `node-gyp` and import the TypeScript definitions that `gonode` generated:\n\t```bash\n\tnode-gyp configure\n\tnode-gyp build\n\t```\n\n\t```typescript\n\timport { sum } from \"../build/Release/calculator\";\n\n\tconsole.log(sum(1, 2));\n\t```\n\n\u003e See the [examples](./examples) directory for a complete example.\n\n## Usage\n\nTODO\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguywaldman%2Fgonode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguywaldman%2Fgonode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguywaldman%2Fgonode/lists"}