实现文档版本比对功能

master
DESKTOP-4RNDQIC\29019 2020-11-11 00:05:17 +08:00
parent 077ddffa99
commit 60330602d4
3 changed files with 31 additions and 7 deletions

View File

@ -97,7 +97,7 @@ func main() {
InitLogs() InitLogs()
InitRedisConfig() InitRedisConfig()
InitMysql() InitMysql()
InitElasticSearch() //InitElasticSearch()
//o := db.GetMongoDb() //o := db.GetMongoDb()
//mgo = mgo //mgo = mgo

23
test/git_test.go Normal file
View File

@ -0,0 +1,23 @@
package test
import (
"log"
"testing"
"github.com/sergi/go-diff/diffmatchpatch"
)
const (
text1 = "Lorem ipsum dolor."
text2 = "Lorem dolor sit amet. sdfsdfsd"
)
func TestDiff(t *testing.T) {
dmp := diffmatchpatch.New()
diffs := dmp.DiffMain(text1, text2, false)
log.Print(diffs)
prettydiff := dmp.DiffPrettyText(diffs)
log.Print(prettydiff)
}

View File

@ -8,6 +8,7 @@ import (
"log" "log"
"testing" "testing"
) )
func InitConfig() { func InitConfig() {
e := config.Init("user.yaml") e := config.Init("user.yaml")
if nil != e { if nil != e {
@ -29,16 +30,16 @@ func InitRedisConfig() {
return return
} }
} }
func InitElasticSearch(){ func InitElasticSearch() {
e := db.GetElastic().CreateIndex("hardware",model.HardwareTypeMapping()) e := db.GetElastic().CreateIndex("hardware", model.HardwareTypeMapping())
if nil != e{ if nil != e {
} }
} }
func InitLogs() { func InitLogs() {
logs.Init(config.GetLogConfig().Dir, config.GetLogConfig().File, config.GetLogConfig().Level, config.GetLogConfig().SaveFile) logs.Init(config.GetLogConfig().Dir, config.GetLogConfig().File, config.GetLogConfig().Level, config.GetLogConfig().SaveFile)
} }
func TestPortDocToElastic(t *testing.T) { func TestPortDocToElastic(t *testing.T) {
InitConfig() InitConfig()
InitLogs() InitLogs()
InitRedisConfig() InitRedisConfig()
@ -46,7 +47,7 @@ func TestPortDocToElastic(t *testing.T) {
InitElasticSearch() InitElasticSearch()
db.InitELK() db.InitELK()
e := model.PortDocumentToElasticsearch("doc") e := model.PortDocumentToElasticsearch("doc")
if nil != e{ if nil != e {
t.Error(e) t.Error(e)
} }
} }