Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors interface usage by removing unnecessary pointer indirection for interface fields and variables, ensuring interfaces are passed and stored directly rather than as pointers.
- Updated
DOMAIN_GLOBALSandNewGlobalssignature to accept interfaces by value - Changed all call sites on
GLOB.DSP,GLOB.HSM,GLOB.CS,GLOB.RFTloc, and related globals to remove*dereferences - Adjusted test and application code across domain, API, and CLI layers for the new interface signatures
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/domain/globals.go | Changed interface fields to non-pointer types and updated NewGlobals signature |
| internal/domain/transitions.go | Removed pointer indirection on all GLOB interface method calls |
| internal/domain/transitions_test.go | Updated tests to call GLOB.DSP.Store... directly |
| internal/domain/power-status.go | Removed * dereferences for kvStore, hsmHandle, ccStore, distLocker, tloc |
| internal/domain/power-status_test.go | Updated credential and HSM data calls to remove pointer derefs |
| internal/domain/power-cap.go | Removed pointer indirection on GLOB.DSP, GLOB.HSM, GLOB.CS, GLOB.RFTloc |
| internal/domain/power-cap_test.go | Updated power-cap tests to use direct interface calls |
| internal/api/health.go | Removed pointer derefs for glb.DSP, glb.DistLock, glb.HSM, glb.CS, glb.RFTloc |
| internal/api/health_test.go | Updated health test setup to pass interfaces by value |
| cmd/power-control/main.go | Adjusted NewGlobals invocation and direct assignment to domainGlobals.RFTloc |
evanmcc
reviewed
Jun 17, 2025
763af8e to
ebb4d78
Compare
Member
|
@rainest Should we update, close, or merge this? |
Member
|
We were holding off on merging this until the postgres work landed, it can be rebase and merged now I think. |
Do not dereference interface fields and vars, and pass struct pointers to functions that accept interfaces. Pointers to structs with the appropriate methods satisfy interfaces and are the standard means of passing interface arguments. Using pointers to interfaces requires weird type contortions. Signed-off-by: Travis Raines <571832+rainest@users.noreply.github.com>
Signed-off-by: Travis Raines <571832+rainest@users.noreply.github.com>
ebb4d78 to
1185c5f
Compare
Contributor
Author
|
Rebased, moved some changes to the new service cmd file. |
Member
|
@cjh1 Can you merge or close this? |
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.
Summary and Scope
Do not dereference interface fields and vars, and pass struct pointers to functions that accept interfaces. Pointers to structs with the appropriate methods satisfy interfaces and are the standard means of passing interface arguments. Using pointers to interfaces requires weird type contortions.
This change is a backwards compatible code cleanliness change, and does not affect functionality.
Testing
Basically, if
go vetlikes it, it's good to go. Don't expect there's anything CI can find that the compiler can, but it's running anyway 🤷Issues and Related PRs
N/a, found working on something else.
Risks and Mitigations
Hopefully unlikely to cause conflicts, since these are largely simple function calls, but ideally this should be upstreamed.
Pull Request Checklist
Version number(s) incremented, if applicableCopyrights updatedCHANGELOG.md updatedcode only