Files
deep_go/lessons/contexts/context_without_cancel/main.go

18 lines
249 B
Go
Raw Normal View History

package main
import (
"context"
"fmt"
"time"
)
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
innerCtx := context.WithoutCancel(ctx)
cancel()
if innerCtx.Err() != nil {
fmt.Println("canceled")
}
}