modernize: update GitHub Actions and modernize Go code #1877
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
modernize: update GitHub Actions and modernize Go code
Summary
This PR modernizes the codebase by upgrading GitHub Actions dependencies and adopting Go 1.23+ standard library improvements. The changes focus on using newer string manipulation functions (
strings.CutPrefix,strings.CutSuffix,strings.SplitSeq) and slice utilities (slices.Contains) to replace older, more verbose patterns. Additionally, GitHub Actions are updated to their latest versions, and a new modernization check is added to the CI pipeline.Related Issues
Closes #1873
Files Changed
GitHub Actions Workflows
.github/workflows/ci.yml: Updated action versions, reordered steps, and added modernization check.github/workflows/patterns.yaml: Bumpedactions/checkout@v6andactions/upload-artifact@v6.github/workflows/release.yml: Updatedactions/checkout@v6andactions/setup-go@v6.github/workflows/update-version-and-create-tag.yml: Updated action versions and fixed conditional syntaxGo Source Files
cmd/generate_changelog/internal/changelog/generator.go: Adoptedstrings.SplitSeqfor iterating over linescmd/generate_changelog/internal/changelog/processing.go: Usedstrings.CutSuffixfor cleaner string manipulationinternal/cli/flags.go: Refactored usingstrings.CutPrefixandslices.Containsinternal/cli/help.go: Simplified flag parsing and padding calculation withmax()functioninternal/cli/output.go: Replaced manual loop withslices.Containsinternal/domain/file_manager.go: Usedslices.Containsfor escape sequence validationinternal/plugins/ai/gemini/voices.go: Migrated tostrings.Builderfor efficient string concatenationinternal/plugins/ai/lmstudio/lmstudio.go: Adoptedbytes.CutPrefixinternal/plugins/ai/openai/openai_image.go: Simplified model checking withslices.Containsinternal/plugins/ai/perplexity/perplexity.go: Usedstrings.Builderfor content assemblyinternal/plugins/template/extension_executor_test.go: Converted tostrings.Builderin test setupinternal/server/ollama.go: Usedfmt.Appendfandstrings.SplitSeqCode Changes
GitHub Actions Dependency Updates
Updated all GitHub Actions to their latest major versions for improved security and performance:
New Modernization Check
Added an automated check to identify further modernization opportunities:
String Manipulation Improvements
Replaced verbose prefix/suffix checking patterns with cleaner Go 1.20+ functions:
Before:
After:
Slice Contains Simplification
Replaced manual loops with
slices.Containsfor readability:Before:
After:
Iterator-Based String Splitting
Adopted
strings.SplitSeqfor memory-efficient iteration over split strings:Before:
After:
String Builder Pattern
Replaced string concatenation with
strings.Builderfor better performance:Before:
After:
Reason for Changes
strings.Builderand iterator-based splitting reduce memory allocationsCutPrefix,CutSuffix,slices.Contains) are more expressiveImpact of Changes
Positive Impacts
Potential Risks
strings.SplitSeqand other featuresTest Plan
go test -v ./...Additional Notes
Breaking Changes
go.modfile should be updated accordingly if not already set.Potential Bugs
strings.SplitSeqbehavior differs slightly fromstrings.Splitfor edge cases (empty strings, single elements). Verified behavior is identical for all usage patterns in this codebase.${{ }}) that was removed. This was a bug fix rather than a potential issue.fmt.Appendf(nil, ...)creates a new buffer each time, which is semantically equivalent to the original code.