Standard library / runtime

runtime.StopTrace()

Stop tracing and wait for readers to drain accumulated trace data. Do not stop on the only reader goroutine. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
func StopTrace()

Working Example

Example Snippetgo
package main
import (  "bytes"  "fmt"  "runtime")
func main() {  if err := runtime.StartTrace(); err != nil {    panic(err)  }  done := make(chan int, 1)  go func() {    var b bytes.Buffer    for {      data := runtime.ReadTrace()      if data == nil {        break      }      b.Write(data)    }    done <- b.Len()  }()  runtime.Gosched()  runtime.StopTrace()  fmt.Println(<-done > 0)}
Go Reference