123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- 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
- }
|