README.md (4100B)
1 # go-pluralize 2 [](https://travis-ci.org/gertd/go-pluralize) 3 [](https://goreportcard.com/report/github.com/gertd/go-pluralize) 4 [](https://godoc.org/github.com/gertd/go-pluralize) 5 6 Pluralize and singularize any word 7 8 # Acknowledgements 9 > The go-pluralize module is the Golang adaptation of the great work from [Blake Embrey](https://www.npmjs.com/~blakeembrey) and other contributors who created and maintain the NPM JavaScript [pluralize](https://www.npmjs.com/package/pluralize) package. 10 > The originating Javascript implementation can be found on https://github.com/blakeembrey/pluralize 11 > 12 > Without their great work this module would have taken a lot more effort, **thank you all**! 13 14 # Version mapping 15 16 The latest go-pluralize version is compatible with [pluralize](https://www.npmjs.com/package/pluralize) version 8.0.0 commit [#36f03cd](https://github.com/blakeembrey/pluralize/commit/36f03cd2d573fa6d23e12e1529fa4627e2af74b4) 17 18 | go-pluralize version | NPM Pluralize Package version | 19 | ------------- | ------------- | 20 | 0.2.0 - Jan 25, 2022 [v0.2.0](https://github.com/gertd/go-pluralize/releases/tag/v0.2.0) | 8.0.0 - Oct 6, 2021 [#36f03cd](https://github.com/blakeembrey/pluralize/commit/36f03cd2d573fa6d23e12e1529fa4627e2af74b4) 21 | 0.1.7 - Jun 23, 2020 [v0.1.7](https://github.com/gertd/go-pluralize/releases/tag/v0.1.7) | 8.0.0 - Mar 14, 2020 [#e507706](https://github.com/blakeembrey/pluralize/commit/e507706be779612c06ebfd6043163e063e791d79) 22 | 0.1.2 - Apr 1, 2020 [v0.1.2](https://github.com/gertd/go-pluralize/releases/tag/v0.1.2) | 8.0.0 - Mar 14, 2020 [#e507706](https://github.com/blakeembrey/pluralize/commit/e507706be779612c06ebfd6043163e063e791d79) 23 | 0.1.1 - Sep 15, 2019 [v0.1.1](https://github.com/gertd/go-pluralize/releases/tag/v0.1.1) | 8.0.0 - Aug 27, 2019 [#abb3991](https://github.com/blakeembrey/pluralize/commit/abb399111aedd1d62dd418d7e0217d85f5bf22c9) 24 | 0.1.0 - Jun 12, 2019 [v0.1.0](https://github.com/gertd/go-pluralize/releases/tag/v0.1.0) | 8.0.0 - May 24, 2019 [#0265e4d](https://github.com/blakeembrey/pluralize/commit/0265e4d131ecad8e11c420fa4be98b75dc92c33d) 25 26 # Installation 27 28 To install the go module: 29 30 go get -u github.com/gertd/go-pluralize 31 32 To lock down a specific the version: 33 34 go get -u github.com/gertd/go-pluralize@v0.2.0 35 36 Download the sources and binaries from the latest [release](https://github.com/gertd/go-pluralize/releases/latest) 37 38 39 # Usage 40 41 ## Code 42 import pluralize "github.com/gertd/go-pluralize" 43 44 word := "Empire" 45 46 pluralize := pluralize.NewClient() 47 48 fmt.Printf("IsPlural(%s) => %t\n", input, pluralize.IsPlural(word)) 49 fmt.Printf("IsSingular(%s) => %t\n", input, pluralize.IsSingular(word)) 50 fmt.Printf("Plural(%s) => %s\n", input, pluralize.Plural(word)) 51 fmt.Printf("Singular(%s) => %s\n", input, pluralize.Singular(word)) 52 53 ## Result 54 IsPlural(Empire) => false 55 IsSingular(Empire) => true 56 Plural(Empire) => Empires 57 Singular(Empire) => Empire 58 59 60 # Pluralize Command Line 61 62 ## Installation 63 go get -x github.com/gertd/go-pluralize/cmd/pluralize 64 65 66 67 68 ## Usage 69 70 ### Help 71 pluralize -help 72 Usage of ./bin/pluralize: 73 -cmd string 74 command [All|IsPlural|IsSingular|Plural|Singular] (default "All") 75 -version 76 display version info 77 -word string 78 input value 79 80 ### Word with All Commands 81 pluralize -word Empire 82 83 IsPlural(Empire) => false 84 IsSingular(Empire) => true 85 Plural(Empire) => Empires 86 Singular(Empire) => Empire 87 88 ### Is Word Plural? 89 pluralize -word Cactus -cmd IsPlural 90 91 IsPlural(Cactus) => false 92 93 ### Is Word Singular? 94 pluralize -word Cacti -cmd IsSingular 95 96 IsSingular(Cacti) => false 97 98 ### Word Make Plural 99 pluralize -word Cactus -cmd Plural 100 101 Plural(Cactus) => Cacti 102 103 ### Word Make Singular 104 pluralize -word Cacti -cmd Singular 105 106 Singular(Cacti) => Cactus