naming

package
v1.0.37 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAttrName added in v1.0.34

func ConvertAttrName(name string, convention Convention) string

ConvertAttrName converts a field name to the appropriate naming convention.

func DefaultAttrName

func DefaultAttrName(name string) string

DefaultAttrName converts a Go struct field name to the preferred camelCase DynamoDB attribute name.

func ResolveAttrName

func ResolveAttrName(field reflect.StructField) (string, bool)

ResolveAttrName determines the DynamoDB attribute name for a field using CamelCase convention. It returns the attribute name and a bool indicating whether the field should be skipped.

func ResolveAttrNameWithConvention added in v1.0.34

func ResolveAttrNameWithConvention(field reflect.StructField, convention Convention) (string, bool)

ResolveAttrNameWithConvention determines the DynamoDB attribute name for a field using the specified convention. It returns the attribute name and a bool indicating whether the field should be skipped.

func ToSnakeCase added in v1.0.34

func ToSnakeCase(name string) string

ToSnakeCase converts a Go struct field name to snake_case DynamoDB attribute name. It uses smart acronym handling: "URLValue" → "url_value", "ID" → "id", "UserID" → "user_id".

func ValidateAttrName

func ValidateAttrName(name string, convention Convention) error

ValidateAttrName enforces the naming convention for DynamoDB attribute names. For CamelCase: allows "PK" and "SK" as exceptions, otherwise enforces camelCase pattern. For SnakeCase: enforces snake_case pattern (no special exceptions).

Types

type Convention added in v1.0.34

type Convention int

Convention represents the naming convention for DynamoDB attribute names.

const (
	// CamelCase convention: "firstName", "createdAt", with special handling for "PK" and "SK"
	CamelCase Convention = 0
	// SnakeCase convention: "first_name", "created_at"
	SnakeCase Convention = 1
)

Jump to

Keyboard shortcuts

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