我的程序在Ubuntu中运行时首先需要一个插件:
go build -race -buildmode=plugin ../mrapps/wc.go当我创建launch.json并尝试在VSCode中调试一个文件时:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch mrworker",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "src/main/mrworker.go",
"args": ["wc.so"]
}
]
}控制台显示了cannot load plugin wc.so
Starting: /home/lzq/go/bin/dlv-dap dap --check-go-version=false --listen=127.0.0.1:44503 --log-dest=3 from /home/lzq/Document/MapReduce/6.824/src/main
DAP server listening at: 127.0.0.1:44503
Type 'dlv help' for list of commands.
2022/01/09 22:38:32 cannot load plugin wc.so
Process 17678 has exited with status 1
Detaching
dlv dap (17594) exited with code: 0当我使用dlv查找更多信息时,错误是plugin was built with a different version of package。
我读了很多帖子,但都没有用。我怎样才能解决这个问题?
发布于 2022-02-17 10:51:04
发布于 2022-01-10 06:11:57
根据文档:
目前,插件只支持Linux、FreeBSD和macOS,正如最新版本的Golang所提到的那样。exe二进制和plugin对象之间的依赖不完全匹配,这就是插件加载程序抛出上述错误的原因。
Go使用最小版本选择。很难确定传递的依赖项,因为Go只在插件代码项目中选择它认为满足依赖树的最小版本,而没有任何方法表明需要考虑另一个依赖树。
有很多办法可以解决这个问题:
参考以下链接:https://forum.heroiclabs.com/t/plugin-was-built-with-a-different-version-of-package/556/5,https://github.com/golang/go/issues/31354
或
您可以尝试使用-gcflags "all=-N -l"标志构建插件。
要更好地理解,请参考以下内容:https://youtrack.jetbrains.com/issue/GO-6288
您还可以在replace文件示例中尝试使用go.mod:
replace github.com/zimnx/central => ../centralhttps://stackoverflow.com/questions/70642618
复制相似问题