strutil: return empty string for empty items in string join (#17)
Signed-off-by: Greg Osuri <me@gregosuri.com>
Greg Osuri authored 4 years ago
GitHub committed 4 years ago
70 | 70 | return s |
71 | 71 | } |
72 | 72 | |
73 | // Join joins the list of the string with the delim provided | |
73 | // Join joins the list of the string with the delim provided. | |
74 | // Returns an empty string for empty list | |
74 | 75 | func Join(list []string, delim string) string { |
76 | if len(list) == 0 { | |
77 | return "" | |
78 | } | |
75 | 79 | var buf bytes.Buffer |
76 | 80 | for i := 0; i < len(list)-1; i++ { |
77 | 81 | buf.WriteString(list[i] + delim) |