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:
28
internal/goose/testdata/StructOptionalFieldPresent/foo/foo.go
vendored
Normal file
28
internal/goose/testdata/StructOptionalFieldPresent/foo/foo.go
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fb := injectFooBar()
|
||||
fmt.Println(fb.Foo, fb.Bar)
|
||||
}
|
||||
|
||||
type Foo int
|
||||
type Bar int
|
||||
|
||||
//goose:provide Set
|
||||
//goose:optional Bar
|
||||
type FooBar struct {
|
||||
Foo Foo
|
||||
Bar Bar
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideFoo() Foo {
|
||||
return 41
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideBar() Bar {
|
||||
return 1
|
||||
}
|
||||
Reference in New Issue
Block a user