package inflect
import "github.com/markbates/inflect"
Index ¶
- Constants
- Variables
- func AddAcronym(word string)
- func AddHuman(suffix, replacement string)
- func AddIrregular(singular, plural string)
- func AddPlural(suffix, replacement string)
- func AddSingular(suffix, replacement string)
- func AddUncountable(word string)
- func Asciify(word string) string
- func Camelize(word string) string
- func CamelizeDownFirst(word string) string
- func Capitalize(word string) string
- func Dasherize(word string) string
- func ForeignKey(word string) string
- func ForeignKeyCondensed(word string) string
- func ForeignKeyToAttribute(word string) string
- func Humanize(word string) string
- func LoadReader(r io.Reader) error
- func Ordinalize(word string) string
- func Parameterize(word string) string
- func ParameterizeJoin(word, sep string) string
- func Pluralize(word string) string
- func PluralizeWithSize(word string, size int) string
- func Singularize(word string) string
- func Tableize(word string) string
- func Titleize(word string) string
- func Typeify(word string) string
- func Uncountables() map[string]bool
- func Underscore(word string) string
- type Name
- func (n Name) Camel() string
- func (n Name) CamelSingular() string
- func (n Name) Char() string
- func (n Name) File() string
- func (n Name) Lower() string
- func (n Name) Model() string
- func (n Name) ModelPlural() string
- func (n Name) Package() string
- func (n Name) ParamID() string
- func (n Name) Plural() string
- func (n Name) PluralCamel() string
- func (n Name) PluralUnder() string
- func (n Name) Resource() string
- func (n Name) Singular() string
- func (n Name) String() string
- func (n Name) Table() string
- func (n Name) Title() string
- func (n Name) URL() string
- func (n Name) UnderSingular() string
- func (n Name) Underscore() string
- func (n Name) VarCasePlural() string
- func (n Name) VarCaseSingular() string
- type Rule
- type Ruleset
- func NewDefaultRuleset() *Ruleset
- func NewRuleset() *Ruleset
- func (rs *Ruleset) AddAcronym(word string)
- func (rs *Ruleset) AddHuman(suffix, replacement string)
- func (rs *Ruleset) AddIrregular(singular, plural string)
- func (rs *Ruleset) AddPlural(suffix, replacement string)
- func (rs *Ruleset) AddPluralExact(suffix, replacement string, exact bool)
- func (rs *Ruleset) AddSingular(suffix, replacement string)
- func (rs *Ruleset) AddSingularExact(suffix, replacement string, exact bool)
- func (rs *Ruleset) AddUncountable(word string)
- func (rs *Ruleset) Asciify(word string) string
- func (rs *Ruleset) Camelize(word string) string
- func (rs *Ruleset) CamelizeDownFirst(word string) string
- func (rs *Ruleset) Capitalize(word string) string
- func (rs *Ruleset) Dasherize(word string) string
- func (rs *Ruleset) ForeignKey(word string) string
- func (rs *Ruleset) ForeignKeyCondensed(word string) string
- func (rs *Ruleset) ForeignKeyToAttribute(str string) string
- func (rs *Ruleset) Humanize(word string) string
- func (rs *Ruleset) LoadReader(r io.Reader) error
- func (rs *Ruleset) Ordinalize(str string) string
- func (rs *Ruleset) Parameterize(word string) string
- func (rs *Ruleset) ParameterizeJoin(word, sep string) string
- func (rs *Ruleset) Pluralize(word string) string
- func (rs *Ruleset) PluralizeWithSize(word string, size int) string
- func (rs *Ruleset) Singularize(word string) string
- func (rs *Ruleset) Tableize(word string) string
- func (rs *Ruleset) Titleize(word string) string
- func (rs *Ruleset) Typeify(word string) string
- func (rs *Ruleset) Uncountables() map[string]bool
- func (rs *Ruleset) Underscore(word string) string
Constants ¶
const Version = "v1.0.4"
Variables ¶
var Helpers = map[string]interface{}{ "asciffy": Asciify, "camelize": Camelize, "camelize_down_first": CamelizeDownFirst, "capitalize": Capitalize, "dasherize": Dasherize, "humanize": Humanize, "ordinalize": Ordinalize, "parameterize": Parameterize, "pluralize": Pluralize, "pluralize_with_size": PluralizeWithSize, "singularize": Singularize, "tableize": Tableize, "typeify": Typeify, "underscore": Underscore, }
Helpers is a map of the helper names with its corresponding inflect function
Functions ¶
func AddAcronym ¶
func AddAcronym(word string)
func AddHuman ¶
func AddHuman(suffix, replacement string)
AddHuman adds human
func AddIrregular ¶
func AddIrregular(singular, plural string)
func AddPlural ¶
func AddPlural(suffix, replacement string)
AddPlural adds plural to the ruleset
func AddSingular ¶
func AddSingular(suffix, replacement string)
AddSingular adds singular to the ruleset
func AddUncountable ¶
func AddUncountable(word string)
func Asciify ¶
func Camelize ¶
func CamelizeDownFirst ¶
func Capitalize ¶
func Dasherize ¶
func ForeignKey ¶
func ForeignKeyCondensed ¶
func ForeignKeyToAttribute ¶
func Humanize ¶
func LoadReader ¶
LoadReader loads rules from io.Reader param
func Ordinalize ¶
func Parameterize ¶
func ParameterizeJoin ¶
func Pluralize ¶
func PluralizeWithSize ¶
func Singularize ¶
func Tableize ¶
func Titleize ¶
func Typeify ¶
func Uncountables ¶
Uncountables returns a list of uncountables rules
func Underscore ¶
Types ¶
type Name ¶
type Name string
Name is a string that represents the "name" of a thing, like an app, model, etc...
func (Name) Camel ¶
Camel version of a name
func (Name) CamelSingular ¶
CamelSingular version of a name
func (Name) Char ¶
Char returns first character in lower case, this is useful for methods inside a struct.
func (Name) File ¶
File version of a name
func (Name) Lower ¶
Lower case version of a string
func (Name) Model ¶
Model version of a name. ie. "user" => "User"
func (Name) ModelPlural ¶
ModelPlural version of a name. ie. "user" => "Users"
func (Name) Package ¶
Package returns go package
func (Name) ParamID ¶
ParamID returns foo_bar_id
func (Name) Plural ¶
Plural version of a name
func (Name) PluralCamel ¶
PluralCamel version of a name
func (Name) PluralUnder ¶
PluralUnder version of a name
func (Name) Resource ¶
Resource version of a name
func (Name) Singular ¶
Singular version of a name
func (Name) String ¶
func (Name) Table ¶
Table version of a name
func (Name) Title ¶
Title version of a name. ie. "foo_bar" => "Foo Bar"
func (Name) URL ¶
URL version of a name
func (Name) UnderSingular ¶
UnderSingular version of a name
func (Name) Underscore ¶
Underscore version of a name. ie. "FooBar" => "foo_bar"
func (Name) VarCasePlural ¶
VarCasePlural version of a name. ie. "FooBar" => "fooBar"
func (Name) VarCaseSingular ¶
VarCaseSingular version of a name. ie. "FooBar" => "fooBar"
type Rule ¶
type Rule struct {
// contains filtered or unexported fields
}
Rule used by rulesets
type Ruleset ¶
type Ruleset struct {
// contains filtered or unexported fields
}
Ruleset a Ruleset is the config of pluralization rules you can extend the rules with the Add* methods
func NewDefaultRuleset ¶
func NewDefaultRuleset() *Ruleset
NewDefaultRuleset creates a new ruleset and load it with the default set of common English pluralization rules
func NewRuleset ¶
func NewRuleset() *Ruleset
NewRuleset creates 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 ¶
AddAcronym 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 ¶
AddHuman Human rules are applied by humanize to show more friendly versions of words
func (*Ruleset) AddIrregular ¶
AddIrregular Add any inconsistent pluralizing/singularizing rules to the set here.
func (*Ruleset) AddPlural ¶
AddPlural add a pluralization rule
func (*Ruleset) AddPluralExact ¶
AddPluralExact add a pluralization rule with full string match
func (*Ruleset) AddSingular ¶
AddSingular add a singular rule
func (*Ruleset) AddSingularExact ¶
AddSingularExact same as AddSingular but you can set `exact` to force a full string match
func (*Ruleset) AddUncountable ¶
AddUncountable add a word to this ruleset that has the same singular and plural form for example: "rice"
func (*Ruleset) Asciify ¶
Asciify transforms Latin characters like é -> e
func (*Ruleset) Camelize ¶
Camelize "dino_party" -> "DinoParty"
func (*Ruleset) CamelizeDownFirst ¶
CamelizeDownFirst same as Camelcase but with first letter downcased
func (*Ruleset) Capitalize ¶
Capitalize uppercase first character
func (*Ruleset) Dasherize ¶
Dasherize "SomeText" -> "some-text"
func (*Ruleset) ForeignKey ¶
ForeignKey an underscored foreign key name "Person" -> "person_id"
func (*Ruleset) ForeignKeyCondensed ¶
ForeignKeyCondensed a foreign key (with an underscore) "Person" -> "personid"
func (*Ruleset) ForeignKeyToAttribute ¶
ForeignKeyToAttribute returns the attribute name from the foreign key
func (*Ruleset) Humanize ¶
Humanize First letter of sentence capitalized Uses custom friendly replacements via AddHuman()
func (*Ruleset) LoadReader ¶
LoadReader loads rules from io.Reader param
func (*Ruleset) Ordinalize ¶
Ordinalize "1031" -> "1031st"
func (*Ruleset) Parameterize ¶
Parameterize param safe dasherized names like "my-param"
func (*Ruleset) ParameterizeJoin ¶
ParameterizeJoin param safe dasherized names with custom separator
func (*Ruleset) Pluralize ¶
Pluralize returns the plural form of a singular word
func (*Ruleset) PluralizeWithSize ¶
PluralizeWithSize pluralize with taking number into account
func (*Ruleset) Singularize ¶
Singularize returns the singular form of a plural word
func (*Ruleset) Tableize ¶
Tableize Rails style pluralized table names: "SuperPerson" -> "super_people"
func (*Ruleset) Titleize ¶
Titleize Capitalize every word in sentence "hello there" -> "Hello There"
func (*Ruleset) Typeify ¶
Typeify "something_like_this" -> "SomethingLikeThis"
func (*Ruleset) Uncountables ¶
Uncountables returns a map of uncountables in the ruleset
func (*Ruleset) Underscore ¶
Underscore lowercase underscore version "BigBen" -> "big_ben"
Source Files ¶
helpers.go inflect.go name.go version.go
- Version
- v1.0.4 (latest)
- Published
- Oct 24, 2018
- Platform
- js/wasm
- Imports
- 13 packages
- Last checked
- now –
Tools for package owners.