## Classes
GoLoader
## Objects
NodeGoRequire : object

Extends the require capabilities to allow loading of google go script files as JS files.

## GoLoader **Kind**: global class **Access**: public **Author**: Sagie Gur-Ari * [GoLoader](#GoLoader) * [new GoLoader()](#new_GoLoader_new) * [#createGopherJSCommandArgs(goFile, [minify])](#GoLoader+createGopherJSCommandArgs) ⇒ String * [#runGopherJS(goFile, gopherjs, [minify])](#GoLoader+runGopherJS) ⇒ Object * [#runGoScript2JS(goFile, [options])](#GoLoader+runGoScript2JS) ⇒ String * [#loadGoScript(goFile, goModule, [options])](#GoLoader+loadGoScript) ⇒ Object ### new GoLoader() The GoLoader enables to load google go script files and to load them into the node runtime as JS files. ### GoLoader#createGopherJSCommandArgs(goFile, [minify]) ⇒ String Returns the gopher js command arguments. **Returns**: String - The command arguments **Access**: public | Param | Type | Default | Description | | --- | --- | --- | --- | | goFile | String | | The google go script file path | | [minify] | Boolean | false | True to minify the generated code | ### GoLoader#runGopherJS(goFile, gopherjs, [minify]) ⇒ Object Runs the gopherjs converter process. **Returns**: Object - The process execution output (see shelljs for more information) **Access**: public | Param | Type | Default | Description | | --- | --- | --- | --- | | goFile | String | | The google go script file path | | gopherjs | String | | The gopherjs executable file location | | [minify] | Boolean | false | True to minify the generated code | ### GoLoader#runGoScript2JS(goFile, [options]) ⇒ String Converts the provided go file into JS script text. **Returns**: String - The JS string of the converted go script **Access**: public | Param | Type | Default | Description | | --- | --- | --- | --- | | goFile | String | | The google go script file path | | [options] | Object | | Optional runtime options | | [options.minify] | Boolean | process.env.NODE_GO_REQUIRE_MINIFY | True to minify the generated code | ### GoLoader#loadGoScript(goFile, goModule, [options]) ⇒ Object Converts the provided google go file into JS script and loads it into the node runtime. **Returns**: Object - The JS module **Access**: public | Param | Type | Default | Description | | --- | --- | --- | --- | | goFile | String | | The go script file path | | goModule | Object | | The module for the go script | | [options] | Object | | Optional runtime options | | [options.minify] | Boolean | process.env.NODE_GO_REQUIRE_MINIFY | True to minify the generated code | ## NodeGoRequire : object Extends the require capabilities to allow loading of google go script files as JS files. **Kind**: global namespace **Author**: Sagie Gur-Ari **Example** In order to use google go scripts under node, you need to first require this library as follows ```js require('node-go-require'); ``` Now you can require your google go files like any other javascript files, for example: ```js const petGo = require('./pet.go'); const pet = petGo.pet.New('my pet'); console.log(pet.Name()); pet.SetName('new name...'); console.log(pet.Name()); ``` Go source: ```go package main import "github.com/gopherjs/gopherjs/js" type Pet struct { name string } func New(name string) *js.Object { return js.MakeWrapper(&Pet{name}) } func (p *Pet) Name() string { return p.name } func (p *Pet) SetName(name string) { p.name = name } func main() { js.Module.Get("exports").Set("pet", map[string]interface{}{ "New": New, }) } ``` * [NodeGoRequire](#NodeGoRequire) : object * [.goLoader](#NodeGoRequire.goLoader) : [GoLoader](#GoLoader) * [.requireGo(goModule, fileName)](#NodeGoRequire.requireGo) ### NodeGoRequire.goLoader : [GoLoader](#GoLoader) The GO loader instance. **Access**: public ### NodeGoRequire.requireGo(goModule, fileName) The node require implementation for google go scripts. **Access**: public | Param | Type | Description | | --- | --- | --- | | goModule | Object | The module for the go script | | fileName | String | The go script file name |