项目作者: codomatech

项目描述 :
Static (i.e. compile-time) plugins for go
高级语言: Go
项目地址: git://github.com/codomatech/spluggy.git
创建时间: 2020-10-09T09:03:04Z
项目社区:https://github.com/codomatech/spluggy

开源协议:BSD 3-Clause "New" or "Revised" License

下载


spluggy: compile-time plugins for go

Organizing your code as plugins has many benefits, Go provides excellent support for them.
The caveat (beside dependency hell) is that you lose the cool, single-binary advantage of Go.

spluggy gets you the best of both worlds: static plugins.
You define your plugins as sub-packages within the same package. As long as they all expose a function with the same name,
spluggy will discover them automatically and make the function accessible for external packages.

Usage

A functioning app is in example which demonstrates how to use spluggy using go generate.
The commend line interface is:

  1. Usage: spluggy <flags> <package directory>
  2. With flags:
  3. -func string
  4. The exposed function name
  5. -out string
  6. Output file name (default "plugins.go")
  7. -pkg string
  8. The base package
  9. -v Enable verbose output

Known Limitations

Currently spluggy cannot infer struct type dependencies defined within a map, e.g.

  1. // spluggy cannot infer that "somepackage" shoud be imported
  2. func Fn(map[somepackage.SomeStructType]int) {
  3. ...
  4. }

This will be addressed in the next version.


spluggy is a work of :heart: by Codoma.tech.