inflector

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 11, 2021 License: BSD-2-Clause Imports: 5 Imported by: 18

README

inflector Go Package

Package inflector pluralizes and singularizes English nouns.

Basic Usage

There are only two exported functions: Pluralize and Singularize.

inflector.Singularize("People") // returns "Person"
inflector.Pluralize("octopus") // returns "octopuses"

Documentation

Overview

Package inflector pluralizes and singularizes English nouns. There are only two exported functions: `Pluralize` and `Singularize`.

Example:

inflector.Singularize("People") // returns "Person"

inflector.Pluralize("octopus) // returns "octopuses"

Index

Examples

Constants

View Source
const (
	RulePlural = iota
	RuleSingular
)

Rule values.

Variables

This section is empty.

Functions

func Pluralize

func Pluralize(s string) string

Pluralize returns string s in plural form.

Example
package main

import (
	"fmt"

	"github.com/kenshaw/inflector"
)

func main() {
	fmt.Println(inflector.Pluralize("octopus"))
}
Output:

octopuses

func Singularize

func Singularize(s string) string

Singularize returns string s in singular form.

Example
package main

import (
	"fmt"

	"github.com/kenshaw/inflector"
)

func main() {
	fmt.Println(inflector.Singularize("People"))
}
Output:

Person

Types

type InflectorRule

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

InflectorRule represents an inflector rule.

type Rule

type Rule int

Rule is the inflector rule type (plural or singular).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL