Skip to content

Refactor: Flatten embedded struct fields in segments and cache - #7837

Merged
JanDeDobbeleer merged 5 commits into
mainfrom
claude/golang-1-27-features-cxn2cb
Aug 27, 2026
Merged

Refactor: Flatten embedded struct fields in segments and cache#7837
JanDeDobbeleer merged 5 commits into
mainfrom
claude/golang-1-27-features-cxn2cb

Conversation

@JanDeDobbeleer

Copy link
Copy Markdown
Owner

Description

This PR refactors the codebase to flatten embedded struct fields, removing unnecessary nesting and improving code clarity. The changes include:

Cache API Changes:

  • Converted cache functions to methods on Store type (e.g., cache.Get()cache.Session.Get(), cache.Set()cache.Device.Set())
  • Updated cache.Print() to Session.Print() method
  • Changed cache.Refresh() to Store.Refresh() method
  • Updated cache.DeleteAll() to Store.DeleteAll() method

Segment Struct Flattening:

  • Removed Scm embedded struct wrapper in Git, Sapling, and other SCM segments, promoting fields directly to parent struct
  • Removed Base embedded struct wrapper in various segments (CopilotCLI, Antigravity, Claude, Argocd, HTTP, IPify, etc.), promoting env and options fields directly
  • Removed ScmStatus embedded struct wrapper in status types (GitStatus, SvnStatus, PlasticStatus, etc.), promoting status fields directly
  • Removed MusicPlayer embedded struct wrapper in Spotify segment
  • Removed SimpleTemplate embedded struct wrapper in cache.Template

Other Improvements:

  • Updated Go version from 1.26.0 to 1.27.0
  • Replaced deprecated strings.LastIndex() with strings.CutLast() in ini.go and log.go
  • Simplified HTTP request methods to use receiver methods instead of package functions
  • Updated all test files to reflect the new flattened structure

Test 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

claude added 5 commits August 27, 2026 15:30
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
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
@github-actions

Copy link
Copy Markdown

📦 Release binary size report

Compares this PR's release-equivalent build against the latest published release, per OS (amd64).

OS Baseline This PR Delta
darwin 13.82 MB 14.00 MB +179.3 KB (+1.27%)
linux 13.49 MB 13.66 MB +176.0 KB (+1.27%)
windows 14.05 MB 14.14 MB +89.7 KB (+0.62%)

✅ No significant size change on any platform.

@JanDeDobbeleer
JanDeDobbeleer merged commit be79cd4 into main Aug 27, 2026
17 checks passed
@JanDeDobbeleer
JanDeDobbeleer deleted the claude/golang-1-27-features-cxn2cb branch August 27, 2026 18:52
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