mirror of
https://github.com/safing/portbase
synced 2025-09-15 09:39:50 +00:00
Initial commit after restructure
This commit is contained in:
commit
96ec15b39b
70 changed files with 6945 additions and 0 deletions
44
utils/slices.go
Normal file
44
utils/slices.go
Normal file
|
@ -0,0 +1,44 @@
|
|||
package utils
|
||||
|
||||
func StringInSlice(s string, a []string) bool {
|
||||
for _, entry := range a {
|
||||
if entry == s {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func RemoveFromStringSlice(a []string, s string) []string {
|
||||
for key, entry := range a {
|
||||
if entry == s {
|
||||
a = append(a[:key], a[key+1:]...)
|
||||
return a
|
||||
}
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func DuplicateStrings(a []string) []string {
|
||||
b := make([]string, len(a))
|
||||
copy(b, a)
|
||||
return b
|
||||
}
|
||||
|
||||
func StringSliceEqual(a []string, b []string) bool {
|
||||
if len(a) != len(b) {
|
||||
return false
|
||||
}
|
||||
for i, v := range a {
|
||||
if v != b[i] {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func DuplicateBytes(a []byte) []byte {
|
||||
b := make([]byte, len(a))
|
||||
copy(b, a)
|
||||
return b
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue