Releases: go-pkgz/stringutils
Releases · go-pkgz/stringutils
v1.3.0
New Features
This release adds 12 new utility functions to enhance string and slice manipulation capabilities.
Slice Operations
- Filter: Filter slice elements by predicate function
- Map: Transform each element using a function
- Reverse: Reverse slice order
- IndexOf: Find first occurrence index
- LastIndexOf: Find last occurrence index
Set Operations
- Difference: Get elements in first slice but not in second
- Union: Combine multiple slices and remove duplicates
- Intersection: Get common elements between slices
String Operations
- NormalizeWhitespace: Clean up and normalize whitespace
- IsBlank: Check if string is empty or only whitespace
- RemovePrefix: Remove prefix if present
- RemoveSuffix: Remove suffix if present
Improvements
- All new functions follow consistent patterns
- Proper nil and empty input handling
- Efficient O(n) algorithms for set operations
- No input mutation - all functions return new slices
- Comprehensive test coverage maintained at 98.8%
Documentation
- README updated with categorized function list
- All functions properly documented with godoc comments
v1.2.2
Hotfix Release: Unified DeDup Implementation
Breaking Changes (Improvements)
- DeDup now stable: The DeDup function now preserves the order of first occurrences, making it predictable and consistent
- No input mutation: DeDup no longer modifies the input slice, returning a new slice instead
Performance Improvements
- DeDup improved from O(n²) to O(n) time complexity for all slice sizes
- Significant performance boost for small to medium slices
- No performance degradation for large slices
Changes
- Unified DeDup and DeDupBig to use the same stable, map-based algorithm
- DeDupBig is now deprecated (but maintained for backwards compatibility)
- Added comprehensive test coverage reaching 98.8%
- Fixed unsafe byte-to-string conversion
- Optimized HasCommonElement from O(n*m) to O(n+m)
- Fixed edge case handling in ContainsAnySubstring
Migration Guide
- If your code relies on DeDup mutating the input slice, update to:
slice = DeDup(slice)
- DeDupBig users can continue using it or switch to DeDup (both now identical)
- The stable ordering is a positive change that should not break well-written code
Technical Details
The previous DeDup used an unstable O(n²) algorithm that mutated input slices. The new implementation uses a map-based approach that is stable, faster, and safer. This change was validated by multiple code analysis tools and comprehensive testing.
v1.2.1 - Critical Safety and Performance Fixes
Hotfix Release
Security & Safety Fixes
- Fixed unsafe byte-to-string conversion - Replaced unsafe pointer manipulation with safe string() conversion, eliminating undefined behavior risks
Performance Improvements
- Optimized HasCommonElement - Improved from O(n×m) to O(n+m) using map-based approach
- Optimized DeDupBig - Now uses map[string]struct{} for better memory efficiency
Bug Fixes
- Fixed ContainsAnySubstring - Now properly skips empty substrings instead of always returning true
- Fixed DeDupBig confusion - Replaced misleading visited[k] = found pattern with clear visited[k] = struct{}{}
Testing
- Added comprehensive test cases for empty string edge cases
- Achieved 98.9% test coverage
- All tests passing, linter clean
Dependencies
- No dependency changes
v1.2.0
Version 1.1.0
What's Changed
- add conversion from byte slice to string by @vadiminshakov in #1
New Contributors
- @vadiminshakov made their first contribution in #1
Full Changelog: v1.0.0...v1.1.0