wire: add info from the dependency graph when a type is not provided
This commit is contained in:
committed by
Ross Light
parent
b84ad6154f
commit
a8825fef58
@@ -17,7 +17,9 @@ package main
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectBaz())
|
||||
fmt.Println(injectMissingOutputType())
|
||||
fmt.Println(injectMultipleMissingTypes())
|
||||
fmt.Println(injectMissingRecursiveType())
|
||||
}
|
||||
|
||||
type Foo int
|
||||
@@ -27,3 +29,19 @@ type Baz int
|
||||
func provideBaz(foo Foo, bar Bar) Baz {
|
||||
return 0
|
||||
}
|
||||
|
||||
type Zip int
|
||||
type Zap int
|
||||
type Zop int
|
||||
|
||||
func provideZip(foo Foo) Zip {
|
||||
return 0
|
||||
}
|
||||
|
||||
func provideZap(zip Zip) Zap {
|
||||
return 0
|
||||
}
|
||||
|
||||
func provideZop(zap Zap) Zop {
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -20,7 +20,23 @@ import (
|
||||
"github.com/google/go-cloud/wire"
|
||||
)
|
||||
|
||||
func injectBaz() Baz {
|
||||
func injectMissingOutputType() Foo {
|
||||
// Error: no provider for Foo.
|
||||
wire.Build()
|
||||
return Foo(0)
|
||||
}
|
||||
|
||||
func injectMultipleMissingTypes() Baz {
|
||||
// Error: provideBaz needs Foo and Bar, both missing.
|
||||
wire.Build(provideBaz)
|
||||
return Baz(0)
|
||||
}
|
||||
|
||||
func injectMissingRecursiveType() Zop {
|
||||
// Error:
|
||||
// Zop -> Zap -> Zip -> Foo
|
||||
// provideZop needs Zap, provideZap needs Zip, provideZip needs Foo,
|
||||
// which is missing.
|
||||
wire.Build(provideZop, provideZap, provideZip)
|
||||
return Zop(0)
|
||||
}
|
||||
|
||||
@@ -1,2 +1,4 @@
|
||||
no provider found for example.com/foo.Foo
|
||||
no provider found for example.com/foo.Bar
|
||||
inject injectMissingOutputType: no provider found for example.com/foo.Foo, output of injector
|
||||
inject injectMultipleMissingTypes: no provider found for example.com/foo.Foo, needed by example.com/foo.Baz in provider "provideBaz" (/wire_gopath/src/example.com/foo/foo.go:29:6)
|
||||
inject injectMultipleMissingTypes: no provider found for example.com/foo.Bar, needed by example.com/foo.Baz in provider "provideBaz" (/wire_gopath/src/example.com/foo/foo.go:29:6)
|
||||
inject injectMissingRecursiveType: no provider found for example.com/foo.Foo, needed by example.com/foo.Zip in provider "provideZip" (/wire_gopath/src/example.com/foo/foo.go:37:6), needed by example.com/foo.Zap in provider "provideZap" (/wire_gopath/src/example.com/foo/foo.go:41:6), needed by example.com/foo.Zop in provider "provideZop" (/wire_gopath/src/example.com/foo/foo.go:45:6)
|
||||
|
||||
Reference in New Issue
Block a user