MCPcopy
hub / github.com/crowdsecurity/crowdsec / removeFromSlice

Function removeFromSlice

cmd/crowdsec-cli/clilapi/utils.go:3–26  ·  view source on GitHub ↗
(val string, slice []string)

Source from the content-addressed store, hash-verified

1package clilapi
2
3func removeFromSlice(val string, slice []string) []string {
4 var (
5 i int
6 value string
7 )
8
9 valueFound := false
10
11 // get the index
12 for i, value = range slice {
13 if value == val {
14 valueFound = true
15 break
16 }
17 }
18
19 if valueFound {
20 slice[i] = slice[len(slice)-1]
21 slice[len(slice)-1] = ""
22 slice = slice[:len(slice)-1]
23 }
24
25 return slice
26}

Callers 1

newContextDetectCmdMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…