package inflection
Import Path
github.com/jinzhu/inflection (on go.dev)
Dependency Relation
imports 2 packages, and imported by one package
Involved Source Files
Package inflection pluralizes and singularizes English nouns.
inflection.Plural("person") => "people"
inflection.Plural("Person") => "People"
inflection.Plural("PERSON") => "PEOPLE"
inflection.Singular("people") => "person"
inflection.Singular("People") => "Person"
inflection.Singular("PEOPLE") => "PERSON"
inflection.Plural("FancyPerson") => "FancydPeople"
inflection.Singular("FancyPeople") => "FancydPerson"
Standard rules are from Rails's ActiveSupport (https://github.com/rails/rails/blob/master/activesupport/lib/active_support/inflections.rb)
If you want to register more rules, follow:
inflection.AddUncountable("fish")
inflection.AddIrregular("person", "people")
inflection.AddPlural("(bu)s$", "${1}ses") # "bus" => "buses" / "BUS" => "BUSES" / "Bus" => "Buses"
inflection.AddSingular("(bus)(es)?$", "${1}") # "buses" => "bus" / "Buses" => "Bus" / "BUSES" => "BUS"
Package-Level Type Names (total 5, in which 4 are exported)
Irregular is a hard replace inflection,
containing both singular and plural forms
plural string
singular string
IrregularSlice is a slice of Irregular inflections
func GetIrregular() IrregularSlice
func SetIrregular(inflections IrregularSlice)
var irregularInflections
RegularSlice is a slice of Regular inflections
func GetPlural() RegularSlice
func GetSingular() RegularSlice
func SetPlural(inflections RegularSlice)
func SetSingular(inflections RegularSlice)
var pluralInflections
var singularInflections
Package-Level Functions (total 16, in which 14 are exported)
AddIrregular adds an irregular inflection
AddPlural adds a plural inflection
AddSingular adds a singular inflection
AddUncountable adds an uncountable inflection
GetIrregular retrieves the irregular inflection values
GetPlural retrieves the plural inflection values
GetSingular retrieves the singular inflection values
GetUncountable retrieves the uncountable inflection values
Plural converts a word to its plural form
SetIrregular sets the irregular inflections slice
SetPlural sets the plural inflections slice
SetSingular sets the singular inflections slice
SetUncountable sets the uncountable inflections slice
Singular converts a word to its singular form
Package-Level Variables (total 6, none are exported)
The pages are generated with Golds v0.4.9. (GOOS=linux GOARCH=amd64)