Open
Description
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:
Metadata
Metadata
Assignees
Labels
No labels