dongxu4023 2019-08-08 07:38
浏览 109
已采纳

Go插件-“插件是使用其他版本的软件包构建的”

I have an application that loads plugins on startup (daemon). In a subpackage (daemon/interfaces), I have a few interfaces that plugins for this program should use.

This means that the main program also gets imported by the plugin.

I am using Go modules (for both the main program and the plugin) to fix the versions, and I can see in go.mod that it is using the latest version of the main program for the plugin.

I can build them both fine, but when I load the plugin it gives me an error saying

 panic: plugin.Open("plugins/my-plugin"): plugin was built with a different version of package daemon/interfaces

I am using Go 1.12.7 to build both of the packages.

  • 写回答

1条回答 默认 最新

  • dongwei1921 2019-08-08 08:06
    关注

    I fixed this by adding a replace statement to my plugin go.mod file

    module github.com/user/plugin
    
    go 1.12
    
    require (
        github.com/user/daemon v1.1.1
    )
    
    replace github.com/user/daemon v1.1.1 => ../local/path/to/daemon/
    

    It also helps when you are building the project from outside of the directory where the source code is in by using the full name of the project (go build github.com/user/project/)

    There is a related Github issue on the Golang repository that you can find here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型
  • ¥15 求学软件的前人们指明方向🥺