CGO & Plugins

278 views
Skip to first unread message

dc0d

unread,
Jun 2, 2017, 6:55:57 PM6/2/17
to golang-nuts
Assuming we have some cgo packages, is it fine to place them inside a plugin (added in Go 1.8)?

It seems to ease deployment (on the same platform) and save some compilation time. But I'm not sure if it's safe to do so, mixing cgo & plugins.

Ian Lance Taylor

unread,
Jun 2, 2017, 8:39:40 PM6/2/17
to dc0d, golang-nuts
I can't think of a reason why it wouldn't work, but clearly the
current plugin approach is rather fragile.

Ian

Michael Brown

unread,
Jun 2, 2017, 10:24:41 PM6/2/17
to golang-nuts, kaveh.sh...@gmail.com
Do you have any references on the stability of the current plugin system that I can use for reference? I'm building a system now that I contemplate using with some plugins and I'd like to know up front the challenges.

Cristian Măgherușan-Stanciu

unread,
Jun 3, 2017, 5:18:06 AM6/3/17
to golang-nuts
The best real world example I know of mixing cgo and plugins is https://github.com/eawsy/aws-lambda-go-shim and it works pretty well.

It compiles a go program as a native library using cgo, which is loading some more golang code compiled as a plugin.

The native library also happens to implement the Python module binary interface so eventually golang code can be called by the Python AWS Lambda runtime, but it should work with any other Python program.

Nick Groenen

unread,
Jun 3, 2017, 10:02:22 AM6/3/17
to Michael Brown, golang-nuts
On 2017-06-02 19:24:40, Michael Brown wrote:
>Do you have any references on the stability of the current plugin system
>that I can use for reference? I'm building a system now that I contemplate
>using with some plugins and I'd like to know up front the challenges.

I wrote a blogpost on plugins earlier this year. The "caveats" section
has some remarks and references you might find interesting in this
context.

You can find it at
https://nick.groenen.me/posts/2017/01/09/plugins-in-go-18/

--
Nick Groenen
https://nick.groenen.me/
signature.asc

dc0d

unread,
Jun 4, 2017, 6:01:06 AM6/4/17
to golang-nuts, michael...@gmail.com
Thanks for the post! I don't think those caveats could be a setback.

Some clarifications on future of plugins would be nice though.

Ian Lance Taylor

unread,
Jun 4, 2017, 2:09:23 PM6/4/17
to dc0d, golang-nuts, michael...@gmail.com
On Sun, Jun 4, 2017 at 3:01 AM, dc0d <kaveh.sh...@gmail.com> wrote:
>
> Some clarifications on future of plugins would be nice though.

To be honest I thought plugins would have fewer problems than they
would up having. And in any case the API seems fine, so any reworking
can preserve the API.

I think the future of plugins is that someone needs to take a step
back and think through all the issues that have been discovered and
figure out whether, and how, they can be addressed. That person is
not going to be me.

Ian
Reply all
Reply to author
Forward
0 new messages