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:
Ross Light
2018-04-03 21:11:53 -07:00
parent ccf63fec5d
commit 2044e2213b
20 changed files with 413 additions and 61 deletions

View 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
}