Commit Graph

68 Commits

Author SHA1 Message Date
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
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
Robert van Gent
8b20581338 all: update record/replay files for new version of go (#310) 2021-08-30 13:35:47 -07:00
Luca Steeb
a58291c0b8 internal/wire: use full go run command in go:generate comment (#268)
Change the go:generate command to use the full go run ... command
to ensure the version specified in the current go module is used
instead of the global binary.

Fixes #160
2021-01-25 17:55:11 -08:00
ajjensen13
4d5ab743af internal/wire: copy doc comment for generated injectors (#254)
Fixes #244
2020-06-11 08:06:02 -07:00
Ross Light
b730ad0fbf internal/wire: use set to determine which argument to use in zero-call injectors (#223)
Fixes #222
2019-11-27 15:23:39 -08:00
Ross Light
a5347c86bc internal/wire: fix crash when giving wire.Struct a bad first argument (#220) 2019-11-11 11:06:03 -08:00
Robert van Gent
c385f07c5d wire: wire.FieldsOf should not provide pointer to field type for non-pointer structs (#210) 2019-09-05 14:17:17 -07:00
Robert van Gent
2b7d1205a1 wire: FieldsOf now provides a pointer to the field type as well as the actual field type (#209) 2019-09-03 12:57:57 -07:00
shantuo
cbfca74d8a wire: support using '-' tag to prevent filling struct fields (#163) 2019-05-17 15:56:42 -07:00
Robert van Gent
fe01654174 cmd/wire: add a --header_file flag to the "gen" and "diff" commands (#175) 2019-05-16 09:56:42 -07:00
Jan Hájek
2183ee4806 internal/wire: add package name to unused provider message (#162)
Fixes #161
2019-05-02 09:57:08 -07:00
shantuo
e9e631cd71 Bind: takes a pointer for the second argument (#152) 2019-04-12 23:50:45 -07:00
shantuo
65ae46b7ea internal/wire: support specifying struct fields to inject (#147)
Added wire.Struct function and deprecate old form.

Updates #36
2019-03-28 09:00:20 -07:00
shantuo
327f42724c add FieldsOf to inject fields of a struct directly (#138) 2019-03-01 13:52:07 -08:00
Robert van Gent
d810929d49 wire: improve error for a provider set with a binding but no corresponding provider (#126)
Fixes #113
2019-02-11 08:58:30 -08:00
Robert van Gent
b869afc095 wire/tests: Add a test that defines a ProviderSet with a binding but no (#121)
corresponding concrete type. The current error message is poor and
should be improved.
2019-02-07 14:36:06 -08:00
Ross Light
9a7ae3ba6b internal/wire/testdata/PkgImport: really add the duplicated import (#105) 2019-01-07 14:57:50 -08:00
Ross Light
5b99fcb30b internal/wire/testdata/PkgImport: add back duplicate import (#103)
This got removed as part of my gofmt run on #101.
2019-01-07 14:15:33 -08:00
Kumbirai Tanekha
f285c073b5 internal/wire: copy over anonymous imports (#101)
Adds Kumbirai Tanekha to A+C.

Fixes #94
2019-01-07 09:04:35 -08:00
shantuo
4243b011bd internal/wire: factor out common code in solve (#98)
- Fixed a bug when a interface is bind to a value wire would fail to record it is used.
- Also rename ProvidedType.ConcreteType to Type since it doesn't necessarily returns a concrete type.

Fixes #72
2018-12-14 12:56:01 -08:00
shantuo
ef9bb67152 Support variadic provider and injector functions (#91)
Fixes #61
2018-12-03 08:30:42 -08:00
Ross Light
90ac48ab7d Remove more references to Go Cloud (#88) 2018-11-30 10:08:58 -08:00
Ross Light
1a5e046395 Remove more references to Go Cloud (#75) 2018-11-28 12:51:41 -08:00
Robert van Gent
925a11ad0d wire: add a test for using a function argument as a provider (google/go-cloud#724) 2018-11-28 11:02:13 -08:00
Robert van Gent
6ea381b3fe wire: give wire.Bind access to the arguments to the injector function (google/go-cloud#715) 2018-11-28 11:02:13 -08:00
Robert van Gent
67170e739d wire/tests: add a test for wire.Bind on an injector arg (google/go-cloud#708) 2018-11-28 11:02:13 -08:00
Robert van Gent
ebb381989a wire/tests: add a test for multiple args of the same type to an injector function (google/go-cloud#706) 2018-11-28 11:02:13 -08:00
Ross Light
30574010a0 Update import path and mirror project docs 2018-11-13 13:16:46 -08:00
Robert van Gent
ded9eb899b wire: remove trailing CR at end of error about cycles (google/go-cloud#662) 2018-11-13 13:16:46 -08:00
Ross Light
282105c273 wire: use go/packages for analysis (google/go-cloud#623)
Unfortunately, this does come with a ~4x slowdown to Wire, as it is
now pulling source for all transitively depended packages, but not
trimming comments or function bodies. This is due to limitations with
the ParseFile callback in go/packages.

This comes with a single semantic change: when performing analysis, Wire
will now evaluate everything with the wireinject build tag. I updated
the build tags tests accordingly. Prior to this PR, only the packages
directly named by the package patterns would be evaluated with the
wireinject build tag. Dependencies would not have the wireinject build
tag applied. There isn't a way to selectively apply build tags in go/packages,
and there isn't a clear benefit to applying it selectively. Being consistent with
other Go tooling provides greater benefit.

I deleted the vendoring test, as non-top-level vendoring
becomes obsolete with modules.

go/packages now parses comments by default, so now the generated code
includes comments for non-injector declarations.

Fixes google/go-cloud#78
2018-11-13 13:16:46 -08:00
Ross Light
64470a2452 wire/internal/wire: use on-disk GOPATH in generate tests (google/go-cloud#616)
The primary motivation is to permit a move to using go/packages instead
of go/loader. go/packages runs exclusively by shelling out to the go
tool, which precludes use of the in-memory "magic" GOPATH being used
up to this point.

This has a secondary effect of removing a lot of code to support "magic"
GOPATH from the test infrastructure. This is on the whole good, but
necessitated a change in the error scrubbing: since the filenames are
no longer fixed, error scrubbing also must remove the leading
$GOPATH/src lines.

Another related change: since all callers of Generate needed to know the
package path in order to write out wire_gen.go (necessitating a
find-only import search) and Generate already has this information,
Generate now returns this information to the caller. This should further
reduce callers' coupling to Wire's load internals. It also eliminates
code duplication.

This should hopefully shake out any difference in path separators for
running on Windows, but I have not tested that yet.

Updates google/go-cloud#78
Updates google/go-cloud#323
2018-11-13 13:16:46 -08:00
Robert van Gent
ab113bf8d1 wire: allow wire.Value to use values with no parent (i.e., struct fields) (google/go-cloud#596) 2018-11-13 13:16:46 -08:00
Robert van Gent
b7c4e8db66 wire: use multiline errors instead of one single line for errors with traces (google/go-cloud#571) 2018-11-13 13:16:46 -08:00
Robert van Gent
97e5c83e18 wire/test: support multi-line errors and -record mode in tests (google/go-cloud#550) 2018-11-13 13:16:46 -08:00
Robert van Gent
a8825fef58 wire: add info from the dependency graph when a type is not provided 2018-11-13 13:16:46 -08:00
Robert van Gent
b1fd26c92a wire: improve error message for provider set conflicts (google/go-cloud#500) 2018-11-13 13:16:46 -08:00
Robert van Gent
be8ecba636 wire: fix error messages for Bind and InterfaceValue when the arg doesn't implement the interface (google/go-cloud#491)
Fixes google/go-cloud#490
2018-11-13 13:16:46 -08:00
Robert van Gent
2c50843322 wire: add an example and document how to use wire with mocks (google/go-cloud#488) 2018-11-13 13:16:46 -08:00
Robert van Gent
ec7cb36215 wire: report an error if a func with wire.Build in it is an invalid injector (google/go-cloud#487) 2018-11-13 13:16:46 -08:00
Robert van Gent
3bc7933406 wire: avoid making variable names that are Go reserved keywords (google/go-cloud#486) 2018-11-13 13:16:46 -08:00
Robert van Gent
26169ca726 wire/test: add tests for missing error and cleanup func in injector (google/go-cloud#484) 2018-11-13 13:16:46 -08:00
shantuo
fbcb6a82cb wire: make Vendor test work with Go module (google/go-cloud#469) 2018-11-13 13:16:46 -08:00
Robert van Gent
a8c7c0b8e1 wire: omit the local package identifier if it matches the package name (google/go-cloud#385)
Fixes google/go-cloud#424
2018-11-13 13:16:46 -08:00
Robert van Gent
c999a4d1b5 wire: use package names to disambiguate variables (google/go-cloud#386) 2018-11-13 13:16:46 -08:00
Robert van Gent
fab79bd5bd wire: add a test that fails due to wire.Value on a value from function scope (google/go-cloud#405)
Fixes google/go-cloud#378
2018-11-13 13:16:46 -08:00
Robert van Gent
46248162d7 wire: add a testcase with multiple similar packages (google/go-cloud#387)
This is based on the description in google/go-cloud#372. It will be useful if we add wire.FieldsOf, and also for the disambiguation-using-package.

Updates google/go-cloud#372
Updates google/go-cloud#386
2018-11-13 13:16:46 -08:00
Robert van Gent
e93f33129e wire: update Provider.Out to be a slice of provided types, and keep track of the provided concrete type in ProviderSet.providerMap (google/go-cloud#332)
Update Provider.Out to be a slice of provided types, and keep track
of the provided concrete type in ProviderSet.providerMap, to more
clearly model-named struct providers (which provide both the struct
type and a pointer to the struct type).

Fixes google/go-cloud#325.
2018-11-13 13:16:46 -08:00
shantuo
86725a2b3f wire: make tests work with Go modules (google/go-cloud#331)
Generates go.mod files for test cases to support Go modules.
2018-11-13 13:16:46 -08:00