Provides functions for joining lists into natural language strings.
func And
func And(list []string) string
And joins the last 2 elements of a list with " and ", while joining preceding elements with a comma.
list := []string{"one", "two"}
fmt.Println(And(list)) // "one and two"
list = []string{"one", "two", "three"}
fmt.Println(And(list)) // "one, two and three"
func Arbitrary
func Arbitrary(wordSeparator string, conjunction string, list []string) string
Arbitrary joins the last 2 elements of a list with the supplied conjunction, while joining preceding elements with the supplied word separator. Note that you'll need to provide your own padding for both the word separator and the conjunction.
list := []string{"eins", "zwei", "drei"}
fmt.Println(Arbitrary(", ", " und ", list)) // "eins, zwei und drei"
func Or
func Or(list []string) string
Or joins the last 2 elements of a list with " or ", while joining preceding elements with a comma.
list := []string{"one", "two"}
fmt.Println(Or(list)) // "one or two"
list = []string{"one", "two", "three"}
fmt.Println(Or(list)) // "one, two or three"
Readme created from Go doc with goreadme