* Update to v3.21.1 to allow builds to work for darwin arm64 Co-authored-by: Megan Marsh <megan@hashicorp.com> Co-authored-by: Adrien Delorme <adrien.delorme@icloud.com>
19 lines
317 B
Go
19 lines
317 B
Go
package common
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// Sleep awaits for provided interval.
|
|
// Can be interrupted by context cancelation.
|
|
func Sleep(ctx context.Context, interval time.Duration) error {
|
|
var timer = time.NewTimer(interval)
|
|
select {
|
|
case <-ctx.Done():
|
|
return ctx.Err()
|
|
case <-timer.C:
|
|
return nil
|
|
}
|
|
}
|