Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
cmd/go: Allow building non-main package with -buildmode=plugin #18124
The plugin package currently requires a
The current methodology is that these are compiled into the host with
This feels like unnecessary boilerplate. At Ian's suggestion I propose modifying the go tool to generate such a main package when using
I plan on working on this feature.
Turns out this is not so easy. This solution would solve my immediate use case, but only because my plugins do not need to export anything. The generated main package hides the exports from the actual package you want to build, and the host app won't be able to find them with
The only solution I can think of is essentially rewriting all go files in the package to a tmp directory and rewriting the import to main. Probably out of scope of what you would be willing to accept for this.
Any other ideas?
I see, you're right, I was thinking more of c-shared and c-archive, where any package can export a symbol (by using a magic cgo
referenced this issue
Dec 19, 2016
I also just hit this issue, as we want to support either dynamic loading of plugins or preloading them during build of the program, I will be generating
This will only work for us as we use single variable export as entry point of plugins.