12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package com
- import (
- "strings"
- )
- func AppendStr(strs []string, str string) []string {
- for _, s := range strs {
- if s == str {
- return strs
- }
- }
- return append(strs, str)
- }
- func CompareSliceStr(s1, s2 []string) bool {
- if len(s1) != len(s2) {
- return false
- }
- for i := range s1 {
- if s1[i] != s2[i] {
- return false
- }
- }
- return true
- }
- func CompareSliceStrU(s1, s2 []string) bool {
- if len(s1) != len(s2) {
- return false
- }
- for i := range s1 {
- for j := len(s2) - 1; j >= 0; j-- {
- if s1[i] == s2[j] {
- s2 = append(s2[:j], s2[j+1:]...)
- break
- }
- }
- }
- if len(s2) > 0 {
- return false
- }
- return true
- }
- func IsSliceContainsStr(sl []string, str string) bool {
- str = strings.ToLower(str)
- for _, s := range sl {
- if strings.ToLower(s) == str {
- return true
- }
- }
- return false
- }
- func IsSliceContainsInt64(sl []int64, i int64) bool {
- for _, s := range sl {
- if s == i {
- return true
- }
- }
- return false
- }
|