<div dir="ltr"><div>Hi *, </div><div><br></div>I've just finished to develop erlang node implementation on golang. Its based on some parts of <a href="https://github.com/goerlang">https://github.com/goerlang</a>, but totally reworked. Now you can create your own nodes using golang and send sync/async messages<div><br></div><div>here is some example...<br></div><div><br></div><div><pre style="box-sizing:border-box;font-family:SFMono-Regular,Consolas,"Liberation Mono",Menlo,Courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;word-wrap:normal;padding:16px;overflow:auto;line-height:1.45;background-color:rgb(246,248,250);border-radius:3px;word-break:normal;color:rgb(36,41,46)"><span class="gmail-pl-smi" style="box-sizing:border-box">Node</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:=</span> ergonode.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Create</span>(<span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span><a href="mailto:examplenode@127.0.0.1">examplenode@127.0.0.1</a><span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span>, <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">21234</span>, <span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span>SecretCookie<span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span>)
<span class="gmail-pl-smi" style="box-sizing:border-box">completeChan</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:=</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">make</span>(<span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">chan</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">bool</span>)
<span class="gmail-pl-smi" style="box-sizing:border-box">gs</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:=</span> <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">new</span>(goGenServ)

n.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Spawn</span>(gs, completeChan)

<span class="gmail-pl-smi" style="box-sizing:border-box">message</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:=</span> etf.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Term</span>(etf.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Atom</span>(<span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span>hello<span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span>))

<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(106,115,125)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> gen_server:call({pname, 'node@address'} , hello)</span>
<span class="gmail-pl-smi" style="box-sizing:border-box">to</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:=</span> etf.<span class="gmail-pl-smi" style="box-sizing:border-box">Tuple</span>{etf.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Atom</span>(<span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span>pname<span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span>), etf.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Atom</span>(<span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span>node@address<span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span>)}

<span class="gmail-pl-smi" style="box-sizing:border-box">answer</span>, <span class="gmail-pl-smi" style="box-sizing:border-box">err</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:=</span> gs.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Call</span>(to, message)
fmt.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Printf</span>(<span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span>Got response: <span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">%v</span><span class="gmail-pl-cce" style="box-sizing:border-box">\n</span><span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span>, answer)

<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(106,115,125)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> it's also possible to call using Pid (etf.Pid)</span>
<span class="gmail-pl-smi" style="box-sizing:border-box">answer</span>, <span class="gmail-pl-smi" style="box-sizing:border-box">err</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:=</span> gs.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Call</span>(Pid, message)

<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(106,115,125)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> gen_server:cast({pname, 'node@address'} , hello)</span>
<span class="gmail-pl-smi" style="box-sizing:border-box">to</span> <span class="gmail-pl-k" style="box-sizing:border-box;color:rgb(215,58,73)">:=</span> etf.<span class="gmail-pl-smi" style="box-sizing:border-box">Tuple</span>{etf.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Atom</span>(<span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span>pname<span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span>), etf.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Atom</span>(<span class="gmail-pl-s" style="box-sizing:border-box;color:rgb(3,47,98)"><span class="gmail-pl-pds" style="box-sizing:border-box">"</span>node@address<span class="gmail-pl-pds" style="box-sizing:border-box">"</span></span>)}
gs.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Cast</span>(to, message)

<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(106,115,125)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> the same way using Pid</span>
gs.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Cast</span>(Pid, message)

<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(106,115,125)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> simple sending message 'Pid ! hello'</span>
gs.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Send</span>(Pid, message)

<span class="gmail-pl-c" style="box-sizing:border-box;color:rgb(106,115,125)"><span class="gmail-pl-c" style="box-sizing:border-box">//</span> to get pid like it does erlang:self()</span>
gs.<span class="gmail-pl-c1" style="box-sizing:border-box;color:rgb(0,92,197)">Self</span>()</pre></div><div><br></div><div>Grab it here: <a href="https://github.com/halturin/ergonode">https://github.com/halturin/ergonode</a><br></div><div><br></div><div>Any feedback is highly appreciated</div><div><br></div><div><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><span></span>Best Regards.<div>Taras Halturin</div></div></div></div>
</div></div>