https://github.com/codomatech/spluggy
Static (i.e. compile-time) plugins for go
https://github.com/codomatech/spluggy
code-generation golang plugins static-analysis
Last synced: 5 months ago
JSON representation
Static (i.e. compile-time) plugins for go
- Host: GitHub
- URL: https://github.com/codomatech/spluggy
- Owner: codomatech
- License: bsd-3-clause
- Created: 2020-10-09T09:03:04.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-10-12T17:02:29.000Z (over 5 years ago)
- Last Synced: 2025-03-24T23:51:31.745Z (11 months ago)
- Topics: code-generation, golang, plugins, static-analysis
- Language: Go
- Homepage:
- Size: 13.7 KB
- Stars: 25
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `spluggy`: compile-time plugins for go
Organizing your code as plugins has many benefits, Go provides [excellent support for them](https://golang.org/pkg/plugin/).
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](example) which demonstrates how to use `spluggy` using `go generate`.
The commend line interface is:
```
Usage: spluggy
With flags:
-func string
The exposed function name
-out string
Output file name (default "plugins.go")
-pkg string
The base package
-v Enable verbose output
```
## Known Limitations
Currently `spluggy` cannot infer struct type dependencies defined within a `map`, e.g.
```go
// spluggy cannot infer that "somepackage" shoud be imported
func Fn(map[somepackage.SomeStructType]int) {
...
}
```
This will be addressed in the next version.
---
`spluggy` is a work of :heart: by [Codoma.tech](https://www.codoma.tech/).