goose: add struct field injection
This makes options structs and application structs much simpler to inject. Reviewed-by: Tuo Shan <shantuo@google.com>
This commit is contained in:
23
internal/goose/testdata/StructOptionalField/foo/foo.go
vendored
Normal file
23
internal/goose/testdata/StructOptionalField/foo/foo.go
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fb := injectFooBar()
|
||||
fmt.Println(fb.Foo, fb.OptionalBar)
|
||||
}
|
||||
|
||||
type Foo int
|
||||
type Bar int
|
||||
|
||||
//goose:provide Set
|
||||
//goose:optional OptionalBar
|
||||
type FooBar struct {
|
||||
Foo Foo
|
||||
OptionalBar Bar
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideFoo() Foo {
|
||||
return 42
|
||||
}
|
||||
Reference in New Issue
Block a user