Compare commits

...

11 Commits

Author SHA1 Message Date
des
a90823eba4 自动查找实现
Some checks failed
Wire Tests / build (1.25.x, macos-latest) (push) Has been cancelled
Wire Tests / build (1.25.x, ubuntu-latest) (push) Has been cancelled
Wire Tests / build (1.25.x, windows-latest) (push) Has been cancelled
但是自动收集到数组是个超级糟糕的需求。糟糕到我认为需要另起炉灶。
2026-02-24 20:55:18 +08:00
Robert Findley
9c25c9016f README: add a note that wire is no longer maintained (#434)
Some checks failed
Wire Tests / build (1.25.x, macos-latest) (push) Has been cancelled
Wire Tests / build (1.25.x, ubuntu-latest) (push) Has been cancelled
Wire Tests / build (1.25.x, windows-latest) (push) Has been cancelled
Wire was archived by an automatic process because it was not being
maintained. Unfortunately, it's true that there is no one maintaining
wire, and we should make this clear in the README before re-archiving.
2025-08-22 09:52:05 -04:00
Robert Findley
5c5c92a1c5 all: update the x/tools dependency to fix the build with Go 1.25 (#432)
An unfortunate bug caused a number of packages in old x/tools versions
to fail to build with Go 1.25 (https://go.dev/issue/74462). Fix this
minimally by updating to the lowest patched version with the fix:
v0.24.1. This should allow wire to continue building with the same range
of Go versions as it could build with before (down to 1.19).

Also:
- Update the go.mod go directive to Go 1.19 to allow for module graph
  pruning, and to be consistent with the minimum build version.
- Fix a test that is broken in recent Go versions due to an error
  message change.
- Update tests to run on Go 1.25.x (the most recent version of Go).
- Remove coverage, since coverage upload wasn't working anyway.

Fixes #431
2025-08-21 10:01:40 -04:00
Todd Treece
e57deea2f8 all: update golang.org/x/tools dependency to support Go v1.22.0 (#401) 2024-02-07 09:25:46 -08:00
Stanley Chen
0675cdc919 Revert "Update dependencies to support Generics (#360)" (#365)
This reverts commit 4aee85e4ce.
2022-06-20 10:14:24 +08:00
Enrique Fueyo
4aee85e4ce Update dependencies to support Generics (#360)
* feat(copy_ast): add ast.IndexListExpr case

* feat(go.mod): add dependencies (golang.org/x/tools v0.1.0 => v0.1.10)
2022-06-19 17:37:05 -07:00
wirekang
79660af943 README: fix install instructions on tutorial (#357) 2022-05-26 22:32:31 -07:00
Giau. Tran Minh
f5e937daa9 fix: run wire with -mod=mod (#353)
* fix: run wire with -mod=mod

* chore: update test with mod flag
2022-05-26 22:31:39 -07:00
Russ Cox
9d78e0ad8c README: fix install instructions (#339)
go get p has been replaced by go install p@latest.
2022-01-06 19:25:54 -08:00
Eli Bendersky
2f70a008e2 Fix build badge link in README (#317) 2021-08-31 08:30:57 -07:00
Robert van Gent
3b6fb78a3f tests: disable apidiff check (#316) 2021-08-30 17:57:05 -07:00
60 changed files with 147 additions and 133 deletions

View File

@@ -19,7 +19,7 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-latest, macos-latest, windows-latest] os: [ubuntu-latest, macos-latest, windows-latest]
go-version: [1.17.x] go-version: [1.25.x]
runs-on: ${{ matrix.os }} runs-on: ${{ matrix.os }}
steps: steps:
- name: Install Go - name: Install Go

View File

@@ -1,9 +1,12 @@
# Wire: Automated Initialization in Go # Wire: Automated Initialization in Go
![Build Status](https://github.com/google/wire/actions/workflows/tests.yml/badge.svg?branch=main) [![Build Status](https://github.com/google/wire/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/google/wire/actions)
[![godoc](https://godoc.org/github.com/google/wire?status.svg)][godoc] [![godoc](https://godoc.org/github.com/google/wire?status.svg)][godoc]
[![Coverage](https://codecov.io/gh/google/wire/branch/master/graph/badge.svg)](https://codecov.io/gh/google/wire)
> [!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 Wire is a code generation tool that automates connecting components using
[dependency injection][]. Dependencies between components are represented in [dependency injection][]. Dependencies between components are represented in
@@ -24,7 +27,7 @@ For an overview, see the [introductory blog post][].
Install Wire by running: Install Wire by running:
```shell ```shell
go get github.com/google/wire/cmd/wire go install github.com/google/wire/cmd/wire@latest
``` ```
and ensuring that `$GOPATH/bin` is added to your `$PATH`. and ensuring that `$GOPATH/bin` is added to your `$PATH`.

View File

@@ -163,7 +163,7 @@ injector complete, we are ready to use the `wire` command line tool.
Install the tool with: Install the tool with:
``` shell ``` shell
go get github.com/google/wire/cmd/wire go install github.com/google/wire/cmd/wire@latest
``` ```
Then in the same directory with the above code, simply run `wire`. Wire will Then in the same directory with the above code, simply run `wire`. Wire will

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -151,7 +151,7 @@ Wire will produce an implementation of the injector in a file called
```go ```go
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//+build !wireinject //+build !wireinject
package main package main

13
go.mod
View File

@@ -1,12 +1,15 @@
module github.com/google/wire module github.com/google/wire
go 1.12 go 1.19
require ( require (
github.com/google/go-cmp v0.2.0 github.com/google/go-cmp v0.6.0
github.com/google/subcommands v1.2.0 github.com/google/subcommands v1.2.0
github.com/pmezard/go-difflib v1.0.0 github.com/pmezard/go-difflib v1.0.0
golang.org/x/mod v0.4.1 // indirect golang.org/x/tools v0.24.1
golang.org/x/sys v0.0.0-20210216224549-f992740a1bac // indirect )
golang.org/x/tools v0.1.0
require (
golang.org/x/mod v0.20.0 // indirect
golang.org/x/sync v0.8.0 // indirect
) )

38
go.sum
View File

@@ -1,34 +1,12 @@
github.com/google/go-cmp v0.2.0 h1:+dTQ8DZQJz0Mb/HjFlkptS1FeQ4cWSnN941F8aEG4SQ= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE= github.com/google/subcommands v1.2.0 h1:vWQspBTo2nEqTUFita5/KeEWlUL8kQObDFbub/EN9oE=
github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= github.com/google/subcommands v1.2.0/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/tools v0.24.1 h1:vxuHLTNS3Np5zrYoPRpcheASHX/7KiGo+8Y4ZM1J2O8=
golang.org/x/mod v0.4.1 h1:Kvvh58BN8Y9/lBi7hTekvtMpm07eUZ0ck5pRHpsMWrY= golang.org/x/tools v0.24.1/go.mod h1:YhNqVBIfWHdzvTLs0d8LCuMhkKUgSUKldakyV7W/WDQ=
golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210216224549-f992740a1bac h1:9glrpwtNjBYgRpb67AZJKHfzj1stG/8BL5H7In2oTC4=
golang.org/x/sys v0.0.0-20210216224549-f992740a1bac/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.0 h1:po9/4sTYwZU9lPhi1tOrb4hCv3qrhiQ77LZfGa2OjwY=
golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=

View File

@@ -2,6 +2,5 @@ github.com/google/subcommands
github.com/google/wire github.com/google/wire
github.com/pmezard/go-difflib github.com/pmezard/go-difflib
golang.org/x/mod golang.org/x/mod
golang.org/x/sys golang.org/x/sync
golang.org/x/tools golang.org/x/tools
golang.org/x/xerrors

View File

@@ -21,11 +21,11 @@
# This script expects: # This script expects:
# a) to be run at the root of the repository # a) to be run at the root of the repository
# b) HEAD is pointing to a commit that merges between the pull request and the # b) HEAD is pointing to a commit that merges between the pull request and the
# upstream branch (GITHUB_HEAD_REF). # upstream branch (GITHUB_BASE_REF).
set -euo pipefail set -euo pipefail
UPSTREAM_BRANCH="${GITHUB_HEAD_REF:-master}" UPSTREAM_BRANCH="${GITHUB_BASE_REF:-master}"
echo "Checking for incompatible API changes relative to ${UPSTREAM_BRANCH}..." echo "Checking for incompatible API changes relative to ${UPSTREAM_BRANCH}..."
MASTER_CLONE_DIR="$(mktemp -d)" MASTER_CLONE_DIR="$(mktemp -d)"

View File

@@ -21,19 +21,10 @@ if [[ $# -gt 0 ]]; then
exit 64 exit 64
fi fi
# Run Go tests. Only do coverage for the Linux build # Run Go tests.
# because it is slow, and codecov will only save the last one anyway.
result=0 result=0
if [[ "${RUNNER_OS:-}" == "Linux" ]]; then
echo "Running Go tests (with coverage)..."
go test -mod=readonly -race -coverpkg=./... -coverprofile=coverage.out ./... || result=1
if [ -f coverage.out ] && [ $result -eq 0 ]; then
bash <(curl -s https://codecov.io/bash)
fi
else
echo "Running Go tests..." echo "Running Go tests..."
go test -mod=readonly -race ./... || result=1 go test -mod=readonly -race ./... || result=1
fi
# No need to run other checks on OSs other than linux. # No need to run other checks on OSs other than linux.
# We default RUNNER_OS to "Linux" so that we don't abort here when run locally. # We default RUNNER_OS to "Linux" so that we don't abort here when run locally.
@@ -71,9 +62,10 @@ echo "Ensuring that there are no dependencies not listed in ./internal/alldeps..
# For pull requests, check if there are undeclared incompatible API changes. # For pull requests, check if there are undeclared incompatible API changes.
# Skip this if we're already going to fail since it is expensive. # Skip this if we're already going to fail since it is expensive.
if ${result} -eq 0 ]] && [[ ! -z "${GITHUB_HEAD_REF:-x}" ]]; then # CURRENTLY BROKEN
echo # if [[ ${result} -eq 0 ]] && [[ ! -z "${GITHUB_HEAD_REF:-x}" ]]; then
./internal/check_api_change.sh || result=1; # echo
fi # ./internal/check_api_change.sh || result=1;
# fi
exit $result exit $result

View File

@@ -329,6 +329,8 @@ func verifyArgsUsed(set *ProviderSet, used []*providerSetSrc) []error {
// buildProviderMap creates the providerMap and srcMap fields for a given // buildProviderMap creates the providerMap and srcMap fields for a given
// provider set. The given provider set's providerMap and srcMap fields are // provider set. The given provider set's providerMap and srcMap fields are
// ignored. // ignored.
//
// 这里就是查找注入的核心
func buildProviderMap(fset *token.FileSet, hasher typeutil.Hasher, set *ProviderSet) (*typeutil.Map, *typeutil.Map, []error) { func buildProviderMap(fset *token.FileSet, hasher typeutil.Hasher, set *ProviderSet) (*typeutil.Map, *typeutil.Map, []error) {
providerMap := new(typeutil.Map) providerMap := new(typeutil.Map)
providerMap.SetHasher(hasher) providerMap.SetHasher(hasher)

View File

@@ -74,6 +74,7 @@ func (p *providerSetSrc) description(fset *token.FileSet, typ types.Type) string
// trace returns a slice of strings describing the (possibly recursive) source // trace returns a slice of strings describing the (possibly recursive) source
// of p, including line numbers. // of p, including line numbers.
// 这里是 srcMap 唯一使用的地方,看起来似乎只是用作错误输出,应该不会干扰我的修改。
func (p *providerSetSrc) trace(fset *token.FileSet, typ types.Type) []string { func (p *providerSetSrc) trace(fset *token.FileSet, typ types.Type) []string {
var retval []string var retval []string
// Only Imports need recursion. // Only Imports need recursion.
@@ -122,12 +123,39 @@ func (set *ProviderSet) Outputs() []types.Type {
} }
// For returns a ProvidedType for the given type, or the zero ProvidedType. // For returns a ProvidedType for the given type, or the zero ProvidedType.
// 这个方法是我们改造的重点,两个功能都要从这个函数进行动作
// - 自动查找所有接口的实现
//
// 已知的困难是
//
// 比如遇见一个新的接口,遍历所有 ProvidedType 进行检查并向 ProviderMap 中添加项以避免下次检查。
// 但是如果有两个接口先后需要查找,此时第二次查找同样会遍历第一次查找生成的 ProviderType 数据。
// 我想起来了,好像 ProviderSet 中有个 providers 属性储存了原始的那啥。可以使用这个遍历避免 ProviderType 膨胀问题
func (set *ProviderSet) For(t types.Type) ProvidedType { func (set *ProviderSet) For(t types.Type) ProvidedType {
pt := set.providerMap.At(t) pt := set.providerMap.At(t)
if pt == nil { if pt != nil {
return *pt.(*ProvidedType)
}
face, isFace := t.Underlying().(*types.Interface)
if !isFace {
return ProvidedType{} return ProvidedType{}
} }
return *pt.(*ProvidedType) var addMap []ProvidedType
for _, provider := range set.Providers {
pro := types.Implements(provider.Out[0], face)
if pro {
addMap = append(addMap, ProvidedType{t: t, p: provider})
}
}
if len(addMap) == 0 {
return ProvidedType{}
} else if len(addMap) == 1 {
provider := addMap[0]
set.providerMap.Set(t, &provider)
set.srcMap.Set(t, &providerSetSrc{Provider: provider.p})
return provider
}
panic("接口 " + t.String() + " 拥有多个实现")
} }
// An IfaceBinding declares that a type should be used to satisfy inputs // An IfaceBinding declares that a type should be used to satisfy inputs
@@ -1155,6 +1183,9 @@ func isProviderSetType(t types.Type) bool {
// can be a *Provider (a provider function), a *Value (wire.Value), or an // can be a *Provider (a provider function), a *Value (wire.Value), or an
// *InjectorArgs (arguments to the injector function). The zero value has // *InjectorArgs (arguments to the injector function). The zero value has
// none of the above, and returns true for IsNil. // none of the above, and returns true for IsNil.
//
// 在我的角度来看,这东西其实有点职责混淆。因为他还顺带兼任了判断类是否存在的功能。
// 总之,这个结构体标记了提供者,还有一个检查是否有提供者的方法。当然,可能不止这一个功能。
type ProvidedType struct { type ProvidedType struct {
// t is the provided concrete type. // t is the provided concrete type.
t types.Type t types.Type

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -2,7 +2,7 @@
// //
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1 +1,3 @@
example.com/foo/wire.go:x:y: not enough arguments in call to wire.Bind example.com/foo/wire.go:x:y: not enough arguments in call to wire.Bind
have (*Fooer)
want (interface{}, interface{})

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1 +1,3 @@
example.com/foo/wire.go:x:y: not enough arguments in call to wire.InterfaceValue example.com/foo/wire.go:x:y: not enough arguments in call to wire.InterfaceValue
have (string)
want (interface{}, interface{})

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1 +1 @@
example.com/foo/wire.go:x:y: foo not exported by package bar example.com/foo/wire.go:x:y: name foo not exported by package bar

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -1,6 +1,6 @@
// Code generated by Wire. DO NOT EDIT. // Code generated by Wire. DO NOT EDIT.
//go:generate go run github.com/google/wire/cmd/wire //go:generate go run -mod=mod github.com/google/wire/cmd/wire
//go:build !wireinject //go:build !wireinject
// +build !wireinject // +build !wireinject

View File

@@ -267,7 +267,7 @@ func (g *gen) frame(tags string) []byte {
tags = fmt.Sprintf(" gen -tags \"%s\"", tags) tags = fmt.Sprintf(" gen -tags \"%s\"", tags)
} }
buf.WriteString("// Code generated by Wire. DO NOT EDIT.\n\n") buf.WriteString("// Code generated by Wire. DO NOT EDIT.\n\n")
buf.WriteString("//go:generate go run github.com/google/wire/cmd/wire" + tags + "\n") buf.WriteString("//go:generate go run -mod=mod github.com/google/wire/cmd/wire" + tags + "\n")
buf.WriteString("//+build !wireinject\n\n") buf.WriteString("//+build !wireinject\n\n")
buf.WriteString("package ") buf.WriteString("package ")
buf.WriteString(g.pkg.Name) buf.WriteString(g.pkg.Name)

View File

@@ -463,7 +463,6 @@ type testCase struct {
// program_out.txt // program_out.txt
// expected output from the final compiled program, // expected output from the final compiled program,
// missing if wire_errs.txt is present // missing if wire_errs.txt is present
//
func loadTestCase(root string, wireGoSrc []byte) (*testCase, error) { func loadTestCase(root string, wireGoSrc []byte) (*testCase, error) {
name := filepath.Base(root) name := filepath.Base(root)
pkg, err := ioutil.ReadFile(filepath.Join(root, "pkg")) pkg, err := ioutil.ReadFile(filepath.Join(root, "pkg"))
@@ -477,7 +476,10 @@ func loadTestCase(root string, wireGoSrc []byte) (*testCase, error) {
wantWireError := err == nil wantWireError := err == nil
var wantWireErrorStrings []string var wantWireErrorStrings []string
if wantWireError { if wantWireError {
wantWireErrorStrings = strings.Split(string(wireErrb), "\n\n") for _, errs := range strings.Split(string(wireErrb), "\n\n") {
// Allow for trailing newlines, which can be hard to remove in some editors.
wantWireErrorStrings = append(wantWireErrorStrings, strings.TrimRight(errs, "\n\r"))
}
} else { } else {
if !*record { if !*record {
wantWireOutput, err = ioutil.ReadFile(filepath.Join(root, "want", "wire_gen.go")) wantWireOutput, err = ioutil.ReadFile(filepath.Join(root, "want", "wire_gen.go"))