From 0c15bd4dd15f39128c0d0c065b3010319797f7f2 Mon Sep 17 00:00:00 2001 From: yywing <386542536@qq.com> Date: Mon, 20 Mar 2017 13:31:56 +0800 Subject: [PATCH] Update strapdown-server.go --- server/strapdown-server.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/strapdown-server.go b/server/strapdown-server.go index c1111ca..26bed1a 100755 --- a/server/strapdown-server.go +++ b/server/strapdown-server.go @@ -378,6 +378,7 @@ func UnicodeIndex(str, substr string) int { } return result } + //字符串匹配 func searchStr(files []string, key string, suffix string, prefix string) (searchs []byte, err error) { var jsondata []SearchResult @@ -389,8 +390,8 @@ func searchStr(files []string, key string, suffix string, prefix string) (search con, _ := ioutil.ReadAll(f) str := string(con[:]) f.Close() - if strings.Contains(strings.ToLower(str),strings.ToLower(key)) { - pos := UnicodeIndex(strings.ToLower(str),strings.ToLower(key)) + if strings.Contains(strings.ToLower(str), strings.ToLower(key)) { + pos := UnicodeIndex(strings.ToLower(str), strings.ToLower(key)) t := Substr(str, pos-15, 30) searchfile := strings.TrimSuffix(files[i], suffix) searchfile = strings.TrimPrefix(searchfile, prefix)