Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumGocontext cancel deadline valuesSingle-choice MCQ

A context created with context.WithTimeout completes its work well before the timeout fires. Why does the linter still flag a missing cancel() call?

func work() error { ctx, cancel := context.WithTimeout( context.Background(), 5*time.Second) _ = cancel // never called return doFast(ctx) }