2022-03-21 21:09:45 -04:00
|
|
|
// Copyright 2022 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2022-03-21 21:09:45 -04:00
|
|
|
|
|
|
|
package util
|
|
|
|
|
|
|
|
// RemoveIDFromList removes the given ID from the slice, if found.
|
|
|
|
// It does not preserve order, and assumes the ID is unique.
|
|
|
|
func RemoveIDFromList(list []int64, id int64) ([]int64, bool) {
|
|
|
|
n := len(list) - 1
|
|
|
|
for i, item := range list {
|
|
|
|
if item == id {
|
|
|
|
list[i] = list[n]
|
|
|
|
return list[:n], true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return list, false
|
|
|
|
}
|