-
Notifications
You must be signed in to change notification settings - Fork 18k
plugin: Global variable is exported as pointer instead of value #31882
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
Comments
This is expected. When using the |
This design choice has implications on the readability of code that makes use of plugins. To me this does not seem consistent either with the Go design philosophy or within the actual implementation. I can't think of anywhere else in the Go standard library where the type of a variable is changed automatically to satisfy an assumed requirement. |
It's only the difference between
and
It's only 2 characters extra. I agree it's a bit tricky, but plugins are already well into the tricky realm. I suspect most people don't want to modify the global variable, but some people will. We have to provide some way to modify a global. If In any case, it is too late now. We can't change the behavior of Maybe some additional docs in the plugin package would help. The example makes it clear, but the |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, as well as against tip
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
This example requires 3 packages: a plugin, an imported package and a main package
plugin:
imported package:
Main package that loads the plugin:
What did you expect to see?
No panics.
What did you see instead?
panic: interface conversion: plugin.Symbol is *q.MagicType, not q.MagicType
The text was updated successfully, but these errors were encountered: