Update module github.com/shirou/gopsutil to v4

Signed-off-by: Mikel Olasagasti Uranga <mikel@olasagasti.info>
This commit is contained in:
Mikel Olasagasti Uranga
2024-09-03 18:20:12 +02:00
parent efd4971545
commit e9a4534cb1
112 changed files with 517 additions and 404 deletions

View File

@@ -0,0 +1,22 @@
// SPDX-License-Identifier: BSD-3-Clause
package common
import (
"context"
"time"
)
// Sleep awaits for provided interval.
// Can be interrupted by context cancellation.
func Sleep(ctx context.Context, interval time.Duration) error {
timer := time.NewTimer(interval)
select {
case <-ctx.Done():
if !timer.Stop() {
<-timer.C
}
return ctx.Err()
case <-timer.C:
return nil
}
}