inflector: github.com/gedex/inflector Index | Examples | Files

package inflector

import "github.com/gedex/inflector"

Package inflector pluralizes and singularizes English nouns.

There are only two exported functions: `Pluralize` and `Singularize`.

s := "People"
fmt.Println(inflector.Singularize(s)) // will print "Person"

s2 := "octopus"
fmt.Println(inflector.Pluralize(s2)) // will print "octopuses"

Index

Examples

Package Files

inflector.go

Constants

const (
    Plural = iota
    Singular
)

func Pluralize Uses

func Pluralize(s string) string

Pluralize returns string s in plural form.

Code:

fmt.Println(inflector.Pluralize("octopus"))

Output:

octopuses

func Singularize Uses

func Singularize(s string) string

Singularize returns string s in singular form.

Code:

fmt.Println(inflector.Singularize("People"))

Output:

Person

type InflectorRule Uses

type InflectorRule struct {
    Rules       []*ruleItem
    Irregular   []*irregularItem
    Uninflected []string
    // contains filtered or unexported fields
}

InflectorRule represents inflector rule

type Rule Uses

type Rule int

Rule represents name of the inflector rule, can be Plural or Singular

Package inflector imports 5 packages (graph) and is imported by 92 packages. Updated 2017-03-15. Refresh now. Tools for package owners.