Skip to content

pkg/plugin: implement using es6 module imports #842

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

Open
paralin opened this issue Jul 12, 2018 · 0 comments
Open

pkg/plugin: implement using es6 module imports #842

paralin opened this issue Jul 12, 2018 · 0 comments

Comments

@paralin
Copy link
Contributor

paralin commented Jul 12, 2018

The plugin package in Go declares a simple mechanism for loading Go plugins.

  • A package is compiled with the command go build -buildmode=plugin
  • A plugin file is produced (on Linux this is a shared library)
  • At runtime, a program can load a plugin and all exported symbols.
// Open opens a Go plugin.
// If a path has already been opened, then the existing *Plugin is returned.
// It is safe for concurrent use by multiple goroutines.
func Open(path string) (*Plugin, error) {
	// GopherJS: load the plugin from the .js file using module.exports.
}

// Lookup searches for a symbol named symName in plugin p.
// A symbol is any exported variable or function.
// It reports an error if the symbol is not found.
// It is safe for concurrent use by multiple goroutines.
func (p *Plugin) Lookup(symName string) (Symbol, error) {
	// GopherJS: lookup the symbol using the lookup table.
}

Docs: https://golang.org/pkg/plugin/

There are then two components that could be implemented for GopherJS:

  • Compiler: build mode to produce plugin (module.exports exported symbol table)
  • Runtime: implement plugin package with proper init() ordering at open() time

Would this be feasible to implement in GopherJS?

Related:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants