forked from forgejo/forgejo
migrate from com.* to alternatives (#14103)
* remove github.com/unknwon/com from models * dont use "com.ToStr()" * replace "com.ToStr" with "fmt.Sprint" where its easy to do * more refactor * fix test * just "proxy" Copy func for now * as per @lunny
This commit is contained in:
parent
04ae0f2f3f
commit
a19447aed1
46 changed files with 230 additions and 220 deletions
|
@ -4,7 +4,10 @@
|
|||
|
||||
package util
|
||||
|
||||
import "sort"
|
||||
import (
|
||||
"sort"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Int64Slice attaches the methods of Interface to []int64, sorting in increasing order.
|
||||
type Int64Slice []int64
|
||||
|
@ -36,10 +39,22 @@ func ExistsInSlice(target string, slice []string) bool {
|
|||
}
|
||||
|
||||
// IsStringInSlice sequential searches if string exists in slice.
|
||||
func IsStringInSlice(target string, slice []string) bool {
|
||||
func IsStringInSlice(target string, slice []string, insensitive ...bool) bool {
|
||||
caseInsensitive := false
|
||||
if len(insensitive) != 0 && insensitive[0] {
|
||||
caseInsensitive = true
|
||||
target = strings.ToLower(target)
|
||||
}
|
||||
|
||||
for i := 0; i < len(slice); i++ {
|
||||
if slice[i] == target {
|
||||
return true
|
||||
if caseInsensitive {
|
||||
if strings.ToLower(slice[i]) == target {
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
if slice[i] == target {
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue