Commit Graph

29 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 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
Robert van Gent
c1be6ec0d8 travis: refresh runtests.sh and Travis config (#174) 2019-05-14 11:31:53 -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
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
Ross Light
3b0186f7df internal/wire: move field name into ProviderInput (#104)
Avoids having parallel arrays for conceptually related data.
2019-01-23 11:34:39 -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
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
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
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
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
Ross Light
eedae3d8d0 all: change copyright notice to The Go Cloud Authors (google/go-cloud#306)
Added AUTHORS+CONTRIBUTORS files with the contributors already present
from the Git log.

Fixes google/go-cloud#225
2018-11-13 13:16:46 -08:00
Robert van Gent
3a3760180d wire: fill in ProviderSet.VarName when the set is a package variable (google/go-cloud#279)
Rename ProviderSet.Name to ProviderSet.VarName.

Fixes google/go-cloud#277
2018-11-13 13:16:46 -08:00
Robert van Gent
85deb53791 wire: Build now returns an error if it has any unused arguments (google/go-cloud#268)
Fixes google/go-cloud#164
2018-11-13 13:16:46 -08:00
Robert van Gent
b348a78000 wire: use providerMap.Iterate instead of providerMap.Keys() + At() (google/go-cloud#265) 2018-11-13 13:16:46 -08:00
Ross Light
765b0228ac wire: don't fail at first error (google/go-cloud#204)
This changes both Generate and Load to try to advance as far as possible
while collecting errors. A small helper type, errorCollector, is used to
make control flow easier to read.

Fixes google/go-cloud#5
2018-11-13 13:16:45 -08:00
Ross Light
a2540bae2a wire: update internal functions to return []error (google/go-cloud#197)
This represents no functional change, it purely changes the signature
used for functions that can possibly return multiple errors. A
follow-up commit will change the control flow to proceed in the face
of errors.
2018-11-13 13:16:45 -08:00
Ross Light
2eb9d5ea1f wire: make solver iterative instead of recursive (google/go-cloud#137)
Primary reason is to make it easier to allow the process to continue and
collect errors. This has the side-effect of allowing larger depth graphs
since the solver no longer pushes Go stack frames.

Updates google/go-cloud#5
2018-11-13 13:16:45 -08:00
Ross Light
366207371e wire: detect cycles incrementally (google/go-cloud#102)
Idea originally mentioned in google/go-cloud#29. This means that any provider set
loaded must not have cycles, which is stricter than before. The cycle
error message now gives full detail on what caused the cycle.
2018-11-13 13:16:45 -08:00
Ross Light
b12449f9e3 wire: build provider map incrementally (google/go-cloud#96)
One small breaking change: a provider set can no longer include an
interface binding to a concrete type that is not being provided
(directly or indirectly) by the provider set. I can't imagine a
reasonable use case for the previous behavior, so this likely will
catch more errors

In terms of operation, binding conflict error messages will now give
much more specific line numbers, since they will be reported closer to
where the problem occurred.

Now that provider sets gather this information, it can be exposed in
the package API. gowire now uses this information instead of
trying to build it itself.

Fixes google/go-cloud#29
2018-11-13 13:16:45 -08:00
Ross Light
6345348d86 wire: rename from Goose (google/go-cloud#59)
Rename Goose to wire, making it more obvious what the package does, and look more like the stdlib.

Fixes google/go-cloud#8
2018-11-13 13:16:45 -08:00