naming

package
v6.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2026 License: Apache-2.0 Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAttrName

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

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

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

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
	// PascalCase convention: "FirstName", "CreatedAt", "ID", "GSI1PK"
	// This is primarily intended for legacy DynamoDB schemas that use PascalCase and acronyms.
	PascalCase Convention = 2
	// DynamORM convention preserves legacy DynamORM semantics:
	// PK/SK are always uppercase, while all other fields use camelCase.
	DynamORM Convention = 3
)

Jump to

Keyboard shortcuts

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