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
c975ece2
Commit
c975ece2
authored
Aug 16, 2022
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初始化
parent
e3aad5f8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
6 deletions
+66
-6
EsLogger_test.go
es/EsLogger_test.go
+36
-0
PwdUtil.go
util/PwdUtil.go
+0
-6
StringUtil.go
util/StringUtil.go
+18
-0
StringUtil_test.go
util/StringUtil_test.go
+12
-0
No files found.
es/EsLogger_test.go
0 → 100644
View file @
c975ece2
package
es
import
(
"context"
"fmt"
"git.168cad.top/zhengqiuyun/rym-util/conf"
"git.168cad.top/zhengqiuyun/rym-util/exception"
"git.168cad.top/zhengqiuyun/rym-util/log"
"github.com/olivere/elastic/v7"
_log
"log"
"os"
"testing"
)
func
init
()
{
conf
.
Es
=
conf
.
EsConf
{
ServerHost
:
"to-chengdu-office.168cad.top"
,
ServerPort
:
50037
,
}
}
func
TestName
(
t
*
testing
.
T
)
{
host
:=
"http://to-chengdu-office.168cad.top:50037"
var
err
error
errorLog
:=
_log
.
New
(
os
.
Stdout
,
"APP"
,
_log
.
LstdFlags
)
client
,
err
:=
elastic
.
NewClient
(
elastic
.
SetSniff
(
false
),
elastic
.
SetErrorLog
(
errorLog
),
elastic
.
SetURL
(
host
))
if
err
!=
nil
{
exception
.
ThrowsErrS
(
fmt
.
Sprintf
(
"ES连接失败:%s"
,
err
.
Error
()))
}
info
,
code
,
err
:=
client
.
Ping
(
host
)
.
Do
(
context
.
Background
())
if
err
!=
nil
{
panic
(
err
)
}
log
.
Info
(
fmt
.
Sprintf
(
"Elasticsearch connect %d"
,
code
))
log
.
Info
(
fmt
.
Sprintf
(
"Elasticsearch version %s"
,
info
.
Version
.
Number
))
}
util/PwdUtil.go
deleted
100644 → 0
View file @
e3aad5f8
package
util
func
EncodePwd
(
loginPwd
,
loginPwdSalt
string
)
string
{
pingPwd
:=
loginPwdSalt
+
loginPwd
return
Md5
(
pingPwd
)
}
util/StringUtil.go
View file @
c975ece2
...
...
@@ -4,6 +4,7 @@ import (
"encoding/json"
"math/rand"
"strconv"
"strings"
)
// 生成: 时间戳 + 设置前缀 + 随即字符串
...
...
@@ -86,3 +87,20 @@ func IsNil(i interface{}) bool {
}
return
false
}
func
ContainsForSplitComma
(
list
,
item
string
)
bool
{
return
containsForSplit
(
list
,
item
,
","
)
}
func
containsForSplit
(
list
,
item
,
character
string
)
bool
{
if
!
IsEmpty
(
&
list
)
{
if
strings
.
Contains
(
list
,
character
)
{
return
strings
.
Index
(
list
,
item
+
character
)
==
0
||
strings
.
Contains
(
list
,
character
+
item
+
character
)
||
strings
.
Index
(
list
,
character
+
item
)
==
len
(
list
)
-
len
(
character
+
item
)
}
else
{
return
list
==
item
}
}
return
false
}
util/StringUtil_test.go
0 → 100644
View file @
c975ece2
package
util
import
(
"fmt"
"testing"
)
func
TestContainsForSplitComma
(
t
*
testing
.
T
)
{
a
:=
"15"
b
:=
"14"
fmt
.
Printf
(
"%s是否包含在[%s]中:%v"
,
a
,
b
,
ContainsForSplitComma
(
b
,
a
))
}
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