Standard library / runtime

runtime.NumGoroutine()

Reports the number of goroutines currently existing. Background runtime activity makes exact totals unstable. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func NumGoroutine() int

Return Value

int

Snapshot of the number of existing goroutines.

Working Example

Example Snippetgo
package main
import (  "fmt"  "runtime")
func main() { fmt.Println(runtime.NumGoroutine() >= 1) }
Go Reference