Skip to content

All methods on models should use pointer receivers #1272

@Mjaethers

Description

@Mjaethers

Is your feature request related to a problem? Please describe.
Goland has been harassing me about the fact that some structs in the package model mix value and pointer receivers. This is not recommended by the Go documentation.

Describe the solution you'd like
It would make sense to convert the methods with pointer receivers to value receiving methods as the mutability provided by using pointers is achieved through the dao design pattern.
It would make sense to convert the methods with value receivers to pointer receiving methods as this would be more efficient for large structs.

Describe alternatives you've considered
It would also be possible to convert the methods with value receivers to methods with pointer receivers, the docs suggest this would be more efficient but since most methods use value receivers and the commitment to the dao design pattern was made, I think using value receivers makes more sense.
It could either be left as is or the dao pattern could be extended for the model package.

Additional context
The Go docs talk about this in their FAQ here

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions