Add ingress feature to controller (#5)

Co-authored-by: Maycon Santos <mlsmaycon@gmail.com>
This commit is contained in:
M. Essam
2025-03-06 09:57:45 +01:00
committed by GitHub
co-authored by Maycon Santos
parent cea60745d2
commit 166091b8e0
54 changed files with 5992 additions and 189 deletions
+6
View File
@@ -0,0 +1,6 @@
package util
// Ptr return pointer to any value for API purposes
func Ptr[T any, PT *T](x T) PT {
return &x
}
+41
View File
@@ -0,0 +1,41 @@
package util
// Contains return if y is in slice x
func Contains[T comparable](x []T, y T) bool {
for _, v := range x {
if v == y {
return true
}
}
return false
}
// Without return all of x in same order without y
func Without[T comparable](x []T, y T) []T {
var ret []T
for _, v := range x {
if v != y {
ret = append(ret, v)
}
}
return ret
}
// Equivalent return true if x and y are equal when sorted
func Equivalent[T comparable](x, y []T) bool {
if len(x) != len(y) {
return false
}
mp := make(map[T]interface{})
for _, v := range x {
mp[v] = nil
}
for _, v := range y {
if _, ok := mp[v]; !ok {
return false
}
}
return true
}