Standard library / context

context.Canceled

Sentinel error returned by Context.Err when a context is canceled for a reason other than expiration of its deadline. Expected stdout: 'true\n'.

Formal Syntax & Structure

go syntaxgo
var Canceled error

Working Example

Example Snippetgo
package main
import (  "context"  "errors"  "fmt")
func main() {  ctx, cancel := context.WithCancel(context.Background())  cancel()  fmt.Println(errors.Is(ctx.Err(), context.Canceled))}
Go Reference