File tree 5 files changed +80
-2
lines changed
5 files changed +80
-2
lines changed Original file line number Diff line number Diff line change 18
18
package main
19
19
20
20
import (
21
- // "strings"
22
-
23
21
"github.com/google/wire"
24
22
)
25
23
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 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
+ "github.com/google/wire"
19
+ )
20
+
21
+ type context struct {}
22
+
23
+ func main () {}
24
+
25
+ type FooOptions struct {}
26
+ type Foo string
27
+ type Bar struct {}
28
+ type BarName string
29
+
30
+ func provideFooOptions () * FooOptions {
31
+ return & FooOptions {}
32
+ }
33
+
34
+ func provideFoo (* FooOptions ) Foo {
35
+ return Foo ("foo" )
36
+ }
37
+
38
+ func provideBar (Foo , BarName ) * Bar {
39
+ return & Bar {}
40
+ }
41
+
42
+ var Set = wire .NewSet (
43
+ provideFooOptions ,
44
+ provideFoo ,
45
+ provideBar ,
46
+ )
Original file line number Diff line number Diff line change
1
+ // Copyright 2018 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
+ //go:build wireinject
16
+ // +build wireinject
17
+
18
+ package main
19
+
20
+ import (
21
+ "github.com/google/wire"
22
+ )
23
+
24
+ func injectNonSet (opts * FooOptions ) Foo {
25
+ panic (wire .Build (wire .Subtract (provideFoo , new (FooOptions ))))
26
+ }
27
+
28
+ func injectNonPointer (name BarName , opts * FooOptions ) * Bar {
29
+ panic (wire .Build (wire .Subtract (Set , FooOptions {})))
30
+ }
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/wire.go:x:y: first argument to Subtract must be a Set
2
+
3
+ example.com/foo/wire.go:x:y: argument to Subtract must be a pointer
You can’t perform that action at this time.
0 commit comments