From c57051ce63e24456638553f038b5b8714eb533bb Mon Sep 17 00:00:00 2001 From: kevin Date: Tue, 11 Aug 2020 17:18:51 +0800 Subject: [PATCH] use strings.Contains instead of strings.Index --- core/logx/logs_test.go | 2 +- rest/httpx/requests.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/logx/logs_test.go b/core/logx/logs_test.go index cb3e6d8a..d8cb7dbc 100644 --- a/core/logx/logs_test.go +++ b/core/logx/logs_test.go @@ -37,7 +37,7 @@ func (mw *mockWriter) Reset() { } func (mw *mockWriter) Contains(text string) bool { - return strings.Index(mw.builder.String(), text) > -1 + return strings.Contains(mw.builder.String(), text) } func TestFileLineFileMode(t *testing.T) { diff --git a/rest/httpx/requests.go b/rest/httpx/requests.go index e62f6842..115cd11f 100644 --- a/rest/httpx/requests.go +++ b/rest/httpx/requests.go @@ -39,7 +39,7 @@ func Parse(r *http.Request, v interface{}) error { // Parses the form request. func ParseForm(r *http.Request, v interface{}) error { - if strings.Index(r.Header.Get(ContentType), multipartFormData) != -1 { + if strings.Contains(r.Header.Get(ContentType), multipartFormData) { if err := r.ParseMultipartForm(maxMemory); err != nil { return err } @@ -107,5 +107,5 @@ func ParsePath(r *http.Request, v interface{}) error { } func withJsonBody(r *http.Request) bool { - return r.ContentLength > 0 && strings.Index(r.Header.Get(ContentType), ApplicationJson) != -1 + return r.ContentLength > 0 && strings.Contains(r.Header.Get(ContentType), ApplicationJson) }