Compare commits

..

10 Commits

Author SHA1 Message Date
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
59 changed files with 112 additions and 131 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..."
echo "Running Go tests (with coverage)..." go test -mod=readonly -race ./... || result=1
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..."
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

@@ -1173,9 +1173,9 @@ func (pt ProvidedType) IsNil() bool {
// //
// - For a function provider, this is the first return value type. // - For a function provider, this is the first return value type.
// - For a struct provider, this is either the struct type or the pointer type // - For a struct provider, this is either the struct type or the pointer type
// whose element type is the struct type. // whose element type is the struct type.
// - For a value, this is the type of the expression. // - For a value, this is the type of the expression.
// - For an argument, this is the type of the argument. // - For an argument, this is the type of the argument.
func (pt ProvidedType) Type() types.Type { func (pt ProvidedType) Type() types.Type {
return pt.t return pt.t
} }

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"))

36
wire.go
View File

@@ -156,12 +156,12 @@ type StructProvider struct{}
// //
// For example: // For example:
// //
// type S struct { // type S struct {
// MyFoo *Foo // MyFoo *Foo
// MyBar *Bar // MyBar *Bar
// } // }
// var Set = wire.NewSet(wire.Struct(new(S), "MyFoo")) -> inject only S.MyFoo // var Set = wire.NewSet(wire.Struct(new(S), "MyFoo")) -> inject only S.MyFoo
// var Set = wire.NewSet(wire.Struct(new(S), "*")) -> inject all fields // var Set = wire.NewSet(wire.Struct(new(S), "*")) -> inject all fields
func Struct(structType interface{}, fieldNames ...string) StructProvider { func Struct(structType interface{}, fieldNames ...string) StructProvider {
return StructProvider{} return StructProvider{}
} }
@@ -175,22 +175,22 @@ type StructFields struct{}
// //
// The following example would provide Foo and Bar using S.MyFoo and S.MyBar respectively: // The following example would provide Foo and Bar using S.MyFoo and S.MyBar respectively:
// //
// type S struct { // type S struct {
// MyFoo Foo // MyFoo Foo
// MyBar Bar // MyBar Bar
// } // }
// //
// func NewStruct() S { /* ... */ } // func NewStruct() S { /* ... */ }
// var Set = wire.NewSet(wire.FieldsOf(new(S), "MyFoo", "MyBar")) // var Set = wire.NewSet(wire.FieldsOf(new(S), "MyFoo", "MyBar"))
// //
// or // or
// //
// func NewStruct() *S { /* ... */ } // func NewStruct() *S { /* ... */ }
// var Set = wire.NewSet(wire.FieldsOf(new(*S), "MyFoo", "MyBar")) // var Set = wire.NewSet(wire.FieldsOf(new(*S), "MyFoo", "MyBar"))
// //
// If the structType argument is a pointer to a pointer to a struct, then FieldsOf // If the structType argument is a pointer to a pointer to a struct, then FieldsOf
// additionally provides a pointer to each field type (e.g., *Foo and *Bar in the // additionally provides a pointer to each field type (e.g., *Foo and *Bar in the
// example above). // example above).
func FieldsOf(structType interface{}, fieldNames ...string) StructFields { func FieldsOf(structType interface{}, fieldNames ...string) StructFields {
return StructFields{} return StructFields{}
} }