Documentation
¶
Overview ¶
Package naming transforms resource, identifier, and database names.
Index ¶
- func Capitalize(s string) string
- func ControllerPackageName(namespace string) string
- func DeriveResourceName(tableName string) string
- func DeriveTableName(resourceName string) string
- func IsValidNamespace(namespace string) bool
- func NamespaceFilePrefix(namespace string) string
- func NamespaceFromResource(resourceName string) (namespace, name string)
- func NamespaceRouteName(namespace string) string
- func NamespaceToPascal(namespace string) string
- func NamespacedControllerImportPath(modulePath, namespace string) string
- func ParseNamespacedResource(input string) (namespace, resource string, err error)
- func ToCamelCase(s string) string
- func ToKebabCase(s string) string
- func ToLowerCamelCase(s string) string
- func ToLowerCamelCaseFromAny(s string) string
- func ToPascalCase(s string) string
- func ToReceiverName(s string) string
- func ToSnakeCase(s string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ControllerPackageName ¶ added in v1.0.0
ControllerPackageName returns the package name for a controller file given an optional namespace. Empty namespace yields "controllers".
func DeriveResourceName ¶ added in v1.0.0
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 ¶
DeriveTableName converts a CamelCase resource name into a snake_case plural table name.
func IsValidNamespace ¶ added in v1.0.0
IsValidNamespace validates that a namespace is a valid Go package name and not a reserved path.
func NamespaceFilePrefix ¶ added in v1.0.0
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
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
NamespaceRouteName converts a slash-separated namespace path into a dotted route-name prefix.
func NamespaceToPascal ¶ added in v1.0.0
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
NamespacedControllerImportPath returns the import path for a controller package, optionally namespaced.
func ParseNamespacedResource ¶ added in v1.0.0
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 ¶
ToCamelCase converts a snake_case identifier into camelCase. Examples: "admin_users" -> "adminUsers", "product_categories" -> "productCategories"
func ToKebabCase ¶ added in v1.0.0
ToKebabCase converts a snake_case identifier into kebab-case.
func ToLowerCamelCase ¶
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
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
ToPascalCase converts a snake_case identifier into PascalCase. Examples: "admin_users" -> "AdminUsers", "product_categories" -> "ProductCategories"
func ToReceiverName ¶ added in v1.0.0
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 ¶
ToSnakeCase converts a CamelCase identifier into snake_case.
Types ¶
This section is empty.