On Tue, Feb 28, 2017 at 12:44 PM, Basile Starynkevitch <[email protected]> wrote: > > Can a plugin be made of several source files in Go?
Yes. > How should then I > compile a single plugin myfoo.so from several Go source files ? Can a > plugin define several packages? A plugin is a main package. It can be built from as many source files as you like. I think a plugin can only define a single main package. > Can a plugin contain several packages? How can I refer to symbols inside > packages of plugins? As the usual "packagename.PublicSymbol" passed as > argument to plugin.Lookup ? If yes, that should IMHO be documented. As far as I know you can only refer to symbols defined in the main package. I could be wrong about that. > Can one get a plugin handle for the entire program & process (like dlopen(3) > does with a NULL filename argument on Linux) From my understanding of > plugin/plugin_dlopen.go this is not the case. I wish it would be the case. You can not. > Can the packages defined in one plugin be visible from plugins loaded > afterwards? I'm thinking of a dlopen with RTLD_GLOBAL flag in C parlance. I'm not sure this really makes sense in a Go context. I'm not sure how you would refer to those symbols. > I'm interested in having my Go program (monimelt on github, currently > Feb2017 in pre-alpha stage, so nothing is working) generate at runtime some > Go source files, compiling them as a plugin (by forking some compilation > command at runtime), and loading them. BTW, I'm really interested in Go only > since its plugin abilities.... so they matter a lot to me. As far as I know that would work. Note that the plugin support is very new, is experimental, and several bugs have been reported against it already (search for plugin at https://golang.org/issue). > Is dladdr(3) available in Go? I would like, given a pointer, to get the name > of the function at the same address (but I guess there could be issues with > closures). See runtime.FuncForPC. > Is there any name mangling issues the user of Go plugins should be aware of? I don't think so. I mean, names are mangled slightly, but you shouldn't need to know about it. Ian -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
