Commit 8c385325 by 盛威豪

s

parent 762f805f
module github.com/zjswh/go-tool module github.com/zjswh/go-tool
go 1.16 go 1.16
require (
github.com/gin-gonic/gin v1.7.4
github.com/google/uuid v1.3.0
github.com/nacos-group/nacos-sdk-go v1.0.8
)
This diff is collapsed. Click to expand it.
...@@ -4,13 +4,34 @@ import ( ...@@ -4,13 +4,34 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strconv"
"strings" "strings"
) )
const MessageHost = "http://pubdev.guangdianyun.tv" const MessageHost = "http://pubdev.guangdianyun.tv"
func DefaultIntParam(str string, defaultValue int, c *gin.Context) int {
param := c.Query(str)
if param == "" {
return defaultValue
}
intParam, _ := strconv.Atoi(param)
return intParam
}
func DefaultIntFormValue(str string, defaultValue int, c *gin.Context) int {
param := c.Request.FormValue(str)
if param == "" {
return defaultValue
}
intParam, _ := strconv.Atoi(param)
return intParam
}
func Request(url string, data map[string]interface{}, header map[string]interface{}, method string, stype string) (body []byte, err error) { func Request(url string, data map[string]interface{}, header map[string]interface{}, method string, stype string) (body []byte, err error) {
url = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(url, "\n", ""), " ", ""), "\r", "") url = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(url, "\n", ""), " ", ""), "\r", "")
param := []byte("") param := []byte("")
...@@ -91,3 +112,8 @@ func Reverse(s string) string { ...@@ -91,3 +112,8 @@ func Reverse(s string) string {
} }
return string(a) return string(a)
} }
func GenUUID() string {
u, _ := uuid.NewRandom()
return u.String()
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment