In the internal package, this expands the wire.Load function to run
the same solver as wire.Generate would on any injector function. For
completeness, I also print the injector functions in the gowire show
command.
A subsequent PR will add this as a step to Go Cloud CI.
Updates google/go-cloud#30
We should be instructing users to run stable things, and more
adventurous folks can adapt to use Go modules. I just ran the test suite
locally from a `go get` and it compiled and ran fine.
Updates google/go-cloud#78
Updates google/go-cloud#208
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.
Fixesgoogle/go-cloud#5
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.
5cfd0141dd95acd1a98a1b7f6de5b8b304077634 worked correctly with
absolute import paths, but would fail with relative import paths
(most commonly when passing "." in the default invocation of
gowire). This commit introduces test infrastructure to allow
relative import paths to be given as test inputs, along with a test
case that addresses the regression.
This was introduced in 7d83fb8532c1455d4e81b587f31d090320f5eb9f and is
surprisingly not caught by the race detector. I suspect that the testing
package makes it not a strict data race, but the result is still
undefined.
out.txts that start with "ERROR" can now include substrings to assert
exist in the error messages, one per line. This gives a very
coarse-grained way of testing for error message quality. It is not a
substitute for manual verification, but gives a "good enough" sanity
check that relevant details are reported.
Updates google/go-cloud#5
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
Updated the call sites to allow multiple errors to be returned from
the package. Load is now permitted to return partial success.
Updates google/go-cloud#5
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.
Summary of changes:
- Rewrote introduction (fixesgoogle/go-cloud#81).
- Simplified `go generate` explanation by automatically adding the
comment line to the output.
- Removed mentions of Dagger. Wire stands enough on its own now, but
Dagger's influence lives on in our minds.
- Moved best practices to bottom and removed provider set grouping
guidance.
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.
Fixesgoogle/go-cloud#29
The function had grown too long. Several related cleanups:
- Factored out the function return value logic, which had been
duplicated between providers and injectors.
- Moved code generation for different provider call types into separate
functions. This moves injector-specific state to a new type
injectorGen to keep the parameter count down.
- Since it's infeasible to keep the "shadow pass" collecting import
identifiers in sync the spread out logic, the injector code
generation is just run twice, with initial output discarded.
- Removed the zero value logic left over from Optional.
Reviewed-by: Tuo Shan <shantuo@google.com>
Previously, goose would ignore declarations in the //+build gooseinject
files that were not injectors. This meant that if you wanted to write
application-specific providers, you would need to place them in a
separate file, away from the goose injectors. This means that a typical
application would have three handwritten files: one for the abstract
business logic, one for the platform-specific providers, one for the
platform-specific injector declarations.
This change allows the two platform-specific files to be merged into
one: the //+build gooseinject file. goose will now copy these
declarations out to goose_gen.go. This requires a bit of hackery, since
the generated file may have different identifiers for the imported
packages, so goose will do some light AST rewriting to address these
cases.
(Historical note: this was the first change made externally, so also in
here are the copyright headers and other housekeeping changes.)
Reviewed-by: Tuo Shan <shantuo@google.com>
Reviewed-by: kokoro <noreply+kokoro@google.com>
To avoid making this CL too large, I did not migrate the existing goose
comments through the repository. This will be addressed in a subsequent
CL.
Reviewed-by: Tuo Shan <shantuo@google.com>
Lists provider sets in packages given on the command line, including
outputs grouped by what is needed to obtain them.
The goose package now exports the loading phase as an API.
Example output: https://paste.googleplex.com/5509965720584192
Reviewed-by: Tuo Shan <shantuo@google.com>
An interface binding instructs goose that a concrete type should be used
to satisfy a dependency on an interface type. goose could determine this
implicitly, but having an explicit directive makes the provider author's
intent clear and allows different concrete types to satisfy different
smaller interfaces.
Reviewed-by: Tuo Shan <shantuo@google.com>