summaryrefslogtreecommitdiff
path: root/pkg/util
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2022-06-05 16:46:34 -0600
committerLuke Shumaker <lukeshu@lukeshu.com>2022-06-05 16:46:34 -0600
commit74b109b0a75ae6648f9381252d8beb5ce6025df3 (patch)
tree64b8b2250c67f749566761bab56676bed9c33846 /pkg/util
parente134a9fbd0d8ae43e2d24c5aabad8bf6a16190ed (diff)
factor out a btrfsmisc pacage
Diffstat (limited to 'pkg/util')
-rw-r--r--pkg/util/generic.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/pkg/util/generic.go b/pkg/util/generic.go
new file mode 100644
index 0000000..79096ab
--- /dev/null
+++ b/pkg/util/generic.go
@@ -0,0 +1,28 @@
+package util
+
+import (
+ "golang.org/x/exp/constraints"
+)
+
+func InSlice[T comparable](needle T, haystack []T) bool {
+ for _, straw := range haystack {
+ if needle == straw {
+ return true
+ }
+ }
+ return false
+}
+
+func Max[T constraints.Ordered](a, b T) T {
+ if a > b {
+ return a
+ }
+ return b
+}
+
+func Min[T constraints.Ordered](a, b T) T {
+ if a < b {
+ return a
+ }
+ return b
+}