Example #1
0
func appendIfMissing(slice []user.User, u user.User) ([]user.User, bool) {
	for _, ele := range slice {
		if u.Equals(ele) {
			return slice, false
		}
	}
	return append(slice, u), true
}
Example #2
0
func removeFromSlice(slice []user.User, u user.User) ([]user.User, bool) {
	removed := false
	newslice := make([]user.User, 0, len(slice))
	for _, ele := range slice {
		if !u.Equals(ele) && ele.ID != "" {
			newslice = append(newslice, ele)
		} else {
			removed = true
		}
	}
	return newslice, removed
}