This repository was archived by the owner on Aug 25, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +77
-0
lines changed
internal/wire/testdata/ProviderSetBindingMissingConcreteType Expand file tree Collapse file tree 4 files changed +77
-0
lines changed Original file line number Diff line number Diff line change 1+ // Copyright 2019 The Wire Authors
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // https://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ package main
16+
17+ import (
18+ "fmt"
19+
20+ "github.com/google/wire"
21+ )
22+
23+ func main () {
24+ fmt .Println (injectFoo ())
25+ }
26+
27+ type fooer interface {
28+ Do () string
29+ }
30+
31+ type foo struct {}
32+
33+ func (f * foo ) Do () string {
34+ return "did foo"
35+ }
36+
37+ func newFoo () * foo {
38+ return & foo {}
39+ }
40+
41+ var (
42+ setA = wire .NewSet (newFoo )
43+ // This set is invalid because it has a wire.Bind but no matching provider.
44+ // From the user guide:
45+ // Any set that includes an interface binding must also have a provider in
46+ // the same set that provides the concrete type.
47+ setB = wire .NewSet (wire .Bind (new (fooer ), new (foo )))
48+ setC = wire .NewSet (setA , setB )
49+ )
Original file line number Diff line number Diff line change 1+ // Copyright 2019 The Wire Authors
2+ //
3+ // Licensed under the Apache License, Version 2.0 (the "License");
4+ // you may not use this file except in compliance with the License.
5+ // You may obtain a copy of the License at
6+ //
7+ // https://www.apache.org/licenses/LICENSE-2.0
8+ //
9+ // Unless required by applicable law or agreed to in writing, software
10+ // distributed under the License is distributed on an "AS IS" BASIS,
11+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+ // See the License for the specific language governing permissions and
13+ // limitations under the License.
14+
15+ //+build wireinject
16+
17+ package main
18+
19+ import (
20+ "github.com/google/wire"
21+ )
22+
23+ func injectFoo () * foo {
24+ wire .Build (setC )
25+ return nil
26+ }
Original file line number Diff line number Diff line change 1+ example.com/foo
Original file line number Diff line number Diff line change 1+ example.com/foo/foo.go:x:y: no binding for *example.com/foo.foo
You can’t perform that action at this time.
0 commit comments