我想使用库 https://github.com/sergi/go-diffpackage mainimport ( "fmt" "github.com/sergi/go-diff/diffmatchpatch")func main() { dmp := diffmatchpatch.New() text1 := "some text" text2 := "other text" diffs := dmp.DiffMain(text1, text2, true) fmt.Println(diffs)}输出:[{Delete s} {Equal o} {Delete m} {Insert th} {Equal e} {Insert r} {Equal text}]我不会:[{Delete some} {Insert other} {Equal text}]可能吗?附言:对不起我的英语。
1 回答
郎朗坤
TA贡献1921条经验 获得超9个赞
检查这个
package main
import (
"fmt"
"github.com/sergi/go-diff/diffmatchpatch"
)
func main() {
dmp := diffmatchpatch.New()
text1 := "some text"
text2 := "other text"
diffs := dmp.DiffMain(text1, text2, true)
fmt.Println(dmp.DiffCleanupSemantic(diffs))
}
添加回答
举报
0/150
提交
取消