Standard library / context

context.Background()

Return a non-nil root context without cancellation, deadline or values. Use for top-level work. Expected stdout: 'true true false\n'.

Formal Syntax & Structure

go syntaxgo
func Background() Context

Return Value

Context

Empty root Context.

Working Example

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