17 lines
293 B
Go
17 lines
293 B
Go
package chat
|
|
|
|
import "strings"
|
|
|
|
func humanJoin(items []string) string {
|
|
count := len(items)
|
|
switch count {
|
|
case 0:
|
|
return ""
|
|
case 1:
|
|
return items[0]
|
|
case 2:
|
|
return items[0] + " and " + items[1]
|
|
default:
|
|
return strings.Join(items[:count-1], ", ") + ", and " + items[count-1]
|
|
}
|
|
}
|