Skip to content

Add Go utility functions package#2

Merged
rjrodger merged 1 commit intomainfrom
claude/add-go-library-Xf3zu
Mar 26, 2026
Merged

Add Go utility functions package#2
rjrodger merged 1 commit intomainfrom
claude/add-go-library-Xf3zu

Conversation

@rjrodger
Copy link
Copy Markdown
Contributor

Summary

This PR introduces a new Go utility package (util) that provides a collection of helper functions for common operations on maps, strings, and data structures. The package is a Go implementation of utility functions, likely ported from a TypeScript/JavaScript codebase.

Key Changes

  • String manipulation functions:

    • Camelify() / CamelifySlice() - Convert kebab-case strings to PascalCase
    • Pinify() - Convert path slices to pin notation with alternating separators
    • Joins() - Join array elements with hierarchical separators
  • Map/data traversal functions:

    • Dive() - Traverse nested maps to a specified depth, returning path-value pairs
    • Get() / GetPath() - Retrieve deeply nested values using dot-separated or slice paths
    • Entity() - Extract entity field validation from a model structure
  • Data transformation functions:

    • Order() - Order and filter maps of items with support for sorting (alphabetical, human-readable), exclusion, and inclusion specs
    • Stringify() - Convert values to JSON strings
    • Decircular() - Create deep copies of nested structures
  • Comprehensive test suite covering all functions with edge cases including nil handling, empty inputs, and complex nested structures

Notable Implementation Details

  • Uses Go's strings.Builder for efficient string concatenation
  • Implements custom integer-to-string conversion in toString() helper
  • Supports hierarchical sorting with special markers (alpha$, human$) for flexible ordering
  • Includes human-readable sorting that pads numeric strings for natural ordering (1, 2, 10 instead of 1, 10, 2)
  • All functions handle nil/empty inputs gracefully

https://claude.ai/code/session_01FsVS8sfCXgTsFVVNE3vGvV

Implements core utility functions (Camelify, Dive, Get, Joins, Pinify,
Entity, Order, Stringify, Decircular) as a Go package with full test
coverage matching the TypeScript test suite.

https://claude.ai/code/session_01FsVS8sfCXgTsFVVNE3vGvV
@rjrodger rjrodger merged commit cb835b2 into main Mar 26, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants