Commit 37dfb08 郑海成
committed
1 parent d618f27 commit 37dfb08 Copy full SHA for 37dfb08
File tree 2 files changed +6
-9
lines changed
examples/module1/callbacks
2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change 1
1
package main
2
2
3
3
func main () {
4
- var a * int
5
- * a += 1
6
- // DoOperation(1, increase)
4
+ DoOperation (1 , increase )
7
5
DoOperation (1 , decrease )
8
6
}
9
7
10
8
func increase (a , b int ) int {
9
+ println ("increase result is:" , a + b )
11
10
return a + b
12
11
}
13
12
14
- func DoOperation (y int , f func (int , int )) {
13
+ func DoOperation (y int , f func (int , int ) int ) {
15
14
f (y , 1 )
16
15
}
17
16
18
- func decrease (a , b int ) {
17
+ func decrease (a , b int ) int {
19
18
println ("decrease result is:" , a - b )
19
+ return a - b
20
20
}
Original file line number Diff line number Diff line change @@ -6,11 +6,8 @@ import (
6
6
"github.com/stretchr/testify/assert"
7
7
)
8
8
9
- func add (a , b int ) int {
10
- return a + b
11
- }
12
9
func TestIncrease (t * testing.T ) {
13
10
t .Log ("Start testing" )
14
- result := add (1 , 2 )
11
+ result := increase (1 , 2 )
15
12
assert .Equal (t , result , 3 )
16
13
}
You can’t perform that action at this time.
0 commit comments