diff --git a/file_result.go b/file_result.go index f9cdf9e..322db90 100644 --- a/file_result.go +++ b/file_result.go @@ -17,7 +17,7 @@ func (r fileResult) String(verbose bool) string { ss := make([]string, 0, len(r.urlResults)) if r.err != nil { - ss = append(ss, indent(color.RedString(r.err.Error()))) + ss = append(ss, indent(color.RedString(capitalizeFirst(r.err.Error())))) } os := make([]string, 0, len(r.urlResults)) diff --git a/main.go b/main.go index 55f9b75..d23708c 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,6 @@ package main import ( "fmt" "os" - "strings" "sync" "github.com/fatih/color" @@ -59,7 +58,6 @@ func printToStderr(xs ...interface{}) { } func fail(err error) { - s := err.Error() - printToStderr(color.RedString(strings.ToUpper(s[:1]) + s[1:])) + printToStderr(color.RedString(capitalizeFirst(err.Error()))) os.Exit(1) } diff --git a/utils.go b/utils.go index 5c4e211..1cd62e3 100644 --- a/utils.go +++ b/utils.go @@ -1,6 +1,10 @@ package main -import "github.com/kr/text" +import ( + "strings" + + "github.com/kr/text" +) func stringSetToSlice(s2b map[string]bool) []string { ss := make([]string, 0, len(s2b)) @@ -15,3 +19,7 @@ func stringSetToSlice(s2b map[string]bool) []string { func indent(s string) string { return text.Indent(s, "\t") } + +func capitalizeFirst(s string) string { + return strings.ToUpper(s[:1]) + s[1:] +} diff --git a/utils_test.go b/utils_test.go index 2128846..8c2401c 100644 --- a/utils_test.go +++ b/utils_test.go @@ -25,3 +25,12 @@ func TestIndent(t *testing.T) { assert.Equal(t, c.target, indent(c.source)) } } + +func TestCapitalizeFirst(t *testing.T) { + for _, ss := range [][2]string{ + {"foo", "Foo"}, + {"foo bar", "Foo bar"}, + } { + assert.Equal(t, ss[1], capitalizeFirst(ss[0])) + } +}