Skip to content

Commit

Permalink
use strings.Contains instead of strings.Index
Browse files Browse the repository at this point in the history
  • Loading branch information
kevwan committed Aug 11, 2020
1 parent 08fa64d commit c57051c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/logx/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions rest/httpx/requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
}

0 comments on commit c57051c

Please sign in to comment.