goose: remove optional directive
This introduces some short-term pain in practice, but I aim to fix that with the goose.Value directive. Reviewed-by: Tuo Shan <shantuo@google.com>
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectBar())
|
||||
}
|
||||
|
||||
type foo int
|
||||
type bar int
|
||||
|
||||
//goose:provide
|
||||
//goose:optional f
|
||||
func provideBar(f foo) bar {
|
||||
return bar(f)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
//+build gooseinject
|
||||
|
||||
package main
|
||||
|
||||
//goose:use provideBar
|
||||
|
||||
func injectBar() bar
|
||||
@@ -1 +0,0 @@
|
||||
0
|
||||
1
internal/goose/testdata/OptionalMissing/pkg
vendored
1
internal/goose/testdata/OptionalMissing/pkg
vendored
@@ -1 +0,0 @@
|
||||
foo
|
||||
@@ -1,16 +0,0 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectBar(42))
|
||||
}
|
||||
|
||||
type foo int
|
||||
type bar int
|
||||
|
||||
//goose:provide
|
||||
//goose:optional f
|
||||
func provideBar(f foo) bar {
|
||||
return bar(f)
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
//+build gooseinject
|
||||
|
||||
package main
|
||||
|
||||
//goose:use provideBar
|
||||
|
||||
func injectBar(foo) bar
|
||||
@@ -1 +0,0 @@
|
||||
42
|
||||
1
internal/goose/testdata/OptionalPresent/pkg
vendored
1
internal/goose/testdata/OptionalPresent/pkg
vendored
@@ -1 +0,0 @@
|
||||
foo
|
||||
@@ -1,23 +0,0 @@
|
||||
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
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
//+build gooseinject
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
|
||||
func injectFooBar() FooBar
|
||||
@@ -1 +0,0 @@
|
||||
42 0
|
||||
@@ -1 +0,0 @@
|
||||
foo
|
||||
@@ -1,28 +0,0 @@
|
||||
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
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
//+build gooseinject
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
|
||||
func injectFooBar() FooBar
|
||||
@@ -1 +0,0 @@
|
||||
41 1
|
||||
@@ -1 +0,0 @@
|
||||
foo
|
||||
Reference in New Issue
Block a user