strings

package module
v0.0.0-...-e1130b3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 1 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnglishJoin

func EnglishJoin(words []string, oxfordComma bool) string

EnglishJoin joins a slice of strings with commas and the "and" conjugation before the final item. The Oxford comma can optionally be applied.

Example:

str := EnglishJoin([]string{"meow", "purr", "raow"}, true)
fmt.Println(str) // meow, purr, and raow

func SpokenLanguageJoin

func SpokenLanguageJoin(words []string, language Language) string

SpokenLangaugeJoin joins a slice of strings with commas and a conjuction before the final item. You may specify the language with Language.

If you are using English and need the Oxford Comma, use EnglishJoin.

Example:

str := SpokenLanguageJoin([]string{"eins", "zwei", "drei"}, DE)
fmt.Println(str) // eins, zwei und drei

Types

type Language

type Language int

Language is a spoken Language.

const (
	DE Language = iota
	DK
	EN
	ES
	FR
	IT
	NO
	PT
	SE
)

Available spoken lanaguges.

func (Language) String

func (l Language) String() string

String returns the English name of the Language code.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL