Help us shape the future of Go! Take the 2026 Go Developer Survey

inflect

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package inflect defines the naming pipeline shared by every product: an open Kind, the Input a naming hook receives, the Next continuation, and the pure string helpers (camel casing, singular/plural, enum value names). Each product declares its own Kind constants and default inflector on top.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ByColumns

func ByColumns(cols []string) string

ByColumns joins UpperCamel column names with "And" (the "ById", "ByEmailAndTenant" suffix used by key-based names).

func EnumValue

func EnumValue(s string) string

EnumValue converts a Postgres enum label to an UPPER_SNAKE enum value name.

func LowerCamel

func LowerCamel(s string) string

LowerCamel converts snake_case to lowerCamelCase.

func Pluralize

func Pluralize(s string) string

Pluralize applies simple English pluralization rules.

func Singularize

func Singularize(s string) string

Singularize applies simple English singularization rules — enough for common table names; plugins can override anything it gets wrong.

func UpperCamel

func UpperCamel(s string) string

UpperCamel converts snake_case to UpperCamelCase.

Types

type Input

type Input struct {
	Schema     string   // pg schema name
	Table      string   // pg table/view name
	Column     string   // pg column name (when applicable)
	Columns    []string // multi-column keys
	Constraint string   // pg constraint name backing the name (relation kinds)
	Function   string   // pg function name (when applicable)
	Enum       string   // pg enum type name
	Value      string   // enum value
	IsList     bool
}

Input carries everything a hook may need to build a name.

type Kind

type Kind string

Kind identifies which name is being generated. It is an open string type: each product defines its constants, so InflectionHook plugins compile against this package alone.

type Next

type Next func(kind Kind, in Input) string

Next continues the chain; the last Next is the product's default inflector.

Jump to

Keyboard shortcuts

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