Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f8e79bf

Browse files
committed
长度计算也使用 utf8
1 parent a58f557 commit f8e79bf

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

websites/code2/studygolang/src/logic/searcher.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,8 @@ func (self SearcherLogic) DoSearch(q, field string, start, rows int) (*model.Res
319319
}
320320

321321
if doc.HlContent == "" && doc.Content != "" {
322-
maxLen := len(doc.Content) - 1
322+
utf8string := util.NewString(doc.Content)
323+
maxLen := utf8string.RuneCount() - 1
323324
if maxLen > searchContentLen {
324325
maxLen = searchContentLen
325326
}

websites/code2/studygolang/start.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ if [ ! -d pid ]; then
1515
mkdir pid
1616
fi
1717

18+
export GOTRACEBACK=crash
19+
1820
bin/studygolang >> log/panic.log 2>&1 &
1921

2022
echo "start successfully"

0 commit comments

Comments
 (0)