Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
broadcast_cloud
/
go-tool
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8c385325
authored
Sep 04, 2021
by
盛威豪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s
parent
762f805f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
0 deletions
+33
-0
go.mod
+6
-0
go.sum
+0
-0
utils/utils.go
+27
-0
No files found.
go.mod
View file @
8c385325
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
)
go.sum
0 → 100644
View file @
8c385325
This diff is collapsed.
Click to expand it.
utils/utils.go
View file @
8c385325
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment