Standard library / runtime/trace

trace.Region.End()

End the traced region on the goroutine that started it, in reverse order of nested starts. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func (r *Region) End()

Working Example

Example Snippetgo
package main
import (  "bytes"  "context"  "fmt"  "runtime/trace")
func main() {  var b bytes.Buffer  if err := trace.Start(&b); err != nil {    panic(err)  }  outer := trace.StartRegion(context.Background(), "outer")  inner := trace.StartRegion(context.Background(), "inner")  inner.End()  outer.End()  trace.Stop()  fmt.Println(b.Len() > 0)}
Go Reference