{"id":13670561,"url":"https://github.com/sagiegurari/node-go-require","last_synced_at":"2025-04-13T04:09:14.058Z","repository":{"id":24068678,"uuid":"27455015","full_name":"sagiegurari/node-go-require","owner":"sagiegurari","description":"Load Google GO files as any javascript modules under nodeJS runtime.","archived":false,"fork":false,"pushed_at":"2023-03-09T03:57:08.000Z","size":236,"stargazers_count":155,"open_issues_count":4,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-13T04:09:05.316Z","etag":null,"topics":["go","golang","nodejs"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sagiegurari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","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}},"created_at":"2014-12-02T21:44:00.000Z","updated_at":"2025-03-21T14:31:29.000Z","dependencies_parsed_at":"2024-01-14T16:28:51.402Z","dependency_job_id":null,"html_url":"https://github.com/sagiegurari/node-go-require","commit_stats":{"total_commits":252,"total_committers":3,"mean_commits":84.0,"dds":0.007936507936507908,"last_synced_commit":"7d361030c2cc3dcc24a040468490f595fba35e31"},"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fnode-go-require","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fnode-go-require/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fnode-go-require/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagiegurari%2Fnode-go-require/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sagiegurari","download_url":"https://codeload.github.com/sagiegurari/node-go-require/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248661705,"owners_count":21141450,"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":["go","golang","nodejs"],"created_at":"2024-08-02T09:00:45.456Z","updated_at":"2025-04-13T04:09:14.015Z","avatar_url":"https://github.com/sagiegurari.png","language":"JavaScript","readme":"# node-go-require\n\n[![NPM Version](http://img.shields.io/npm/v/node-go-require.svg?style=flat)](https://www.npmjs.org/package/node-go-require) [![CI](https://github.com/sagiegurari/node-go-require/workflows/CI/badge.svg?branch=master)](https://github.com/sagiegurari/node-go-require/actions) [![Coverage Status](https://coveralls.io/repos/sagiegurari/node-go-require/badge.svg)](https://coveralls.io/r/sagiegurari/node-go-require) [![Known Vulnerabilities](https://snyk.io/test/github/sagiegurari/node-go-require/badge.svg)](https://snyk.io/test/github/sagiegurari/node-go-require) [![Inline docs](http://inch-ci.org/github/sagiegurari/node-go-require.svg?branch=master)](http://inch-ci.org/github/sagiegurari/node-go-require) [![License](https://img.shields.io/npm/l/node-go-require.svg?style=flat)](https://github.com/sagiegurari/node-go-require/blob/master/LICENSE) [![Total Downloads](https://img.shields.io/npm/dt/node-go-require.svg?style=flat)](https://www.npmjs.org/package/node-go-require)\n\n\u003e Load google go script as any javascript modules under nodeJS runtime.\n\n* [Overview](#overview)\n* [Usage](#usage)\n* [Installation](#installation)\n* [Limitations](#limitations)\n* [API Documentation](docs/api.md)\n* [Contributing](.github/CONTRIBUTING.md)\n* [Release History](#history)\n* [License](#license)\n\n\u003ca name=\"overview\"\u003e\u003c/a\u003e\n## Overview\nGo is an open source programming language that makes it easy to build simple, reliable, and efficient software.\n\nSee [golang.org](https://golang.org/) for more information.\n\n\u003ca name=\"usage\"\u003e\u003c/a\u003e\n## Usage\nIn order to use google go scripts under node, you need to first require this library as follows\n\n```js\nrequire('node-go-require');\n```\n\nNow you can require your google go files like any other javascript files, for example:\n\n```js\nvar petGo = require('./pet.go');\n\nvar pet = petGo.pet.New('my pet');\nconsole.log(pet.Name());\npet.SetName('new name...');\nconsole.log(pet.Name());\n```\n\nIn your go file, instead of doing module.exports as in any JS file, use the gopherjs solution for exporting objects/functions.\n\nDo not export to the global namespace, instead export to the module namespace.\n\nFor example:\n\n```go\njs.Module.Get(\"exports\").Set(\"pet\", map[string]interface{}{\n    \"New\": New,\n})\n```\n\nFull example (GO):\n\n```go\npackage main\n\nimport \"github.com/gopherjs/gopherjs/js\"\n\ntype Pet struct {\n  name string\n}\n\nfunc New(name string) *js.Object {\n  return js.MakeWrapper(\u0026Pet{name})\n}\n\nfunc (p *Pet) Name() string {\n  return p.name\n}\n\nfunc (p *Pet) SetName(name string) {\n  p.name = name\n}\n\nfunc main() {\n  js.Module.Get(\"exports\").Set(\"pet\", map[string]interface{}{\n    \"New\": New,\n  })\n}\n```\n\nFull example (JavaScript):\n\n```js\nrequire('node-go-require');\n\nvar petGo = require('./pet.go');\n\nvar pet = petGo.pet.New('my pet');\nconsole.log(pet.Name());\npet.SetName('new name...');\nconsole.log(pet.Name());\n```\n\nIn order to generate minified javascript code, first set the following environment variable:\n\n```sh\nNODE_GO_REQUIRE_MINIFY=TRUE\n```\n\n\u003ca name=\"installation\"\u003e\u003c/a\u003e\n## Installation\nIn order to use this library, just run the following npm install command:\n\n```sh\nnpm install --save node-go-require\n```\n\nApart of installing the NPM modules, you will need to setup the following:\n\n* Install Google Go - [installation guide](https://golang.org/doc/install) (make sure that GOPATH env variable is defined)\n* Install gopherjs - [gopherjs](https://github.com/gopherjs/gopherjs) by running\n\n```sh\ngo get -u github.com/gopherjs/gopherjs\n```\n\n\u003ca name=\"limitations\"\u003e\u003c/a\u003e\n## Limitations\nThe Google Go to javascript conversion is done by gopherjs and there are some limitations of running the gopherjs generated code under node runtime.\n\nTo see exact limitations please see gopherjs project at: [gopherjs](https://github.com/gopherjs/gopherjs)\n\n## API Documentation\nSee full docs at: [API Docs](docs/api.md)\n\n## Contributing\nSee [contributing guide](.github/CONTRIBUTING.md)\n\n\u003ca name=\"history\"\u003e\u003c/a\u003e\n## Release History\n\n| Date        | Version | Description |\n| ----------- | ------- | ----------- |\n| 2020-05-13  | v2.0.0  | Migrate to github actions and upgrade minimal node version |\n| 2019-02-08  | v1.1.5  | Maintenance |\n| 2018-01-22  | v1.1.0  | Removed shelljs dependency and raised minimum node.js version to 0.12 |\n| 2017-02-07  | v1.0.25 | Ability to generate minified js code |\n| 2016-07-26  | v0.1.2  | Add integration test via docker |\n| 2015-02-14  | v0.0.16 | Modified tests and examples due to changes in gopherjs API |\n| 2015-02-09  | v0.0.15 | Grunt cleanups. |\n| 2015-02-06  | v0.0.14 | Doc changes |\n| 2015-02-05  | v0.0.13 | Fix continues integrations |\n| 2015-02-05  | v0.0.12 | Minor internal quality changes |\n| 2014-12-30  | v0.0.11 | Doc changes |\n| 2014-12-07  | v0.0.10 | Minor internal changes |\n| 2014-12-03  | v0.0.9  | No need to modify generated code |\n| 2014-12-03  | v0.0.8  | Simplified code generation modification |\n| 2014-12-02  | v0.0.7  | Mock gopherjs calls for continues integration tests. |\n| 2014-12-02  | v0.0.3  | Initial release. |\n\n\u003ca name=\"license\"\u003e\u003c/a\u003e\n## License\nDeveloped by Sagie Gur-Ari and licensed under the Apache 2 open source license.\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagiegurari%2Fnode-go-require","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagiegurari%2Fnode-go-require","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagiegurari%2Fnode-go-require/lists"}