Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengqiuyun
rym-util
Commits
ca24e506
Commit
ca24e506
authored
Oct 17, 2022
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
数组包含封装
parent
f2767dca
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
124 additions
and
0 deletions
+124
-0
AddrUtil.go
util/AddrUtil.go
+6
-0
ArrayUtil.go
util/ArrayUtil.go
+98
-0
ArrayUtil_test.go
util/ArrayUtil_test.go
+15
-0
DateUtil.go
util/DateUtil.go
+5
-0
No files found.
util/AddrUtil.go
View file @
ca24e506
...
@@ -29,6 +29,12 @@ func Int16s(p int16) *int16 {
...
@@ -29,6 +29,12 @@ func Int16s(p int16) *int16 {
func
Int8s
(
p
int8
)
*
int8
{
func
Int8s
(
p
int8
)
*
int8
{
return
&
p
return
&
p
}
}
func
Float64s
(
p
float64
)
*
float64
{
return
&
p
}
func
Float32s
(
p
float32
)
*
float32
{
return
&
p
}
func
Bytes
(
p
byte
)
*
byte
{
func
Bytes
(
p
byte
)
*
byte
{
return
&
p
return
&
p
}
}
...
...
util/ArrayUtil.go
View file @
ca24e506
package
util
package
util
import
"time"
func
ArrayContains
(
array
[]
string
,
e
string
)
bool
{
func
ArrayContains
(
array
[]
string
,
e
string
)
bool
{
for
_
,
v
:=
range
array
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
if
v
==
e
{
...
@@ -8,3 +10,99 @@ func ArrayContains(array []string, e string) bool {
...
@@ -8,3 +10,99 @@ func ArrayContains(array []string, e string) bool {
}
}
return
false
return
false
}
}
func
ArrayContainsUint64
(
array
[]
uint64
,
e
uint64
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsUint32
(
array
[]
uint32
,
e
uint32
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsUint16
(
array
[]
uint16
,
e
uint16
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsUint8
(
array
[]
uint8
,
e
uint8
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsInt64
(
array
[]
int64
,
e
int64
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsInt32
(
array
[]
int32
,
e
int32
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsInt16
(
array
[]
int16
,
e
int16
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsInt8
(
array
[]
int8
,
e
int8
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsFloat64
(
array
[]
float64
,
e
float64
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsFloat32
(
array
[]
float32
,
e
float32
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsByte
(
array
[]
byte
,
e
byte
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
func
ArrayContainsTime
(
array
[]
time
.
Time
,
e
time
.
Time
)
bool
{
for
_
,
v
:=
range
array
{
if
v
==
e
{
return
true
}
}
return
false
}
util/ArrayUtil_test.go
0 → 100644
View file @
ca24e506
package
util
import
(
"fmt"
"testing"
"time"
)
func
TestArrayContainsInterface
(
t
*
testing
.
T
)
{
var
areaIds
[]
time
.
Time
areaIds
=
append
(
areaIds
,
PareDateTime
(
"2022-02-09 22:09:12"
))
areaIds
=
append
(
areaIds
,
PareDateTime
(
"2022-03-09 22:09:12"
))
areaIds
=
append
(
areaIds
,
PareDateTime
(
"2022-12-09 22:09:12"
))
fmt
.
Println
(
ArrayContainsTime
(
areaIds
,
PareDateTime
(
"2022-02-10 22:09:12"
)))
}
util/DateUtil.go
View file @
ca24e506
...
@@ -31,6 +31,11 @@ func PareDateStart(date string) time.Time {
...
@@ -31,6 +31,11 @@ func PareDateStart(date string) time.Time {
return
stamp
return
stamp
}
}
func
PareDateTime
(
dateTime
string
)
time
.
Time
{
stamp
,
_
:=
time
.
ParseInLocation
(
formatSimple1
,
dateTime
,
time
.
Local
)
return
stamp
}
func
AddDate
(
date
time
.
Time
,
d
int
)
time
.
Time
{
func
AddDate
(
date
time
.
Time
,
d
int
)
time
.
Time
{
t
:=
(
int64
)(
d
*
24
*
60
*
60
)
t
:=
(
int64
)(
d
*
24
*
60
*
60
)
return
Add
(
date
,
t
)
return
Add
(
date
,
t
)
...
...
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