/*如何应用 goland debug goroutine*/package mainimport (    "fmt"    "runtime"    "sync")type Tester interface {    test1()    test2()    test3()}type T struct {    a int    s *sync.WaitGroup}func main() {    fmt.Println("main start!")    s := &sync.WaitGroup{}    s.Add(3)    t := T{a: 1, s: s} // 断点    // bebug 到这里时,须要在帧栏目中抉择 main.test1 的协程帧,不然不会 debug到 test1 函数外部的.或者光标放入 test1 函数外部,点击运行到光标处也行    go t.test1() // 断点    go t.test2()    go t.test3() // 断点    s.Wait()    fmt.Println("main end!")}// 如何进入 goroutinefunc (t *T) test1() {    defer func() {        t.s.Done()    }()    t.a++ // 断点    fmt.Println("test1", t.a)}//异样断点func (t *T) test2() {    defer func() {        // 产生宕机时,获取panic传递的上下文并打印        err := recover()        switch err.(type) {        case runtime.Error: // 运行时谬误            fmt.Println("runtime error:", err)        default: // 非运行时谬误            fmt.Println("error:", err)        }        t.s.Done()    }()    t.a++    panic("制作一个谬误")    fmt.Println("test2", t.a)}// 如何跳过循环func (t *T) test3() {    fmt.Println("test start!") // 断点    for i := 0; i < 30; i++ {  // debug 到一些循环时,不想跟踪每个循环运行,能够点击 步出(F8)跳到下一个 debug 点        fmt.Println("test3", i)    }    fmt.Println("test end!") // 断点    t.s.Done()}/*调试心得:1.要是协程帧打不开,那可能是帧太多了,能够在 goland 的设置中设置协程数限度2.有时候下面的形式切换不到想看的协程,能够在协程运行左近(go XXX()处),试试应用运行到光标处(光标放到协程函数中)3.有时候单步运行到了循环中,同样能够应用运行到光标处(光标点击到循环外)或者点击回复程序按钮(最好在循环外打一个端点,点击恢复程序按钮会运行到此处)3.https://www.jetbrains.com/help/go/debugging-code.html 官网教程,但感觉没说很细*/