From 94a15e44d58efff36bc91c26a70a1a8db841a8df Mon Sep 17 00:00:00 2001
From: wangguoliang <liangcszzu@163.com>
Date: Thu, 7 Sep 2017 18:16:41 +0800
Subject: [PATCH] should use strings.Contains() instead of stings.Index()

Signed-off-by: wgliang <liangcszzu@163.com>
---
 gateway/handlers/reader.go      | 2 +-
 watchdog/requesthandler_test.go | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gateway/handlers/reader.go b/gateway/handlers/reader.go
index 77c5c0b9..af9c50cf 100644
--- a/gateway/handlers/reader.go
+++ b/gateway/handlers/reader.go
@@ -42,7 +42,7 @@ func MakeFunctionReader(metricsOptions metrics.MetricOptions, c *client.Client)
 				var envProcess string
 
 				for _, env := range service.Spec.TaskTemplate.ContainerSpec.Env {
-					if strings.Index(env, "fprocess=") > -1 {
+					if strings.Contains(env, "fprocess=") {
 						envProcess = env[len("fprocess="):]
 					}
 				}
diff --git a/watchdog/requesthandler_test.go b/watchdog/requesthandler_test.go
index 3a1cbd6e..03875a8e 100644
--- a/watchdog/requesthandler_test.go
+++ b/watchdog/requesthandler_test.go
@@ -47,7 +47,7 @@ func TestHandler_HasCustomHeaderInFunction_WithCgi_Mode(t *testing.T) {
 
 	read, _ := ioutil.ReadAll(rr.Body)
 	val := string(read)
-	if strings.Index(val, "Http_Custom_Header") == -1 {
+	if !strings.Contains(val, "Http_Custom_Header") {
 		t.Errorf("'env' should printed: Http_Custom_Header, got: %s\n", val)
 
 	}
@@ -83,7 +83,7 @@ func TestHandler_DoesntHaveCustomHeaderInFunction_WithoutCgi_Mode(t *testing.T)
 
 	read, _ := ioutil.ReadAll(rr.Body)
 	val := string(read)
-	if strings.Index(val, "Http_Custom_Header") != -1 {
+	if strings.Contains(val, "Http_Custom_Header") {
 		t.Errorf("'env' should not have printed: Http_Custom_Header, got: %s\n", val)
 
 	}
-- 
GitLab