Documentation ¶
Overview ¶
Package flect is a new inflection engine to replace [https://github.com/markbates/inflect](https://github.com/markbates/inflect) designed to be more modular, more readable, and easier to fix issues on than the original.
Index ¶
- Constants
- func AddPlural(suffix string, repl string)
- func AddSingular(ext string, repl string)
- func Camelize(s string) string
- func Capitalize(s string) string
- func Dasherize(s string) string
- func Humanize(s string) string
- func LoadAcronyms(r io.Reader) error
- func LoadInflections(r io.Reader) error
- func Ordinalize(s string) string
- func Pascalize(s string) string
- func Pluralize(s string) string
- func Singularize(s string) string
- func Titleize(s string) string
- func Underscore(s string) string
- type CustomDataParser
- type Ident
- func (i Ident) Camelize() Ident
- func (i Ident) Capitalize() Ident
- func (i Ident) Dasherize() Ident
- func (i Ident) Humanize() Ident
- func (i Ident) MarshalText() ([]byte, error)
- func (i Ident) Ordinalize() Ident
- func (i Ident) Pascalize() Ident
- func (i Ident) Pluralize() Ident
- func (i Ident) Singularize() Ident
- func (i Ident) String() string
- func (i Ident) Titleize() Ident
- func (i Ident) ToLower() Ident
- func (i Ident) ToUpper() Ident
- func (i Ident) Underscore() Ident
- func (i *Ident) UnmarshalText(data []byte) error
Constants ¶
const Version = "v0.1.6"
Version holds Flect version number
Variables ¶
This section is empty.
Functions ¶
func AddPlural ¶
AddPlural adds a rule that will replace the given suffix with the replacement suffix.
func AddSingular ¶
AddSingular adds a rule that will replace the given suffix with the replacement suffix.
func Camelize ¶
Camelize returns a camelize version of a string
bob dylan = bobDylan widget_id = widgetID WidgetID = widgetID
func Capitalize ¶
Capitalize will cap the first letter of string
user = User bob dylan = Bob dylan widget_id = Widget_id
func Dasherize ¶
Dasherize returns an alphanumeric, lowercased, dashed string
Donald E. Knuth = donald-e-knuth Test with + sign = test-with-sign admin/WidgetID = admin-widget-id
func Humanize ¶
Humanize returns first letter of sentence capitalized employee_salary = Employee salary employee_id = employee ID employee_mobile_number = Employee mobile number
func LoadAcronyms ¶
LoadAcronyms loads rules from io.Reader param
func LoadInflections ¶
LoadInflections loads rules from io.Reader param
func Pascalize ¶
Pascalize returns a string with each segment capitalized
user = User bob dylan = BobDylan widget_id = WidgetID
func Pluralize ¶
Pluralize returns a plural version of the string
user = users person = people datum = data
func Singularize ¶
Singularize returns a singular version of the string
users = user data = datum people = person
func Titleize ¶
Titleize will capitalize the start of each part
"Nice to see you!" = "Nice To See You!" "i've read a book! have you?" = "I've Read A Book! Have You?" "This is `code` ok" = "This Is `code` OK"
func Underscore ¶
Underscore a string
bob dylan = bob_dylan Nice to see you! = nice_to_see_you widgetID = widget_id
Types ¶
type CustomDataParser ¶
CustomDataParser are functions that parse data like acronyms or plurals in the shape of a io.Reader it receives.
type Ident ¶
Ident represents the string and it's parts
func (Ident) Camelize ¶
Camelize returns a camelize version of a string
bob dylan = bobDylan widget_id = widgetID WidgetID = widgetID
func (Ident) Capitalize ¶
Capitalize will cap the first letter of string
user = User bob dylan = Bob dylan widget_id = Widget_id
func (Ident) Dasherize ¶
Dasherize returns an alphanumeric, lowercased, dashed string
Donald E. Knuth = donald-e-knuth Test with + sign = test-with-sign admin/WidgetID = admin-widget-id
func (Ident) MarshalText ¶
MarshalText marshals Ident into byte array
func (Ident) Ordinalize ¶
Ordinalize converts a number to an ordinal version
42 = 42nd 45 = 45th 1 = 1st
func (Ident) Pascalize ¶
Pascalize returns a string with each segment capitalized
user = User bob dylan = BobDylan widget_id = WidgetID
func (Ident) Pluralize ¶
Pluralize returns a plural version of the string
user = users person = people datum = data
func (Ident) Singularize ¶
Singularize returns a singular version of the string
users = user data = datum people = person
func (Ident) Titleize ¶
Titleize will capitalize the start of each part
"Nice to see you!" = "Nice To See You!" "i've read a book! have you?" = "I've Read A Book! Have You?" "This is `code` ok" = "This Is `code` OK"
func (Ident) Underscore ¶
Underscore a string
bob dylan = bob_dylan Nice to see you! = nice_to_see_you widgetID = widget_id
func (*Ident) UnmarshalText ¶
UnmarshalText unmarshalls byte array into the Ident