From 956589fab3d67fb5ce9823b7d7c5d8201b7a95f7 Mon Sep 17 00:00:00 2001 From: Cameron Moore Date: Thu, 19 Mar 2015 09:21:15 -0500 Subject: [PATCH] Improve placement of variable declaration Thanks to rsc.io/grind --- helpers/helpers.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/helpers/helpers.go b/helpers/helpers.go index a6c02bf..c5bbed7 100644 --- a/helpers/helpers.go +++ b/helpers/helpers.go @@ -42,12 +42,10 @@ func ExtractParameter(s string, params interface{}) (string, bool) { return "", false } - var p []string - if paramsValue := reflect.ValueOf(params); paramsValue.Kind() == reflect.Slice { if paramsValueSliceLength := paramsValue.Len(); paramsValueSliceLength > 0 { - if p = strings.SplitN(s, ".", 3); len(p) > 3 { + if p := strings.SplitN(s, ".", 3); len(p) > 3 { index, err := strconv.ParseInt(p[1], 10, 64) if err != nil { @@ -63,7 +61,7 @@ func ExtractParameter(s string, params interface{}) (string, bool) { return "", false } - if p = strings.SplitN(s, ".", 2); len(p) > 1 { + if p := strings.SplitN(s, ".", 2); len(p) > 1 { if pValue, ok := params.(map[string]interface{})[p[0]]; ok { return ExtractParameter(p[1], pValue) }