Skip to content

Commit

Permalink
Extend ToStrs() to support ints or strings
Browse files Browse the repository at this point in the history
  • Loading branch information
senorprogrammer committed May 13, 2019
1 parent 5620db2 commit f7b69fa
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion wtf/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"os/exec"
"regexp"
"runtime"
"strconv"
"strings"

"github.com/wtfutil/wtf/utils"
Expand Down Expand Up @@ -149,7 +150,12 @@ func ToStrs(slice []interface{}) []string {
results := []string{}

for _, val := range slice {
results = append(results, fmt.Sprintf("%v", val))
switch val.(type) {
case int:
results = append(results, strconv.Itoa(val.(int)))
case string:
results = append(results, val.(string))
}
}

return results
Expand Down

0 comments on commit f7b69fa

Please sign in to comment.