123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- package utils
- import (
- "fmt"
- "github.com/go-resty/resty/v2"
- uuid "github.com/satori/go.uuid"
- "strings"
- )
- func AllBlank(str ...string) bool {
- for _, s := range str {
- if !HasBlank(s) {
- return false
- }
- }
- return true
- }
- func HasBlank(str ...string) bool {
- for _, s := range str {
- if strings.Trim(s, " ") == "" {
- return true
- }
- }
- return false
- }
- func HasText(str ...string) bool {
- for _, s := range str {
- if strings.Trim(s, " ") != "" {
- return true
- }
- }
- return false
- }
- func GetUUID() string {
- return uuid.NewV4().String()
- }
- func SimpleUUID() string {
- return strings.ReplaceAll(GetUUID(), "-", "")
- }
- func ResponseStatusError(url string, resp *resty.Response) error {
- if resp.Body() != nil && len(resp.Body()) != 0 {
- return fmt.Errorf("URL: %s Status: %d %s\n", url, resp.StatusCode(), resp.Body())
- } else {
- return fmt.Errorf("URL: %s Status: %s\n", url, resp.Status())
- }
- }
|