summaryrefslogtreecommitdiff
path: root/utilities/utilities.go
diff options
context:
space:
mode:
authorWill Hawkins <[email protected]>2023-05-23 17:58:14 -0400
committerWill Hawkins <[email protected]>2023-06-21 09:12:22 -0400
commitec2ccf69d8b08abb03fa3bdb3e7e95ae1862d619 (patch)
tree6b636bdbda82db40da89a2bde213c684542850dc /utilities/utilities.go
parent5558f0347baaf6db066314f0eaf82d7fb552b2f7 (diff)
Major Update/Refactor to Support IETF 02
Beginning of a release candidate for support for IETF 02 tag of the responsiveness spec.
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)
+}