@@ -15,7 +15,7 @@ import (
15
15
)
16
16
17
17
func Example_helloWorld () {
18
- kod .Run (context .Background (), func (ctx context.Context , t * helloworld.App ) error {
18
+ kod .Run (context .Background (), func (ctx context.Context , app * helloworld.App ) error {
19
19
fmt .Println ("Hello, World!" )
20
20
return nil
21
21
})
@@ -26,8 +26,8 @@ func Example_helloWorld() {
26
26
}
27
27
28
28
func Example_callComponent () {
29
- kod .Run (context .Background (), func (ctx context.Context , t * helloworld.App ) error {
30
- t .HelloWorld .Get ().SayHello (ctx )
29
+ kod .Run (context .Background (), func (ctx context.Context , app * helloworld.App ) error {
30
+ app .HelloWorld .Get ().SayHello (ctx )
31
31
return nil
32
32
})
33
33
// Output:
@@ -40,8 +40,8 @@ func Example_mockComponent() {
40
40
mock := helloworld .NewMockHelloWorld (gomock .NewController (nil ))
41
41
mock .EXPECT ().SayHello (gomock .Any ()).Return ()
42
42
43
- kod .Run (context .Background (), func (ctx context.Context , t * helloworld.App ) error {
44
- t .HelloWorld .Get ().SayHello (ctx )
43
+ kod .Run (context .Background (), func (ctx context.Context , app * helloworld.App ) error {
44
+ app .HelloWorld .Get ().SayHello (ctx )
45
45
fmt .Println ("Nothing printed from mock" )
46
46
return nil
47
47
}, kod .WithFakes (kod.Fake [helloworld.HelloWorld ](mock )))
@@ -50,9 +50,9 @@ func Example_mockComponent() {
50
50
}
51
51
52
52
func Example_config () {
53
- kod .Run (context .Background (), func (ctx context.Context , t * helloworld.App ) error {
54
- fmt .Println (t .Config ().Name )
55
- t .HelloWorld .Get ().SayHello (ctx )
53
+ kod .Run (context .Background (), func (ctx context.Context , app * helloworld.App ) error {
54
+ fmt .Println (app .Config ().Name )
55
+ app .HelloWorld .Get ().SayHello (ctx )
56
56
return nil
57
57
}, kod .WithConfigFile ("./examples/helloworld/config.toml" ))
58
58
// Output:
@@ -65,11 +65,11 @@ func Example_config() {
65
65
func Example_log () {
66
66
wrapper , observer := kod .NewLogObserver ()
67
67
68
- kod .Run (context .Background (), func (ctx context.Context , t * helloworld.App ) error {
69
- t .L (ctx ).Debug ("Hello, World!" )
70
- t .L (ctx ).Info ("Hello, World!" )
71
- t .L (ctx ).Warn ("Hello, World!" )
72
- t .L (ctx ).Error ("Hello, World!" )
68
+ kod .Run (context .Background (), func (ctx context.Context , app * helloworld.App ) error {
69
+ app .L (ctx ).Debug ("Hello, World!" )
70
+ app .L (ctx ).Info ("Hello, World!" )
71
+ app .L (ctx ).Warn ("Hello, World!" )
72
+ app .L (ctx ).Error ("Hello, World!" )
73
73
return nil
74
74
}, kod .WithLogWrapper (wrapper ))
75
75
@@ -95,8 +95,8 @@ func Example_interceptor() {
95
95
return err
96
96
})
97
97
98
- kod .Run (context .Background (), func (ctx context.Context , t * helloworld.App ) error {
99
- t .HelloWorld .Get ().SayHello (ctx )
98
+ kod .Run (context .Background (), func (ctx context.Context , app * helloworld.App ) error {
99
+ app .HelloWorld .Get ().SayHello (ctx )
100
100
return nil
101
101
}, kod .WithInterceptors (interceptor ))
102
102
// Output:
@@ -108,8 +108,8 @@ func Example_interceptor() {
108
108
}
109
109
110
110
func Example_builtinInterceptor () {
111
- kod .Run (context .Background (), func (ctx context.Context , t * helloworld.App ) error {
112
- t .HelloWorld .Get ().SayHello (ctx )
111
+ kod .Run (context .Background (), func (ctx context.Context , app * helloworld.App ) error {
112
+ app .HelloWorld .Get ().SayHello (ctx )
113
113
return nil
114
114
}, kod .WithInterceptors (krecovery .Interceptor (), ktrace .Interceptor (), kmetric .Interceptor ()))
115
115
// Output:
@@ -119,8 +119,8 @@ func Example_builtinInterceptor() {
119
119
}
120
120
121
121
func Example_test () {
122
- kod .RunTest (& testing.T {}, func (ctx context.Context , t * helloworld.App ) {
123
- t .HelloWorld .Get ().SayHello (ctx )
122
+ kod .RunTest (& testing.T {}, func (ctx context.Context , app * helloworld.App ) {
123
+ app .HelloWorld .Get ().SayHello (ctx )
124
124
})
125
125
// Output:
126
126
// helloWorld init
@@ -132,18 +132,18 @@ func Example_testWithMockComponent() {
132
132
mock := helloworld .NewMockHelloWorld (gomock .NewController (nil ))
133
133
mock .EXPECT ().SayHello (gomock .Any ()).Return ()
134
134
135
- kod .RunTest (& testing.T {}, func (ctx context.Context , t * helloworld.App ) {
136
- t .HelloWorld .Get ().SayHello (ctx )
135
+ kod .RunTest (& testing.T {}, func (ctx context.Context , app * helloworld.App ) {
136
+ app .HelloWorld .Get ().SayHello (ctx )
137
137
fmt .Println ("Nothing printed from mock" )
138
138
}, kod .WithFakes (kod.Fake [helloworld.HelloWorld ](mock )))
139
139
// Output:
140
140
// Nothing printed from mock
141
141
}
142
142
143
143
func Example_lazyInit () {
144
- kod .Run (context .Background (), func (ctx context.Context , t * helloworld.App ) error {
145
- t .HelloBob .Get ().SayHello (ctx )
146
- t .HelloWorld .Get ().SayHello (ctx )
144
+ kod .Run (context .Background (), func (ctx context.Context , app * helloworld.App ) error {
145
+ app .HelloBob .Get ().SayHello (ctx )
146
+ app .HelloWorld .Get ().SayHello (ctx )
147
147
return nil
148
148
})
149
149
// Output:
0 commit comments