-
Notifications
You must be signed in to change notification settings - Fork 0
chore(golang): anonymous struct for api response #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: chore-any-type
Are you sure you want to change the base?
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the API response handling by converting a named struct type (apiResponse) into an anonymous inline struct. The change eliminates the standalone type definition and embeds the structure directly where it's used.
Key Changes:
- Removed the
apiResponsetype definition - Replaced it with an anonymous struct defined inline within the
domethod
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| r := struct { | ||
| Result string `json:"result"` | ||
| Message string `json:"message"` | ||
| Data any `json:"data"` | ||
| Code int `json:"code"` | ||
| Fields map[string]any `json:"fields"` | ||
| }{ | ||
| Data: data, | ||
| } |
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Converting apiResponse from a named type to an anonymous struct reduces code reusability and makes it harder to test. If this response structure is used in multiple places or needs to be mocked for testing, consider keeping it as a named type. Additionally, the inline comment (lines 158-159) duplicates information that was better expressed as a type-level comment on the original struct.
Add `testing/doc.go` with comprehensive package documentation covering: - Test data builders with fluent API examples - FakeClient for integration-style tests - MockClient for unit tests with function fields The documentation appears in `go doc` output and helps users understand the package's purpose and usage patterns. Resolves todo #8: testing package missing package-level documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add `testing/doc.go` with comprehensive package documentation covering: - Test data builders with fluent API examples - FakeClient for integration-style tests - MockClient for unit tests with function fields The documentation appears in `go doc` output and helps users understand the package's purpose and usage patterns. Resolves todo #8: testing package missing package-level documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add `testing/doc.go` with comprehensive package documentation covering: - Test data builders with fluent API examples - FakeClient for integration-style tests - MockClient for unit tests with function fields The documentation appears in `go doc` output and helps users understand the package's purpose and usage patterns. Resolves todo #8: testing package missing package-level documentation. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
No description provided.