tpl: Simplify

This commit is contained in:
Bjørn Erik Pedersen 2016-11-23 18:53:50 +01:00
parent a721fbed1d
commit 139585f84a
3 changed files with 7 additions and 7 deletions

View file

@ -1593,7 +1593,7 @@ func dfault(dflt interface{}, given ...interface{}) (interface{}, error) {
// 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 @@ func humanize(in interface{}) (string, error) {
_, 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

View file

@ -233,7 +233,7 @@ func getCSV(sep string, urlParts ...string) [][]string {
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.")
}

View file

@ -72,7 +72,7 @@ func TestScpCache(t *testing.T) {
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 @@ func TestScpGetLocal(t *testing.T) {
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 @@ func TestScpGetRemote(t *testing.T) {
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 @@ func TestScpGetRemote(t *testing.T) {
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))
}
}