wire
wire copied to clipboard
Export wire.Generate from internal/
This PR explores the idea of allowing wire to be used as a library in addition to its current use as a CLI-only tool.
Currently, all logic to generate the wire_gen.go
files is locked under the internal/
directory. While it has its upsides, it blocks users from using wire as a library. It is helpful for framework authors (see the use of wire in Copper) to wrap wire in their own CLIs and still enable dependency injection.
This PR exports the wire.Generate
method that would allow it to be called by other CLIs to generate the wire_gen.go
files.
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).
View this failed invocation of the CLA check for more information.
For the most up to date status, view the checks section at the bottom of the pull request.
For your needs, is it possible to consume wire as a binary? e.g. in your framework you can interact with wire through Go's exec.Cmd
? I'd rather we don't increase the API surface of wire. WDYT?
@jayzhuang That's exactly what it does right now and while it works, it's not a great solution. It makes the setup harder for users because they need to install 2 things (Copper and Wire CLIs, see here). For now, I'm recommending users use go install ..
to install binaries but I'd like to move towards pre-compiled binaries for Copper CLI. I believe Wire doesn't provide these so that would be an additional thing to setup.
Using wire as a library makes these issues go away so I'd definitely prefer to have that. I tried this approach by forking wire and it's much better.
While I understand your need, wire
is intended as a CLI tool, and making its library API available would make future refactors and fixes harder for wire
. I think in you particular case, if you want to ship Copper
as a binary, you can clone this repo, apply your patch locally and compile. It requires a few extra steps, but that can be automated.