Standard library / runtime/trace
trace.IsEnabled()
Return an advisory snapshot of trace status; other goroutines may change it immediately. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
func IsEnabled() boolReturn Value
bool
Advisory snapshot of whether execution tracing is active.
Working Example
Example Snippetgo
package main
import ( "bytes" "fmt" "runtime/trace")
func main() { var b bytes.Buffer if err := trace.Start(&b); err != nil { panic(err) } active := trace.IsEnabled() trace.Stop() fmt.Println(active && !trace.IsEnabled())}