Skip to content
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

Feature: compiler plugin #51

Open
xhd2015 opened this issue Apr 11, 2024 · 0 comments
Open

Feature: compiler plugin #51

xhd2015 opened this issue Apr 11, 2024 · 0 comments

Comments

@xhd2015
Copy link
Owner

xhd2015 commented Apr 11, 2024

A general solution to #48

Provides the user a chance to inspect specific package's content, and modify them on the fly.

A possible implementation:

  • When xgo compiles a package, it finds possible matching plugins,
  • These plugins are go code which accepts a compile context as input, and return a Result describing what effects will be applied to the following compiling process, for instance, inserting a code snippet into beginning of a specific file

Plugin signature:

package plugin_demo

import (
     "github.com/xhd2015/xgo/plugin"
)

func Handle(ctx *plugin.CompileContext) *plugin.Result {
    return nil
}

Primary considerations:

  • Performance
    • the plugin should be an opt in feature, if there isn't any, then performance should be as same as before
    • if there is some, ensure only invoke them when targets match
  • Security
    • If user do not deliberately use it, then the compiler should bypass it
  • Reusability
    • Plugin can be written in another separate module, then imported by different projects.
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

1 participant