Standard library / runtime/trace
trace.Task
Handle for a logical operation that may span goroutines, linked through a context. Expected stdout: 'true\n'.
Formal Syntax & Structure
go syntaxgo
type Task struct {}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) } c, t := trace.NewTask(context.Background(), "job") var task *trace.Task = t trace.Log(c, "phase", "done") task.End() trace.Stop() fmt.Println(b.Len() > 0)}