How to using golang for write a xxx.so for ruby?

you may see http://golang.org
I want to using golang create a shared object thant can call from
ruby,Is it possiable?

On 18 Nov 2009, at 02:50, Haoqi H. wrote:

you may see http://golang.org
I want to using golang create a shared object thant can call from
ruby,Is it possiable?

First write your shared library in go, then load it into your ruby
program using either ruby/dl (part of the MRI standard library) or
ruby-ffi (available as a gem and supported under both MRI and JRuby).

You will also have to figure out how go mangles function names to be
able to call into the library and there may well be runtime aspects of
the go language which are incompatible with current ruby
implementations.

Happy hacking :slight_smile:

Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net

raise ArgumentError unless @reality.responds_to? :reason

On Wed, 18 Nov 2009 20:44:20 +0900, Eleanor McHugh wrote:

Ellie

From the Go FAQ: “There is no safe way to call Go code from C or C++
yet.”

-jh

On 18 Nov 2009, at 22:01, Jonathan H. wrote:

Happy hacking :slight_smile:

From the Go FAQ: “There is no safe way to call Go code from C or C++ yet.”

Indeed. But if you can build a shared library in the first place
(something I can’t comment on one way or the other) then both ruby/dl
and ruby-ffi can attempt to load it. Whether or not that’s easy or
stable we’ll only know for sure when someone tries :slight_smile:

Ellie

Eleanor McHugh
Games With Brains
http://slides.games-with-brains.net

raise ArgumentError unless @reality.responds_to? :reason