Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Pluralize and singularize any word (golang adaptation ofhttps://www.npmjs.com/package/pluralize)

License

NotificationsYou must be signed in to change notification settings

gertd/go-pluralize

Repository files navigation

Build StatusGo Report CardGoDoc

Pluralize and singularize any word

Acknowledgements

The go-pluralize module is the Golang adaptation of the great work fromBlake Embrey and other contributors who created and maintain the NPM JavaScriptpluralize package.The originating Javascript implementation can be found onhttps://github.com/blakeembrey/pluralize

Without their great work this module would have taken a lot more effort,thank you all!

Version mapping

The latest go-pluralize version is compatible withpluralize version 8.0.0 commit#36f03cd

go-pluralize versionNPM Pluralize Package version
0.2.0 - Jan 25, 2022v0.2.08.0.0 - Oct 6, 2021#36f03cd
0.1.7 - Jun 23, 2020v0.1.78.0.0 - Mar 14, 2020#e507706
0.1.2 - Apr 1, 2020v0.1.28.0.0 - Mar 14, 2020#e507706
0.1.1 - Sep 15, 2019v0.1.18.0.0 - Aug 27, 2019#abb3991
0.1.0 - Jun 12, 2019v0.1.08.0.0 - May 24, 2019#0265e4d

Installation

To install the go module:

go get -u github.com/gertd/go-pluralize

To lock down a specific the version:

go get -u github.com/gertd/go-pluralize@v0.2.0

Download the sources and binaries from the latestrelease

Usage

Code

import pluralize "github.com/gertd/go-pluralize"word := "Empire"pluralize := pluralize.NewClient()fmt.Printf("IsPlural(%s)   => %t\n", input, pluralize.IsPlural(word))fmt.Printf("IsSingular(%s) => %t\n", input, pluralize.IsSingular(word))fmt.Printf("Plural(%s)     => %s\n", input, pluralize.Plural(word))fmt.Printf("Singular(%s)   => %s\n", input, pluralize.Singular(word))

Result

IsPlural(Empire)   => falseIsSingular(Empire) => truePlural(Empire)     => EmpiresSingular(Empire)   => Empire

Pluralize Command Line

Installation

go get -x github.com/gertd/go-pluralize/cmd/pluralize

Usage

Help

pluralize -helpUsage of ./bin/pluralize:  -cmd string        command [All|IsPlural|IsSingular|Plural|Singular] (default "All")  -version        display version info  -word string        input value

Word with All Commands

pluralize -word Empire IsPlural(Empire)   => falseIsSingular(Empire) => truePlural(Empire)     => EmpiresSingular(Empire)   => Empire

Is Word Plural?

pluralize -word Cactus -cmd IsPluralIsPlural(Cactus)   => false

Is Word Singular?

pluralize -word Cacti -cmd IsSingularIsSingular(Cacti)  => false

Word Make Plural

pluralize -word Cactus -cmd PluralPlural(Cactus)     => Cacti

Word Make Singular

pluralize -word Cacti -cmd SingularSingular(Cacti)    => Cactus

[8]ページ先頭

©2009-2025 Movatter.jp