From e10bc75933e09e9e457ffc37a6863c2bd66a1232 Mon Sep 17 00:00:00 2001 From: guoguangwu Date: Sat, 16 Mar 2024 10:42:23 +0800 Subject: [PATCH] chore: use strings.Contains and strings.ContainsRune instead strings.Index Signed-off-by: guoguangwu --- baselib.go | 2 +- parse/lexer.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/baselib.go b/baselib.go index aa2c08a9..7572d696 100644 --- a/baselib.go +++ b/baselib.go @@ -410,7 +410,7 @@ func baseToNumber(L *LState) int { L.Push(lv) case LString: str := strings.Trim(string(lv), " \n\t") - if strings.Index(str, ".") > -1 { + if strings.ContainsRune(str, '.') { if v, err := strconv.ParseFloat(str, LNumberBit); err != nil { L.Push(LNil) } else { diff --git a/parse/lexer.go b/parse/lexer.go index c20a0bdd..0f1cae47 100644 --- a/parse/lexer.go +++ b/parse/lexer.go @@ -512,7 +512,7 @@ func dump(node interface{}, level int, s string) string { tt := rt.Elem() indicies := []int{} for i := 0; i < tt.NumField(); i++ { - if strings.Index(tt.Field(i).Name, "Base") > -1 { + if strings.Contains(tt.Field(i).Name, "Base") { continue } indicies = append(indicies, i)