You can already do this from C--provided that your main function is
written in Go.
If you want to have a program whose main function is written in C call
subroutines written in Go, that doesn't work today, but it is possible
to make it work. This is not something the Go team is likely to work
on, though. If somebody else wants to work on it, you would basically
have to have to link in the Go runtime library, and have it start up the
first time a Go function was called. You would have to do something to
make sure that the initializers were run for all imported Go packages.
Any direct interaction between Go and Java is almost surely going to be
via C, one way or another.
In general you may want to consider communicating over a socket.
Ian
Surma
How mad would someone have to be to consider compiling Go into
JVM code?
(Not me, I have enough mad projects already.)
Chris
--
Chris "allusive" Dollin
I think it's more likely that Go code would be called through the JNI
somehow. Compiling Go to JVM bytecode definitely involves a number of
difficulties with relatively few benefits.
- Evan
> Thanks Ian. I'd missed cgo's existence, and it appears swig is on the
> roadmap at least.
SWIG is working and the patches have all been contributed back to the
SWIG sources. There has not been a SWIG release since the patches were
contributed, though.
Ian