fix (encounter): add guard for create, delete and cancel

This commit is contained in:
dpurbosakti
2025-11-13 14:51:45 +07:00
parent ccc341be34
commit 1e54d3bc3f
6 changed files with 73 additions and 10 deletions
+16
View File
@@ -150,3 +150,19 @@ func IsDateBeforeNow(t *time.Time) bool {
}
return t.Before(time.Now())
}
// Contains reports whether v is present in s.
func Contains[S ~[]E, E comparable](s S, v E) bool {
return index(s, v) >= 0
}
// Index returns the index of the first occurrence of v in s,
// or -1 if not present.
func index[S ~[]E, E comparable](s S, v E) int {
for i := range s {
if v == s[i] {
return i
}
}
return -1
}