github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/util/slice.go (about) 1 // Copyright 2023 The GitBundle Inc. All rights reserved. 2 // Copyright 2017 The Gitea Authors. All rights reserved. 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file. 5 6 package util 7 8 // RemoveIDFromList removes the given ID from the slice, if found. 9 // It does not preserve order, and assumes the ID is unique. 10 func RemoveIDFromList(list []int64, id int64) ([]int64, bool) { 11 n := len(list) - 1 12 for i, item := range list { 13 if item == id { 14 list[i] = list[n] 15 return list[:n], true 16 } 17 } 18 return list, false 19 }