| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- package utils
- import (
- "errors"
- "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(resp *resty.Response) error {
- if resp.Body() != nil && len(resp.Body()) != 0 {
- return errors.New(string(resp.Body()))
- } else {
- return fmt.Errorf("Status: %d %s\n", resp.StatusCode(), resp.Status())
- }
- }
|