Common Patterns
As with most software packages and libraries there are common patterns that are used most of the time, with some functionality used in edge cases (I've thought a lot about this as it pertains to external libraries in software engineering and my best guess is that it follows a Pareto-like cumulative distribution). The point of this chapter is to lay out the most common patterns used. More advanced topics such as validations, callbacks, and tests are addressed in their own chapter.
For all the example patterns we'll be using the User
model created in the quick start section using the development database. The examples will also live in a file called main.go
.