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

naming

package
v1.9.4 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

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