summaryrefslogtreecommitdiff
path: root/utilities/utilities.go
diff options
context:
space:
mode:
Diffstat (limited to 'utilities/utilities.go')
-rw-r--r--utilities/utilities.go18
1 files changed, 12 insertions, 6 deletions
diff --git a/utilities/utilities.go b/utilities/utilities.go
index e75d373..ff04023 100644
--- a/utilities/utilities.go
+++ b/utilities/utilities.go
@@ -30,13 +30,10 @@ import (
"golang.org/x/exp/constraints"
)
-var (
- // GitVersion is the Git revision hash
- GitVersion = "dev"
-)
+// GitVersion is the Git revision hash
+var GitVersion = "dev"
func Iota(low int, high int) (made []int) {
-
made = make([]int, high-low)
for counter := low; counter < high; counter++ {
made[counter-low] = counter
@@ -67,7 +64,7 @@ func AbsPercentDifference(
)
}
-func Conditional(condition bool, t string, f string) string {
+func Conditional[T any](condition bool, t T, f T) T {
if condition {
return t
}
@@ -229,3 +226,12 @@ func ContextSignaler(ctxt context.Context, st time.Duration, condition *func() b
return
}
}
+
+type Pair[T any] struct {
+ First T
+ Second T
+}
+
+func PerSecondToInterval(rate int64) time.Duration {
+ return time.Duration(time.Second.Nanoseconds() / rate)
+}