goose: use marker functions instead of comments
To avoid making this CL too large, I did not migrate the existing goose comments through the repository. This will be addressed in a subsequent CL. Reviewed-by: Tuo Shan <shantuo@google.com>
This commit is contained in:
12
internal/goose/testdata/Chain/foo/foo.go
vendored
12
internal/goose/testdata/Chain/foo/foo.go
vendored
@@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectFooBar())
|
||||
@@ -9,12 +13,14 @@ func main() {
|
||||
type Foo int
|
||||
type FooBar int
|
||||
|
||||
//goose:provide Set
|
||||
var Set = goose.NewSet(
|
||||
provideFoo,
|
||||
provideFooBar)
|
||||
|
||||
func provideFoo() Foo {
|
||||
return 41
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideFooBar(foo Foo) FooBar {
|
||||
return FooBar(foo) + 1
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFooBar() FooBar
|
||||
func injectFooBar() FooBar {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
6
internal/goose/testdata/Cleanup/foo/foo.go
vendored
6
internal/goose/testdata/Cleanup/foo/foo.go
vendored
@@ -1,6 +1,8 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
bar, cleanup := injectBar()
|
||||
@@ -12,14 +14,12 @@ func main() {
|
||||
type Foo int
|
||||
type Bar int
|
||||
|
||||
//goose:provide Foo
|
||||
func provideFoo() (*Foo, func()) {
|
||||
foo := new(Foo)
|
||||
*foo = 42
|
||||
return foo, func() { *foo = 0 }
|
||||
}
|
||||
|
||||
//goose:provide Bar
|
||||
func provideBar(foo *Foo) (*Bar, func()) {
|
||||
bar := new(Bar)
|
||||
*bar = 77
|
||||
|
||||
9
internal/goose/testdata/Cleanup/foo/goose.go
vendored
9
internal/goose/testdata/Cleanup/foo/goose.go
vendored
@@ -2,7 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Foo
|
||||
//goose:use Bar
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectBar() (*Bar, func())
|
||||
func injectBar() (*Bar, func()) {
|
||||
panic(goose.Use(provideFoo, provideBar))
|
||||
}
|
||||
|
||||
11
internal/goose/testdata/EmptyVar/foo/foo.go
vendored
Normal file
11
internal/goose/testdata/EmptyVar/foo/foo.go
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectedMessage())
|
||||
}
|
||||
|
||||
var myFakeSet struct{}
|
||||
11
internal/goose/testdata/EmptyVar/foo/goose.go
vendored
Normal file
11
internal/goose/testdata/EmptyVar/foo/goose.go
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
//+build gooseinject
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectedMessage() string {
|
||||
panic(goose.Use(myFakeSet))
|
||||
}
|
||||
@@ -3,7 +3,8 @@ package main
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
_ "foo"
|
||||
"codename/goose"
|
||||
"foo"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -16,11 +17,12 @@ func (b *Bar) Foo() string {
|
||||
return string(*b)
|
||||
}
|
||||
|
||||
//goose:provide
|
||||
func provideBar() *Bar {
|
||||
b := new(Bar)
|
||||
*b = "Hello, World!"
|
||||
return b
|
||||
}
|
||||
|
||||
//goose:bind provideBar "foo".Fooer *Bar
|
||||
var Set = goose.NewSet(
|
||||
provideBar,
|
||||
goose.Bind(foo.Fooer(nil), (*Bar)(nil)))
|
||||
|
||||
@@ -2,8 +2,11 @@
|
||||
|
||||
package main
|
||||
|
||||
import "foo"
|
||||
import (
|
||||
"codename/goose"
|
||||
"foo"
|
||||
)
|
||||
|
||||
//goose:use provideBar
|
||||
|
||||
func injectFooer() foo.Fooer
|
||||
func injectFooer() foo.Fooer {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
12
internal/goose/testdata/InjectInput/foo/foo.go
vendored
12
internal/goose/testdata/InjectInput/foo/foo.go
vendored
@@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectFooBar(40))
|
||||
@@ -10,12 +14,14 @@ type Foo int
|
||||
type Bar int
|
||||
type FooBar int
|
||||
|
||||
//goose:provide Set
|
||||
var Set = goose.NewSet(
|
||||
provideBar,
|
||||
provideFooBar)
|
||||
|
||||
func provideBar() Bar {
|
||||
return 2
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideFooBar(foo Foo, bar Bar) FooBar {
|
||||
return FooBar(foo) + FooBar(bar)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFooBar(foo Foo) FooBar
|
||||
func injectFooBar(foo Foo) FooBar {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
// I'm on the fence as to whether this should be an error (versus an
|
||||
@@ -12,12 +16,14 @@ func main() {
|
||||
type Foo int
|
||||
type Bar int
|
||||
|
||||
//goose:provide Set
|
||||
var Set = goose.NewSet(
|
||||
provideFoo,
|
||||
provideBar)
|
||||
|
||||
func provideFoo() Foo {
|
||||
return -888
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideBar(foo Foo) Bar {
|
||||
return 2
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectBar(foo Foo) Bar
|
||||
func injectBar(foo Foo) Bar {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectFooer().Foo())
|
||||
@@ -16,11 +20,12 @@ func (b *Bar) Foo() string {
|
||||
return string(*b)
|
||||
}
|
||||
|
||||
//goose:provide
|
||||
func provideBar() *Bar {
|
||||
b := new(Bar)
|
||||
*b = "Hello, World!"
|
||||
return b
|
||||
}
|
||||
|
||||
//goose:bind provideBar Fooer *Bar
|
||||
var Set = goose.NewSet(
|
||||
provideBar,
|
||||
goose.Bind(Fooer(nil), (*Bar)(nil)))
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use provideBar
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFooer() Fooer
|
||||
func injectFooer() Fooer {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
@@ -28,8 +28,6 @@ func (b *Bar) Foo() string {
|
||||
return string(*b)
|
||||
}
|
||||
|
||||
//goose:provide
|
||||
//goose:bind provideBar Fooer *Bar
|
||||
func provideBar() *Bar {
|
||||
mu.Lock()
|
||||
provideBarCalls++
|
||||
@@ -44,7 +42,6 @@ var (
|
||||
provideBarCalls int
|
||||
)
|
||||
|
||||
//goose:provide
|
||||
func provideFooBar(fooer Fooer, bar *Bar) FooBar {
|
||||
return FooBar{fooer, bar}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,13 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use provideBar
|
||||
//goose:use provideFooBar
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFooBar() FooBar
|
||||
func injectFooBar() FooBar {
|
||||
panic(goose.Use(
|
||||
provideBar,
|
||||
provideFooBar,
|
||||
goose.Bind(Fooer(nil), (*Bar)(nil))))
|
||||
}
|
||||
|
||||
14
internal/goose/testdata/MissingUse/foo/foo.go
vendored
14
internal/goose/testdata/MissingUse/foo/foo.go
vendored
@@ -1,14 +0,0 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectedMessage())
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
|
||||
// provideMessage provides a friendly user greeting.
|
||||
func provideMessage() string {
|
||||
return "Hello, World!"
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
//+build gooseinject
|
||||
|
||||
package main
|
||||
|
||||
func injectedMessage() string
|
||||
22
internal/goose/testdata/MultiImport/foo/foo.go
vendored
22
internal/goose/testdata/MultiImport/foo/foo.go
vendored
@@ -1,22 +0,0 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectFooBar())
|
||||
}
|
||||
|
||||
type Foo int
|
||||
type FooBar int
|
||||
|
||||
//goose:provide Foo
|
||||
func provideFoo() Foo {
|
||||
return 41
|
||||
}
|
||||
|
||||
//goose:provide FooBar
|
||||
func provideFooBar(foo Foo) FooBar {
|
||||
return FooBar(foo) + 1
|
||||
}
|
||||
|
||||
//goose:import Set Foo FooBar
|
||||
@@ -1,7 +0,0 @@
|
||||
//+build gooseinject
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
|
||||
func injectFooBar() FooBar
|
||||
1
internal/goose/testdata/MultiImport/out.txt
vendored
1
internal/goose/testdata/MultiImport/out.txt
vendored
@@ -1 +0,0 @@
|
||||
42
|
||||
1
internal/goose/testdata/MultiImport/pkg
vendored
1
internal/goose/testdata/MultiImport/pkg
vendored
@@ -1 +0,0 @@
|
||||
foo
|
||||
20
internal/goose/testdata/MultiUse/foo/foo.go
vendored
20
internal/goose/testdata/MultiUse/foo/foo.go
vendored
@@ -1,20 +0,0 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectFooBar())
|
||||
}
|
||||
|
||||
type Foo int
|
||||
type FooBar int
|
||||
|
||||
//goose:provide Foo
|
||||
func provideFoo() Foo {
|
||||
return 41
|
||||
}
|
||||
|
||||
//goose:provide FooBar
|
||||
func provideFooBar(foo Foo) FooBar {
|
||||
return FooBar(foo) + 1
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
//+build gooseinject
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Foo FooBar
|
||||
|
||||
func injectFooBar() FooBar
|
||||
1
internal/goose/testdata/MultiUse/out.txt
vendored
1
internal/goose/testdata/MultiUse/out.txt
vendored
@@ -1 +0,0 @@
|
||||
42
|
||||
1
internal/goose/testdata/MultiUse/pkg
vendored
1
internal/goose/testdata/MultiUse/pkg
vendored
@@ -1 +0,0 @@
|
||||
foo
|
||||
@@ -17,8 +17,6 @@ func main() {
|
||||
fmt.Println(c)
|
||||
}
|
||||
|
||||
//goose:provide
|
||||
|
||||
func provide(ctx stdcontext.Context) (context, error) {
|
||||
return context{}, nil
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ package main
|
||||
|
||||
import (
|
||||
stdcontext "context"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
//goose:use provide
|
||||
|
||||
func inject(context stdcontext.Context, err struct{}) (context, error)
|
||||
func inject(context stdcontext.Context, err struct{}) (context, error) {
|
||||
panic(goose.Use(provide))
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ func main() {
|
||||
fmt.Println(injectedMessage())
|
||||
}
|
||||
|
||||
//goose:provide
|
||||
|
||||
// provideMessage provides a friendly user greeting.
|
||||
func provideMessage() string {
|
||||
return "Hello, World!"
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use provideMessage
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectedMessage() string
|
||||
func injectedMessage() string {
|
||||
panic(goose.Use(provideMessage))
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ func (b Bar) Foo() string {
|
||||
return string(b)
|
||||
}
|
||||
|
||||
//goose:provide
|
||||
func provideBar() Bar {
|
||||
return "Hello, World!"
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use provideBar
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFooer() Fooer
|
||||
func injectFooer() Fooer {
|
||||
panic(goose.Use(provideBar))
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ func main() {
|
||||
fmt.Println(c)
|
||||
}
|
||||
|
||||
//goose:provide
|
||||
|
||||
func provide(ctx stdcontext.Context) (context, error) {
|
||||
return context{}, nil
|
||||
}
|
||||
|
||||
@@ -4,11 +4,13 @@ package main
|
||||
|
||||
import (
|
||||
stdcontext "context"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
// The notable characteristic of this test is that there are no
|
||||
// parameter names on the inject stub.
|
||||
|
||||
//goose:use provide
|
||||
|
||||
func inject(stdcontext.Context, struct{}) (context, error)
|
||||
func inject(stdcontext.Context, struct{}) (context, error) {
|
||||
panic(goose.Use(provide))
|
||||
}
|
||||
|
||||
@@ -25,14 +25,12 @@ type Foo int
|
||||
type Bar int
|
||||
type Baz int
|
||||
|
||||
//goose:provide Foo
|
||||
func provideFoo() (*Foo, func()) {
|
||||
foo := new(Foo)
|
||||
*foo = 42
|
||||
return foo, func() { *foo = 0; cleanedFoo = true }
|
||||
}
|
||||
|
||||
//goose:provide Bar
|
||||
func provideBar(foo *Foo) (*Bar, func(), error) {
|
||||
bar := new(Bar)
|
||||
*bar = 77
|
||||
@@ -45,7 +43,6 @@ func provideBar(foo *Foo) (*Bar, func(), error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
//goose:provide Baz
|
||||
func provideBaz(bar *Bar) (Baz, error) {
|
||||
return 0, errors.New("bork!")
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Foo
|
||||
//goose:use Bar
|
||||
//goose:use Baz
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectBaz() (Baz, func(), error)
|
||||
func injectBaz() (Baz, func(), error) {
|
||||
panic(goose.Use(provideFoo, provideBar, provideBaz))
|
||||
}
|
||||
|
||||
1
internal/goose/testdata/PkgImport/bar/bar.go
vendored
1
internal/goose/testdata/PkgImport/bar/bar.go
vendored
@@ -2,7 +2,6 @@ package bar
|
||||
|
||||
type Bar int
|
||||
|
||||
//goose:provide Bar
|
||||
func ProvideBar() Bar {
|
||||
return 1
|
||||
}
|
||||
|
||||
10
internal/goose/testdata/PkgImport/foo/foo.go
vendored
10
internal/goose/testdata/PkgImport/foo/foo.go
vendored
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"bar"
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -13,14 +14,15 @@ func main() {
|
||||
type Foo int
|
||||
type FooBar int
|
||||
|
||||
//goose:provide Set
|
||||
var Set = goose.NewSet(
|
||||
provideFoo,
|
||||
bar.ProvideBar,
|
||||
provideFooBar)
|
||||
|
||||
func provideFoo() Foo {
|
||||
return 41
|
||||
}
|
||||
|
||||
//goose:import Set "bar".Bar
|
||||
|
||||
//goose:provide Set
|
||||
func provideFooBar(foo Foo, barVal bar.Bar) FooBar {
|
||||
return FooBar(foo) + FooBar(barVal)
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFooBar() FooBar
|
||||
func injectFooBar() FooBar {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
13
internal/goose/testdata/ReturnError/foo/foo.go
vendored
13
internal/goose/testdata/ReturnError/foo/foo.go
vendored
@@ -1,8 +1,12 @@
|
||||
package main
|
||||
|
||||
import "errors"
|
||||
import "fmt"
|
||||
import "strings"
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
foo, err := injectFoo()
|
||||
@@ -16,7 +20,8 @@ func main() {
|
||||
|
||||
type Foo int
|
||||
|
||||
//goose:provide Set
|
||||
func provideFoo() (Foo, error) {
|
||||
return 42, errors.New("there is no Foo")
|
||||
}
|
||||
|
||||
var Set = goose.NewSet(provideFoo)
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFoo() (Foo, error)
|
||||
func injectFoo() (Foo, error) {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
14
internal/goose/testdata/Struct/foo/foo.go
vendored
14
internal/goose/testdata/Struct/foo/foo.go
vendored
@@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fb := injectFooBar()
|
||||
@@ -10,18 +14,20 @@ func main() {
|
||||
type Foo int
|
||||
type Bar int
|
||||
|
||||
//goose:provide Set
|
||||
type FooBar struct {
|
||||
Foo Foo
|
||||
Bar Bar
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideFoo() Foo {
|
||||
return 41
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideBar() Bar {
|
||||
return 1
|
||||
}
|
||||
|
||||
var Set = goose.NewSet(
|
||||
FooBar{},
|
||||
provideFoo,
|
||||
provideBar)
|
||||
|
||||
8
internal/goose/testdata/Struct/foo/goose.go
vendored
8
internal/goose/testdata/Struct/foo/goose.go
vendored
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFooBar() FooBar
|
||||
func injectFooBar() FooBar {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
14
internal/goose/testdata/StructPointer/foo/foo.go
vendored
14
internal/goose/testdata/StructPointer/foo/foo.go
vendored
@@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fb := injectFooBar()
|
||||
@@ -10,18 +14,20 @@ func main() {
|
||||
type Foo int
|
||||
type Bar int
|
||||
|
||||
//goose:provide Set
|
||||
type FooBar struct {
|
||||
Foo Foo
|
||||
Bar Bar
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideFoo() Foo {
|
||||
return 41
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideBar() Bar {
|
||||
return 1
|
||||
}
|
||||
|
||||
var Set = goose.NewSet(
|
||||
FooBar{},
|
||||
provideFoo,
|
||||
provideBar)
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFooBar() *FooBar
|
||||
func injectFooBar() *FooBar {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
14
internal/goose/testdata/TwoDeps/foo/foo.go
vendored
14
internal/goose/testdata/TwoDeps/foo/foo.go
vendored
@@ -1,6 +1,10 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(injectFooBar())
|
||||
@@ -10,17 +14,19 @@ type Foo int
|
||||
type Bar int
|
||||
type FooBar int
|
||||
|
||||
//goose:provide Set
|
||||
func provideFoo() Foo {
|
||||
return 40
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideBar() Bar {
|
||||
return 2
|
||||
}
|
||||
|
||||
//goose:provide Set
|
||||
func provideFooBar(foo Foo, bar Bar) FooBar {
|
||||
return FooBar(foo) + FooBar(bar)
|
||||
}
|
||||
|
||||
var Set = goose.NewSet(
|
||||
provideFoo,
|
||||
provideBar,
|
||||
provideFooBar)
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
package main
|
||||
|
||||
//goose:use Set
|
||||
import (
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
func injectFooBar() FooBar
|
||||
func injectFooBar() FooBar {
|
||||
panic(goose.Use(Set))
|
||||
}
|
||||
|
||||
9
internal/goose/testdata/Vendor/foo/goose.go
vendored
9
internal/goose/testdata/Vendor/foo/goose.go
vendored
@@ -3,9 +3,10 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
_ "bar"
|
||||
"bar"
|
||||
"codename/goose"
|
||||
)
|
||||
|
||||
//goose:use "bar".Message
|
||||
|
||||
func injectedMessage() string
|
||||
func injectedMessage() string {
|
||||
panic(goose.Use(bar.ProvideMessage))
|
||||
}
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
// Package bar is the vendored copy of bar which contains the real provider.
|
||||
package bar
|
||||
|
||||
//goose:provide Message
|
||||
|
||||
// ProvideMessage provides a friendly user greeting.
|
||||
func ProvideMessage() string {
|
||||
return "Hello, World!"
|
||||
|
||||
Reference in New Issue
Block a user