Skip to content

Conversation

@karngyan
Copy link
Member

No description provided.

Copilot AI review requested due to automatic review settings September 17, 2025 21:10
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new CamelCase function to the sx package that converts strings and string slices to camelCase format. The function follows the existing pattern established by PascalCase but produces camelCase output (first letter lowercase).

  • Implements CamelCase function with support for both string and string slice inputs
  • Adds comprehensive test coverage for various input formats and edge cases
  • Introduces a helper function lowercaseWord for converting the first character to lowercase

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
sx.go Adds CamelCase function and lowercaseWord helper function
sx_test.go Comprehensive test cases for both string and slice variants of CamelCase

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +254 to +255
pascalCase := PascalCase(v, opts...)
return lowercaseWord(pascalCase)
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Converting to PascalCase first then lowercasing introduces unnecessary work. Consider implementing camelCase directly by reusing the PascalCase logic but applying lowercaseWord to the first word only, similar to how the slice case is handled.

Suggested change
pascalCase := PascalCase(v, opts...)
return lowercaseWord(pascalCase)
options := CaseConfig{}
for _, opt := range opts {
opt(&options)
}
words := splitByCaseWithCustomSeparators(v, nil)
result := joinWords(words, "", func(word string, i int) string {
normalized := normalizeWord(word, options.Normalize)
if i == 0 {
return lowercaseWord(normalized)
}
return capitalizeWord(normalized)
})
return result

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

📊 Code Coverage Report

total:					(statements)			95.2%
Coverage by file
github.com/gomantics/sx/sx.go:14:	isSeparator			100.0%
github.com/gomantics/sx/sx.go:19:	isSeparatorCustom		100.0%
github.com/gomantics/sx/sx.go:24:	isLetterCaseChange		100.0%
github.com/gomantics/sx/sx.go:51:	splitByCaseWithCustomSeparators	100.0%
github.com/gomantics/sx/sx.go:124:	defaultSplitConfig		100.0%
github.com/gomantics/sx/sx.go:131:	WithSeparators			100.0%
github.com/gomantics/sx/sx.go:140:	SplitByCase			100.0%
github.com/gomantics/sx/sx.go:150:	normalizeWord			100.0%
github.com/gomantics/sx/sx.go:158:	capitalizeWord			83.3%
github.com/gomantics/sx/sx.go:172:	joinWords			87.5%
github.com/gomantics/sx/sx.go:197:	WithNormalize			100.0%
github.com/gomantics/sx/sx.go:209:	PascalCase			92.9%
github.com/gomantics/sx/sx.go:237:	lowercaseWord			83.3%
github.com/gomantics/sx/sx.go:251:	CamelCase			93.3%
total:					(statements)			95.2%

@karngyan karngyan merged commit fee2b75 into main Sep 17, 2025
2 checks passed
@karngyan karngyan deleted the camel-case branch September 17, 2025 21:11
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