github.com/Rookout/GoSDK@v0.1.48/pkg/utils/list_utils.go (about) 1 package utils 2 3 import ( 4 "container/list" 5 "strings" 6 ) 7 8 func GetElementInList(l *list.List, index int) interface{} { 9 i := 0 10 for e := l.Front(); e != nil; e = e.Next() { 11 if index == i { 12 return e.Value 13 } 14 i++ 15 } 16 return nil 17 } 18 19 func Contains(slice []string, str string) bool { 20 for _, value := range slice { 21 if value == str { 22 return true 23 } 24 } 25 return false 26 } 27 28 func IsTrue(str string) bool { 29 return Contains(TrueValues, strings.ToLower(str)) 30 } 31 32 func Cut(str string, l int) string { 33 if len(str) > l { 34 return str[:l] 35 } 36 return str 37 }