CheckGoroutines updates the number of goroutines and optionally outputs the list of them on verbose. Use with `defer util.CheckGoroutines()`
()
| 84 | // and optionally outputs the list of them on verbose. |
| 85 | // Use with `defer util.CheckGoroutines()` |
| 86 | func CheckGoroutines() { |
| 87 | globalconfig.GoroutineCount = runtime.NumGoroutine() |
| 88 | if nodeps.IsEnvTrue("DDEV_GOROUTINES") { |
| 89 | if globalconfig.DdevVerbose { |
| 90 | buf := new(bytes.Buffer) |
| 91 | |
| 92 | // Lookup "goroutine" profile |
| 93 | p := pprof.Lookup("goroutine") |
| 94 | // Write it to stderr |
| 95 | _ = p.WriteTo(buf, 2) |
| 96 | Verbose("%s", buf.String()) |
| 97 | } |
| 98 | output.UserOut.Printf("goroutines=%d at exit of main()", globalconfig.GoroutineCount) |
| 99 | } |
| 100 | } |