drn34916
drn34916
2017-07-14 15:56

寻找有关如何在Golang中创建dll / so / dylib的基本示例/资源

已采纳

I am looking to convert part of an app I have written in golang to a dll/dylib/so and make calls to it from my core golang app.

Does anyone know of any good resources or guides on how to do this as my searches are not turning up a great deal of info (much of what I'm finding are old requests for the feature which i understand is now included)

Please note: I have seen documentation on how to do the actual build, it is more around how to organise the app and expose methods that I am missing

I would also be interested in pros/cons of this approach if anyone has any experience doing something similar

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

1条回答

  • dongyata3336 dongyata3336 4年前

    The c-shared buildmode is currently only supported on Linux.

    As seen here, Building a dll with Go 1.7, you may be able to build a DLL or shared lib using gcc, but it's not supported directly by the Go toolchain.

    However, if you're looking to create a "plugin" architecture, you don't want to create a C shared library, in which each instance creates a new Go runtime. There is already a plugin package which is intended for that purpose.

    点赞 评论 复制链接分享