Skip to content

Latest commit

 

History

History

grammar

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

grammar

Pluralize

import "github.com/northwood-labs/golang-utils/grammar"

func main() {
    results := DatabaseThing()

    fmt.Printf(
        "There were %d %s.\n",
        results.NumberOfResults,
        grammar.Pluralize(results.NumberOfResults, "result", "results")
    )
}

Based on the count of whatever the thing is, you can pass a singular and plural version of a string so that you can maintain proper grammar in your application.

No more “There were 1 results.”