ref: 139585f84a82f08027ca72b3d3266b7f58db2883
parent: a721fbed1daf5f9046ceff5f831f9a859347bd90
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Wed Nov 23 13:53:50 EST 2016
tpl: Simplify
--- a/tpl/template_funcs.go
+++ b/tpl/template_funcs.go
@@ -1593,7 +1593,7 @@
// argument when the key is missing: {{ index . "key" | default "foo" }}// The Go template will complain that we got 1 argument when we expectd 2.
- if given == nil || len(given) == 0 {+ if len(given) == 0 {return dflt, nil
}
if len(given) != 1 {@@ -1922,7 +1922,7 @@
_, ok := in.(int) // original param was literal int value
_, err = strconv.Atoi(word) // original param was string containing an int value
- if ok == true || err == nil {+ if ok || err == nil {return inflect.Ordinalize(word), nil
}
return inflect.Humanize(word), nil
--- a/tpl/template_resources.go
+++ b/tpl/template_resources.go
@@ -233,7 +233,7 @@
for i := 0; i <= resRetries; i++ {c, err := resGetResource(url)
- if err == nil && false == bytes.Contains(c, []byte(sep)) {+ if err == nil && !bytes.Contains(c, []byte(sep)) { err = errors.New("Cannot find separator " + sep + " in CSV.")}
--- a/tpl/template_resources_test.go
+++ b/tpl/template_resources_test.go
@@ -72,7 +72,7 @@
t.Errorf("Cache ignored but content is not nil: %s", string(c))}
} else {- if bytes.Compare(c, test.content) != 0 {+ if !bytes.Equal(c, test.content) { t.Errorf("\nExpected: %s\nActual: %s\n", string(test.content), string(c))}
}
@@ -104,7 +104,7 @@
if err != nil { t.Errorf("Error getting resource content: %s", err)}
- if bytes.Compare(c, test.content) != 0 {+ if !bytes.Equal(c, test.content) { t.Errorf("\nExpected: %s\nActual: %s\n", string(test.content), string(c))}
}
@@ -148,7 +148,7 @@
if err != nil { t.Errorf("Error getting resource content: %s", err)}
- if bytes.Compare(c, test.content) != 0 {+ if !bytes.Equal(c, test.content) { t.Errorf("\nNet Expected: %s\nNet Actual: %s\n", string(test.content), string(c))}
cc, cErr := resGetCache(test.path, fs, test.ignore)
@@ -160,7 +160,7 @@
t.Errorf("Cache ignored but content is not nil: %s", string(cc))}
} else {- if bytes.Compare(cc, test.content) != 0 {+ if !bytes.Equal(cc, test.content) { t.Errorf("\nCache Expected: %s\nCache Actual: %s\n", string(test.content), string(cc))}
}
--
⑨