package string import ( "strconv" "strings" ) func IsEmptyOrNil(s string) bool { return &s == nil || len(s) == 0 } func IsBlank(s string) bool { return strings.TrimSpace(s) == "" } func IsNotBlank(s string) bool { return !IsBlank(s) } func StringToIntSlice(strSlice []string) ([]int, error) { var intSlice []int for _, str := range strSlice { num, err := strconv.Atoi(str) if err != nil { return nil, err } intSlice = append(intSlice, num) } return intSlice, nil } func StringsToJSON(str string) string { rs := []rune(str) jsons := "" for _, r := range rs { rint := int(r) if rint < 128 { jsons += string(r) } else { jsons += "\\u" + strconv.FormatInt(int64(rint), 16) // json } } return jsons } func IntToStringSlice(intSlice []int) []string { var strSlice []string for _, num := range intSlice { strSlice = append(strSlice, strconv.Itoa(num)) } return strSlice } func RemoveEmptyStrings(slice []string) []string { var filteredSlice []string for _, s := range slice { if s != "" { filteredSlice = append(filteredSlice, s) } } return filteredSlice } func UniqueItems(items []string) []string { seen := make(map[string]bool) result := []string{} for _, item := range items { if seen[item] { continue } seen[item] = true result = append(result, item) } return result }