-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Labels
component: backendPull requests that update Go codePull requests that update Go codelanguage: Gopriority: P2 - Lowstatus: newtype: pedantic
Milestone
Description
Description
Align the codebase with the Go best practice: "Accept interfaces, return structs" to improve flexibility and API clarity.
Some parts of the code do not follow the common Go convention:
- Functions and methods should accept interfaces as parameters, enabling flexibility.
- They should return concrete structs, which provide clarity and avoid unnecessary abstractions.
Following this pattern makes the code more idiomatic and easier for Go developers to understand and maintain.
Tasks
- Review the codebase to find functions or methods that:
- Accept concrete structs instead of interfaces.
- Return interfaces instead of structs.
- Refactor these to:
- Accept interfaces where appropriate.
- Return structs instead of interfaces where it improves clarity or safety.
- Consider API protection:
- Returning interfaces can sometimes hide implementation details but may reduce clarity.
- Choose the best approach case-by-case.
- Test all affected code to ensure no behavior changes or breakages.
Notes
- Use this as a guideline, not a strict rule, apply changes only where it makes sense.
- This improves code readability, testability, and adherence to Go idioms.
Metadata
Metadata
Assignees
Labels
component: backendPull requests that update Go codePull requests that update Go codelanguage: Gopriority: P2 - Lowstatus: newtype: pedantic