Categorygithub.com/google/wire
modulepackage
0.6.0
Repository: https://github.com/google/wire.git
Documentation: pkg.go.dev

# README

Wire: Automated Initialization in Go

Build Status godoc Coverage

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.

# Packages

# Functions

Bind declares that a concrete type should be used to satisfy a dependency on the type of iface.
Build is placed in the body of an injector function template to declare the providers to use.
FieldsOf declares that the fields named of the given struct type will be used to provide the types of those fields.
InterfaceValue binds an expression to provide a specific interface type.
NewSet creates a new provider set that includes the providers in its arguments.
Struct specifies that the given struct type will be provided by filling in the fields in the struct that have the names given.
Value binds an expression to provide the type of the expression.

# Structs

A Binding maps an interface to a concrete type.
A ProvidedValue is an expression that is copied to the generated injector.
ProviderSet is a marker type that collects a group of providers.
StructFields is a collection of the fields from a struct.
A StructProvider represents a named struct.