// Delay sleeps for the specific amount or until context cancel/timeout
// and returns context error if context was canceled/timed out.
Delay sleeps for the specific amount or until context cancel/timeout
and returns context error if context was canceled/timed out.
// Delay sleeps for the specific amount or until context cancel / timeout // and returns context error if context was canceled / timed out .
func Delay(ctx context.Context, duration time.Duration) error {
    select {
    case <-time.After(duration):
    case <-ctx.Done():
    }
    return ctx.Err()
}
func Delay ( ctx context . Context , duration time . Duration ) error { select { case <- time . After ( duration ) : case <- ctx . Done ( ) : } return ctx . Err ( ) }
Delay sleeps for the specific amount or until context cancel/timeout
and returns context error if context was canceled/timed out.
Delay sleeps for the specific amount or until context cancel / timeout and returns context error if context was canceled / timed out .