casing

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package casing holds snake_case <-> camelCase helpers used internally by the GoFastr framework. Hook payloads are snake_cased; generated structs use camelCase JSON tags. These helpers translate between the two.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMapping

func ApplyMapping(row map[string]any, mapping map[string]string) map[string]any

ApplyMapping converts keys using a precomputed mapping. Skips keys not in the mapping (passes them through as-is). Zero allocations for the mapping lookup; one allocation for the result map.

func MapToCamel

func MapToCamel(m map[string]any) map[string]any

MapToCamel converts all snake_case keys in a map to camelCase. Reuses the input map's capacity for the result.

func MapToSnake

func MapToSnake(m map[string]any) map[string]any

MapToSnake converts all camelCase keys in a map to snake_case.

func PrecomputeMapping

func PrecomputeMapping(columns []string) map[string]string

PrecomputeMapping builds a snake→camel mapping for a fixed set of column names. The returned map can be passed to ApplyMapping for zero-alloc key conversion on each row. Call this once at entity Define() time.

func ToCamel

func ToCamel(s string) string

ToCamel converts a snake_case string to camelCase. e.g. "author_id" -> "authorId", "created_at" -> "createdAt". Results are cached for repeat lookups.

func ToSnake

func ToSnake(s string) string

ToSnake converts a camelCase string to snake_case. e.g. "authorId" -> "author_id", "createdAt" -> "created_at". Results are cached for repeat lookups.

Types

This section is empty.

Jump to

Keyboard shortcuts

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