Go package providing English word inflection utilities -- pluralization, singularization, case conversion (CamelCase, underscore, dasherize, titleize), humanization, ordinalization, and URL parameterization. Modeled after Ruby on Rails' ActiveSupport::Inflector. Used in the go-swagger ecosystem to transform identifier names between API specifications and generated Go code.
| File | Contents |
|---|---|
inflect.go |
All types, rules, and inflection functions |
inflect_test.go |
Tests for all inflection functions |
Ruleset— configurable rule collection (plural, singular, human, acronym, uncountable)NewDefaultRuleset()— ruleset pre-loaded with common English rulesPluralize/Singularize— plural/singular conversionCamelize/CamelizeDownFirst/Underscore/Dasherize/Titleize— case conversionHumanize/Tableize/Typeify/ForeignKey/Ordinalize/Parameterize— specialized transformsAsciify— Latin character transliterationAddPlural,AddSingular,AddIrregular,AddUncountable,AddHuman,AddAcronym— extend rules
None -- standard library only.
- Suffix-based matching (not regexps) for simplicity and speed.
- Global default ruleset via
init()with top-level convenience functions. - Acronym-safe case conversion via
AddAcronym().
Coding conventions are found beneath .github/copilot
- All
.gofiles must have SPDX license headers (Apache-2.0). - Commits require DCO sign-off (
git commit -s). - Linting:
golangci-lint run— config in.golangci.yml(posture:default: allwith explicit disables). - Every
//nolintdirective must have an inline comment explaining why. - Tests:
go test ./.... CI runs on{ubuntu, macos, windows} x {stable, oldstable}with-race. - Test framework:
github.com/go-openapi/testify/v2(notstretchr/testify;testifylintdoes not work).
See .github/copilot/ (symlinked to .claude/rules/) for detailed rules on Go conventions, linting, testing, and contributions.