File tree Expand file tree Collapse file tree 1 file changed +23
-23
lines changed Expand file tree Collapse file tree 1 file changed +23
-23
lines changed Original file line number Diff line number Diff line change @@ -98,31 +98,31 @@ GDB的一些常用命令如下所示
98
98
我们通过下面这个代码来演示如何通过GDB来调试Go程序,下面是将要演示的代码:
99
99
``` Go
100
100
101
- package main
102
-
103
- import (
104
- " fmt"
105
- " time"
106
- )
107
-
108
- func counting (c chan <- int ) {
109
- for i := 0 ; i < 10 ; i++ {
110
- time.Sleep (2 * time.Second )
111
- c <- i
112
- }
113
- close (c)
114
- }
101
+ package main
102
+
103
+ import (
104
+ " fmt"
105
+ " time"
106
+ )
115
107
116
- func main () {
117
- msg := " Starting main"
118
- fmt.Println (msg)
119
- bus := make (chan int )
120
- msg = " starting a gofunc"
121
- go counting (bus)
122
- for count := range bus {
123
- fmt.Println (" count:" , count)
124
- }
108
+ func counting (c chan <- int ) {
109
+ for i := 0 ; i < 10 ; i++ {
110
+ time.Sleep (2 * time.Second )
111
+ c <- i
112
+ }
113
+ close (c)
114
+ }
115
+
116
+ func main () {
117
+ msg := " Starting main"
118
+ fmt.Println (msg)
119
+ bus := make (chan int )
120
+ msg = " starting a gofunc"
121
+ go counting (bus)
122
+ for count := range bus {
123
+ fmt.Println (" count:" , count)
125
124
}
125
+ }
126
126
```
127
127
编译文件,生成可执行文件gdbfile:
128
128
You can’t perform that action at this time.
0 commit comments