netbird/management/server/util/util.go
bcmmbaga 525019b5ed
Use time pointer instead of sql.NullTime
Signed-off-by: bcmmbaga <bethuelmbaga12@gmail.com>
2025-01-02 15:48:50 +03:00

22 lines
426 B
Go

package util
// Difference returns the elements in `a` that aren't in `b`.
func Difference(a, b []string) []string {
mb := make(map[string]struct{}, len(b))
for _, x := range b {
mb[x] = struct{}{}
}
var diff []string
for _, x := range a {
if _, found := mb[x]; !found {
diff = append(diff, x)
}
}
return diff
}
// ToPtr returns a pointer to the given value.
func ToPtr[T any](value T) *T {
return &value
}