context.Context is passed as the first argument of functions that may block or take long. Calling the cancel function, or hitting a timeout, closes ctx.Done() so every goroutine listening on it can stop and release resources.
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
defer cancel()