Debugging Go Plugins

blov · 2018-05-08 13:30:41 · 739 次点击    
这是一个分享于 2018-05-08 13:30:41 的资源,其中的信息可能已经有所发展或是发生改变。

Hi everyone!

Being new to Go I'm looking into plugins https://golang.org/pkg/plugin/. I'd like to be able to dynamically load libs during runtime, plugin seems to be working, exactly what I need.

Since documentation around it looks scarce, at least regarding best practices, I wanted to ask here if anyone could share some best practices for building applications using plugin.

Another important aspect of interest is debugging. I have Go Land, love all things JetBrains pretty much, but how do you actually debug plugins once they are built as *.so files?

Thanks in advance!


评论:

callcifer:

Delve (the debugger Goland uses) doesn't support plugins yet as it depends on missing debug information that Go upstream needs to fix first.

pr0v4:

Ok, that makes sense. Thanks!

widdma:

You could take a look at other users on GoDoc.

That said, in general I've seen the the tendency in the Go community is to statically compile everything, even if you have some kind of plugin architecture internally. Telegraf is a good example of this pattern.

Plugin libraries may be nice for some use cases, but static builds are very convenient for distribution/deployment.

Perhaps folks here will be able to give better advice if you describe the problem you're trying to solve with plugin.

pr0v4:

Telegraf is a solid example, thanks for sharing. It's on track of what we are trying to build.

The idea is to have a binary that would connect to the server and download plugins that it needs. Thus not deploying 15 plugins everywhere if only 3 are needed for example. And as with Telegraf to have a minimal memory footprint.

lluad:

I think best practice around it is probably not to use it in production, not quite yet. It's almost there, at least on Linux, but not quite.

For dynamically loaded - rather than embedded at compile time - plugins I'd look at Hashicorp's go-plugin as an alternative, one that runs plugins out-of-process. It's grpc-based, so the plugins don't even need to be written in Go. Though if you're looking to minimize footprint that's probably the wrong direction.

pr0v4:

Can you note what's missing to be "production" ready? I really need it to have footprint as small as possible and performance is really important. Plugins will and can be written in GO, that's not a problem.

upboatact:

Admittedly just nitpicking here, but it's so weird to me: you wrote the name of the language correctly in your title and than you capitalized it in the body of your post. Why?

If it's to trigger people with OCD, well played :)

pr0v4:

Thanks, I've edited that one :). Wasn't thinking about those details I guess.


入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

739 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传