inflect: github.com/go-openapi/inflect Index | Files

package inflect

import "github.com/go-openapi/inflect"

Index

Package Files

inflect.go

func AddAcronym Uses

func AddAcronym(word string)

func AddHuman Uses

func AddHuman(suffix, replacement string)

func AddIrregular Uses

func AddIrregular(singular, plural string)

func AddPlural Uses

func AddPlural(suffix, replacement string)

func AddSingular Uses

func AddSingular(suffix, replacement string)

func AddUncountable Uses

func AddUncountable(word string)

func Asciify Uses

func Asciify(word string) string

func Camelize Uses

func Camelize(word string) string

func CamelizeDownFirst Uses

func CamelizeDownFirst(word string) string

func Capitalize Uses

func Capitalize(word string) string

func Dasherize Uses

func Dasherize(word string) string

func ForeignKey Uses

func ForeignKey(word string) string

func ForeignKeyCondensed Uses

func ForeignKeyCondensed(word string) string

func Humanize Uses

func Humanize(word string) string

func Ordinalize Uses

func Ordinalize(word string) string

func Parameterize Uses

func Parameterize(word string) string

func ParameterizeJoin Uses

func ParameterizeJoin(word, sep string) string

func Pluralize Uses

func Pluralize(word string) string

func Singularize Uses

func Singularize(word string) string

func Tableize Uses

func Tableize(word string) string

func Titleize Uses

func Titleize(word string) string

func Typeify Uses

func Typeify(word string) string

func Uncountables Uses

func Uncountables() map[string]bool

func Underscore Uses

func Underscore(word string) string

type Rule Uses

type Rule struct {
    // contains filtered or unexported fields
}

used by rulesets

type Ruleset Uses

type Ruleset struct {
    // contains filtered or unexported fields
}

a Ruleset is the config of pluralization rules you can extend the rules with the Add* methods

func NewDefaultRuleset Uses

func NewDefaultRuleset() *Ruleset

create a new ruleset and load it with the default set of common English pluralization rules

func NewRuleset Uses

func NewRuleset() *Ruleset

create a blank ruleset. Unless you are going to build your own rules from scratch you probably won't need this and can just use the defaultRuleset via the global inflect.* methods

func (*Ruleset) AddAcronym Uses

func (rs *Ruleset) AddAcronym(word string)

if you use acronym you may need to add them to the ruleset to prevent Underscored words of things like "HTML" coming out as "h_t_m_l"

func (*Ruleset) AddHuman Uses

func (rs *Ruleset) AddHuman(suffix, replacement string)

Human rules are applied by humanize to show more friendly versions of words

func (*Ruleset) AddIrregular Uses

func (rs *Ruleset) AddIrregular(singular, plural string)

Add any inconsistant pluralizing/sinularizing rules to the set here.

func (*Ruleset) AddPlural Uses

func (rs *Ruleset) AddPlural(suffix, replacement string)

add a pluralization rule

func (*Ruleset) AddPluralExact Uses

func (rs *Ruleset) AddPluralExact(suffix, replacement string, exact bool)

add a pluralization rule with full string match

func (*Ruleset) AddSingular Uses

func (rs *Ruleset) AddSingular(suffix, replacement string)

add a singular rule

func (*Ruleset) AddSingularExact Uses

func (rs *Ruleset) AddSingularExact(suffix, replacement string, exact bool)

same as AddSingular but you can set `exact` to force a full string match

func (*Ruleset) AddUncountable Uses

func (rs *Ruleset) AddUncountable(word string)

add a word to this ruleset that has the same singular and plural form for example: "rice"

func (*Ruleset) Asciify Uses

func (rs *Ruleset) Asciify(word string) string

transforms latin characters like é -> e

func (*Ruleset) Camelize Uses

func (rs *Ruleset) Camelize(word string) string

"dino_party" -> "DinoParty"

func (*Ruleset) CamelizeDownFirst Uses

func (rs *Ruleset) CamelizeDownFirst(word string) string

same as Camelcase but with first letter downcased

func (*Ruleset) Capitalize Uses

func (rs *Ruleset) Capitalize(word string) string

uppercase first character

func (*Ruleset) Dasherize Uses

func (rs *Ruleset) Dasherize(word string) string

"SomeText" -> "some-text"

func (*Ruleset) ForeignKey Uses

func (rs *Ruleset) ForeignKey(word string) string

an underscored foreign key name "Person" -> "person_id"

func (*Ruleset) ForeignKeyCondensed Uses

func (rs *Ruleset) ForeignKeyCondensed(word string) string

a foreign key (with an underscore) "Person" -> "personid"

func (*Ruleset) Humanize Uses

func (rs *Ruleset) Humanize(word string) string

First letter of sentance captitilized Uses custom friendly replacements via AddHuman()

func (*Ruleset) Ordinalize Uses

func (rs *Ruleset) Ordinalize(str string) string

"1031" -> "1031st"

func (*Ruleset) Parameterize Uses

func (rs *Ruleset) Parameterize(word string) string

param safe dasherized names like "my-param"

func (*Ruleset) ParameterizeJoin Uses

func (rs *Ruleset) ParameterizeJoin(word, sep string) string

param safe dasherized names with custom seperator

func (*Ruleset) Pluralize Uses

func (rs *Ruleset) Pluralize(word string) string

returns the plural form of a singular word

func (*Ruleset) Singularize Uses

func (rs *Ruleset) Singularize(word string) string

returns the singular form of a plural word

func (*Ruleset) Tableize Uses

func (rs *Ruleset) Tableize(word string) string

Rails style pluralized table names: "SuperPerson" -> "super_people"

func (*Ruleset) Titleize Uses

func (rs *Ruleset) Titleize(word string) string

Captitilize every word in sentance "hello there" -> "Hello There"

func (*Ruleset) Typeify Uses

func (rs *Ruleset) Typeify(word string) string

"something_like_this" -> "SomethingLikeThis"

func (*Ruleset) Uncountables Uses

func (rs *Ruleset) Uncountables() map[string]bool

func (*Ruleset) Underscore Uses

func (rs *Ruleset) Underscore(word string) string

lowercase underscore version "BigBen" -> "big_ben"

Package inflect imports 6 packages (graph) and is imported by 21 packages. Updated 2018-10-08. Refresh now. Tools for package owners.