strutils.go 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. package strutils
  2. import (
  3. uuid "github.com/satori/go.uuid"
  4. "strings"
  5. )
  6. func AllBlank(str ...string) bool {
  7. for _, s := range str {
  8. if !IsStringEmpty(s) {
  9. return false
  10. }
  11. }
  12. return true
  13. }
  14. func HasBlank(str ...string) bool {
  15. for _, s := range str {
  16. if strings.Trim(s, " ") == "" {
  17. return true
  18. }
  19. }
  20. return false
  21. }
  22. func HasText(str ...string) bool {
  23. for _, s := range str {
  24. if strings.Trim(s, " ") != "" {
  25. return true
  26. }
  27. }
  28. return false
  29. }
  30. func IsStringEmpty(s string) bool {
  31. return strings.Trim(s, " ") == ""
  32. }
  33. func IsStringNotEmpty(s string) bool {
  34. return strings.Trim(s, " ") != ""
  35. }
  36. func GetUUID() string {
  37. return uuid.NewV4().String()
  38. }
  39. func SimpleUUID() string {
  40. return strings.ReplaceAll(GetUUID(), "-", "")
  41. }
  42. func GenerateUpperLetters(length int) []string {
  43. var str []string
  44. for i := 0; i < length; i++ {
  45. str = append(str, string(rune('A'+i)))
  46. }
  47. return str
  48. }
  49. func GenerateLowerLetters(length int) []string {
  50. var str []string
  51. for i := 0; i < length; i++ {
  52. str = append(str, string(rune('a'+i)))
  53. }
  54. return str
  55. }