Refactor: Flatten embedded struct fields in segments and cache - #7837
Merged
Conversation
Bump the module and CI toolchain to go 1.27.0 and let go mod tidy merge the duplicate require blocks, as it now does for 1.27 modules. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F4pmtq5zxSxC4VqXipPAmY
Go 1.27 ships a uuid package in the standard library, replacing the hand-rolled RFC 4122 v4 implementation. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F4pmtq5zxSxC4VqXipPAmY
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F4pmtq5zxSxC4VqXipPAmY
Go 1.27 allows any valid field selector as a struct literal key, applied via the new go fix embedlit modernizer. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F4pmtq5zxSxC4VqXipPAmY
Go 1.27 allows methods to declare their own type parameters. Turn the package-level generic functions that took a receiver as first argument into methods: - http.Do[T](r, ...) becomes Request.Do[T](...) - http.OauthResult[T](o, ...) becomes OAuthRequest.Result[T](...) - cache.Get/Set/Delete/DeleteAll/Refresh/Print(store, ...) become methods on Store, e.g. cache.Device.Get[string](key) cache.Store already carried non-generic methods; Get and Set were only package functions because generic methods did not exist. OneOf (options) and the interface-based helpers stay functions, as interface methods cannot have type parameters. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01F4pmtq5zxSxC4VqXipPAmY
📦 Release binary size reportCompares this PR's release-equivalent build against the latest published release, per OS (amd64).
✅ No significant size change on any platform. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This PR refactors the codebase to flatten embedded struct fields, removing unnecessary nesting and improving code clarity. The changes include:
Cache API Changes:
Storetype (e.g.,cache.Get()→cache.Session.Get(),cache.Set()→cache.Device.Set())cache.Print()toSession.Print()methodcache.Refresh()toStore.Refresh()methodcache.DeleteAll()toStore.DeleteAll()methodSegment Struct Flattening:
Scmembedded struct wrapper in Git, Sapling, and other SCM segments, promoting fields directly to parent structBaseembedded struct wrapper in various segments (CopilotCLI, Antigravity, Claude, Argocd, HTTP, IPify, etc.), promotingenvandoptionsfields directlyScmStatusembedded struct wrapper in status types (GitStatus, SvnStatus, PlasticStatus, etc.), promoting status fields directlyMusicPlayerembedded struct wrapper in Spotify segmentSimpleTemplateembedded struct wrapper in cache.TemplateOther Improvements:
strings.LastIndex()withstrings.CutLast()in ini.go and log.goTest Plan
Existing unit tests have been updated to reflect the new struct layouts and API changes. All tests pass with the refactored code, confirming that the flattening maintains functional equivalence while improving code organization.
https://claude.ai/code/session_01F4pmtq5zxSxC4VqXipPAmY