wire README

The project's README from github.com/google/wire. As one markdown file: README.md.

Wire: Automated Initialization in Go

Build Status godoc

[!WARNING] This project is no longer maintained.

If you wish to update or extend wire, please do so in a fork.

Wire is a code generation tool that automates connecting components using dependency injection. Dependencies between components are represented in Wire as function parameters, encouraging explicit initialization instead of global variables. Because Wire operates without runtime state or reflection, code written to be used with Wire is useful even for hand-written initialization.

For an overview, see the introductory blog post.

Installing

Install Wire by running:

go install github.com/google/wire/cmd/wire@latest

and ensuring that $GOPATH/bin is added to your $PATH.

Documentation

Project status

As of version v0.3.0, Wire is beta and is considered feature complete. It works well for the tasks it was designed to perform, and we prefer to keep it as simple as possible.

We'll not be accepting new features at this time, but will gladly accept bug reports and fixes.

Community

For questions, please use GitHub Discussions.

This project is covered by the Go Code of Conduct.

wire (google/wire)

Searching Database…

14.4K ·GitHub
archived
这是什么东西?Wire 是 Google 出品的一个代码生成工具,它用依赖注入的方式自动完成 Go 中各组件之间的连接:你只需声明各个 provider,Wire 就会生成把这些组件组装起来的初始化代码。
它是我的程序在运行时使用的库,还是我在构建时运行的工具?它是一个命令行代码生成器:生成的是普通的 Go 初始化代码,不依赖任何运行时状态或反射,所以你的二进制文件里不会包含任何 Wire 专属的东西。
Wire 还在积极开发吗?没有了——代码仓库已经归档,README 也说明该项目不再维护。它目前处于 beta 阶段,但自 v0.3.0 起被认为功能已经完整,官方只接受 bug 报告和修复。
Wire 希望我怎样连接各个组件?依赖关系通过 provider 函数之间普通的函数参数来表达,这样能促使你使用显式的初始化而不是全局变量——而且由于运行时没有任何东西在跑,就算哪天你手写初始化代码,这些函数也照样能用。
安装好之后,我应该从哪里开始看?README 里链接了一份教程(Tutorial)、一份用户指南(User Guide)、一份最佳实践文档和一份 FAQ,都放在仓库的 docs 文件夹里。
我能给 Wire 添加自己的功能吗?在官方主仓库里不行:README 建议任何想更新或扩展 wire 的人在自己的 fork 里做,原项目只接受 bug 报告和修复。
Creator
google
Size
0.5 MB
Stars
14.4K
Age
7y
Commits · 90 Days