-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin: fails to correctly reference type from vendor #27062
Comments
Upon further inspection, it appears the reflection does not view the type |
It looks like the discussion from https://github.com/golang/proposal/blob/master/design/25719-go15vendor.md and the comment in Line 360 in 3acd257
Does anyone have a better method that I could use in my example to load the plugin with the custom type |
Recommendations:
|
My workaround for this bug, is to store the $ cat deps.sh
#!/bin/sh
unset IFS
set -euf
go get github.com/TykTechnologies/tyk
sh -c "cd $GOPATH/src/github.com/TykTechnologies/tyk && git checkout v2.9.4.3"
# Re-enable Tyk plugin feature
sh -c "cd $GOPATH/src/github.com/TykTechnologies/tyk && go install -a -tags 'goplugin'"
$ ./deps.sh This is not ideal for Windows, but it basically works in any UNIX environment, such as WSL. |
I believe the solution is to use modules (and thus not use nested vendor directories). |
I do use modules. Vendoring is an option in go modules. I use this option to mitigate leftpad (actually logrus and moby) problems. |
I think the issue here is the use of plugins with vendor directories. |
I'm not sure how this applies to building with modules, even with vendoring. The original report was for the main and plugin package each vendoring a shared dependency in their own subtrees, the identity of the dependency was different due to the different build paths. in module mode: if the main and plugin package are in the same module, then it shares the vendor directory, and thus same identity for the dependency. I think we would need a modern reproducer if we want to keep this open. |
Timed out in state WaitingForInfo. Closing. (I am just a bot, though. Please speak up if this is a mistake or you have the requested information.) |
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.10.3 linux/amd64
Does this issue reproduce with the latest release?
yes, 1.10.3
What operating system and processor architecture are you using (
go env
)?What did you do?
When using plugins, in a typical github vendoring approach:
$GOPATH/src/github.com/author/repo/package
with resources in$GOPATH/src/github.com/author/repo/package/vendor/github.com/author/repoa/package
, if the plugin was compiled using a separate package, that is ultimately imported into the main package via vendoring, the types don't match and casting is not possible.This tree works (rooted at
$GOPATH/src/github.com
:This tree does not work (rooted at
$GOPATH/src/github.com
)In both the working and not working cases, the imports are the same, just the directory structure is different.
plbody.go:
pltypes.go:
plmain.go:
plplugin.go:
What did you expect to see?
What did you see instead?
The types are not castable to each other:
The text was updated successfully, but these errors were encountered: