/
githubmirror
/
nbs
Обзор
Документация
Войти
/
githubmirror
/
nbs
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
cloud/tasks/common/util.go
39 строк
726 B
Mikhail Montsev
issue-5588: [Tasks] support non-cancellable tasks that can only either complete successfully or fail with a NonCancellableError (#5589)
28 мар 2026, 01:43
Не верифицирован
28 мар 2026, 01:43
39e8721
Код
Авторство
О чём код?
package common import ( "fmt" "math/rand" "time" ) //////////////////////////////////////////////////////////////////////////////// func Assertf(condition bool, message string, args ...any) { if !condition { panic(fmt.Sprintf(message, args...)) } } //////////////////////////////////////////////////////////////////////////////// func Find(slice []string, value string) bool { for _, v := range slice { if v == value { return true } } return false } func RandomDuration(min time.Duration, max time.Duration) time.Duration { rand.Seed(time.Now().UnixNano()) x := min.Microseconds() y := max.Microseconds() if y <= x { return min } return time.Duration(x+rand.Int63n(y-x)) * time.Microsecond }