Help us shape the future of Go! Take the 2026 Go Developer Survey

english_conjoin

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 2 Imported by: 0

README

English ConjoinBuild Status GoDoc

A little Go util to print lists of strings in common English format

Docs

The Conjoin function takes a slice of strings and a final joiner.

Usage

package main

import (
	"fmt"
	"github.com/davidbanham/english_conjoin"
)

func main() {
	example := []string{"Alice", "Bob", "Charlie"}

	fmt.Println(english_conjoin.Conjoin(example, "and")) // Alice, Bob and Charlie
	fmt.Println(english_conjoin.Conjoin(example, "or"))  // Alice, Bob or Charlie

	dupeExample := []string{"Milk", "Flour", "Eggs", "Rice", "Flour", "Rice", "Rice"}

	fmt.Println(english_conjoin.DeDuplicate(dupeExample))  // Milk, Flour (x2), Eggs, Rice (x3)
}

There are also some helper funcs for common joiners: ConjoinAnd and ConjoinOr

There are more examples in the tests.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AorAn added in v1.0.2

func AorAn(input string) string

func AorAnUpper added in v1.0.2

func AorAnUpper(input string) string

func Conjoin

func Conjoin(input []string, joiner string) string

func ConjoinAnd

func ConjoinAnd(items []string) string

func ConjoinOr

func ConjoinOr(items []string) string

func DeDuplicate

func DeDuplicate(input []string) []string

Types

This section is empty.

Jump to

Keyboard shortcuts

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