javascript - How to make nodejs to talk with golang -
i creating web app in node.js , golang. need connect nodejs golang code talks mongodb , returns data node program. there way connect so? tried use gonode api.this code using gonode api.
my node.js file contains below code:
var go = require('gonode').go; var options = { path : 'gofile.go', initatonce : true, } var go = new go(options,function(err){ if(err) throw err; go.execute({commandtext: 'hello world gonode!'}, function(result, response) { if(result.ok) { console.log('go responded: ' + response.responsetext); } }); go.close(); }); `
and code in gofile.go file:
package main import( gonode "github.com/jgranstrom/gonodepkg" json "github.com/jgranstrom/go-simplejson" ) func main(){ gonode.start(process) } func process(cmd *json.json) (response *json.json) { response, m := json.makemap() if(cmd.get("commandtext").muststring() == "hello") { m["responsetext"] = "well hello there!" } else { m["responsetext"] = "what?" } return }
this error getting while running node node.js in terminal events.js:72 throw er; // unhandled 'error' event ^ error: write epipe @ errnoexception (net.js:905:11) @ object.afterwrite (net.js:721:19)
thanks response. got solution this. made 2 different servers. 1 nodejs , golang. calling golang uri in node server , getting data golang server.
Comments
Post a Comment