1d4f3166fb
* core(deps): bump golang.org/x/sys To resolve /go/pkg/mod/github.com/shirou/gopsutil@v2.20.9+incompatible/host/host_bsd.go:20:13: undefined: unix.SysctlTimeval * chore(deps): make update-vendor
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
|
|
}
|
|
}
|