Standard library / context

context.TODO()

Return an empty context as a placeholder when the appropriate parent is not yet available. Replace it when wiring real cancellation. Expected stdout: 'true true\n'.

Formal Syntax & Structure

go syntaxgo
func TODO() Context

Return Value

Context

Non-nil placeholder Context.

Working Example

Example Snippetgo
package main
import (  "context"  "fmt")
func main() { ctx := context.TODO(); fmt.Println(ctx.Done() == nil, ctx.Err() == nil) }
Go Reference