Skip to content

Releases: go-pkgz/stringutils

v1.3.0

11 Aug 22:14
ed86b8d
Compare
Choose a tag to compare

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

11 Aug 22:04
ea95ec0
Compare
Choose a tag to compare

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

11 Aug 21:39
94f699b
Compare
Choose a tag to compare

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

11 Aug 06:13
efb2501
Compare
Choose a tag to compare

golangci-lint v2 migration

Migrated golangci-lint configuration to v2 format
Updated GitHub Actions workflow to use golangci-lint-action@v7

All tests pass and linter shows 0 issues.

Version 1.1.0

01 Jun 15:23
Compare
Choose a tag to compare

What's Changed

New Contributors

Full Changelog: v1.0.0...v1.1.0