naming

package
v1.2.15 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package naming transforms resource, identifier, and database names.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capitalize

func Capitalize(s string) string

Capitalize performs capitalize.

func ControllerPackageName added in v1.0.0

func ControllerPackageName(namespace string) string

ControllerPackageName returns the package name for a controller file given an optional namespace. Empty namespace yields "controllers".

func DeriveResourceName added in v1.0.0

func DeriveResourceName(tableName string) string

DeriveResourceName converts a snake_case plural table name into a PascalCase singular resource name. Examples: "user_roles" -> "UserRole", "products" -> "Product", "admin_users" -> "AdminUser"

func DeriveTableName

func DeriveTableName(resourceName string) string

DeriveTableName converts a CamelCase resource name into a snake_case plural table name.

func IsValidNamespace added in v1.0.0

func IsValidNamespace(namespace string) bool

IsValidNamespace validates that a namespace is a valid Go package name and not a reserved path.

func NamespaceFilePrefix added in v1.0.0

func NamespaceFilePrefix(namespace string) string

NamespaceFilePrefix converts a slash-separated namespace path into the file prefix used for same-package generated artifacts such as route and view files.

func NamespaceFromResource added in v1.0.0

func NamespaceFromResource(resourceName string) (namespace, name string)

NamespaceFromResource splits a namespaced resource name into its namespace and resource name parts. Invalid namespaced input is returned as an unnamespaced resource for backward-compatible callers that cannot surface an error; command paths should use ParseNamespacedResource.

func NamespaceRouteName added in v1.0.0

func NamespaceRouteName(namespace string) string

NamespaceRouteName converts a slash-separated namespace path into a dotted route-name prefix.

func NamespaceToPascal added in v1.0.0

func NamespaceToPascal(namespace string) string

NamespaceToPascal converts a slash-separated namespace path into a PascalCase prefix suitable for route variables and generated view symbols.

func NamespacedControllerImportPath added in v1.0.0

func NamespacedControllerImportPath(modulePath, namespace string) string

NamespacedControllerImportPath returns the import path for a controller package, optionally namespaced.

func ParseNamespacedResource added in v1.0.0

func ParseNamespacedResource(input string) (namespace, resource string, err error)

ParseNamespacedResource splits a resource name into an optional single-level namespace and resource name. Namespaces are intentionally lower-case Go package names; resource names remain the original PascalCase generator input.

func ToCamelCase

func ToCamelCase(s string) string

ToCamelCase converts a snake_case identifier into camelCase. Examples: "admin_users" -> "adminUsers", "product_categories" -> "productCategories"

func ToKebabCase added in v1.0.0

func ToKebabCase(s string) string

ToKebabCase converts a snake_case identifier into kebab-case.

func ToLowerCamelCase

func ToLowerCamelCase(s string) string

ToLowerCamelCase converts a PascalCase identifier into camelCase by lowercasing the first character. Examples: "NewUser" -> "newUser", "AdminUser" -> "adminUser", "User" -> "user"

func ToLowerCamelCaseFromAny added in v1.0.0

func ToLowerCamelCaseFromAny(s string) string

ToLowerCamelCaseFromAny converts snake_case or PascalCase into lower camelCase. It preserves existing camelCase inputs by only lowercasing the first character when there are no underscores.

func ToPascalCase added in v1.0.0

func ToPascalCase(s string) string

ToPascalCase converts a snake_case identifier into PascalCase. Examples: "admin_users" -> "AdminUsers", "product_categories" -> "ProductCategories"

func ToReceiverName added in v1.0.0

func ToReceiverName(s string) string

ToReceiverName generates a short receiver name from a PascalCase identifier by extracting and lowercasing all uppercase letters. Examples: "StudentFeedback" -> "sf", "Product" -> "p", "UserRole" -> "ur"

func ToSnakeCase

func ToSnakeCase(s string) string

ToSnakeCase converts a CamelCase identifier into snake_case.

Types

This section is empty.

Jump to

Keyboard shortcuts

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