GORM errors are returned as a field of the return value instead of a separate return value.

It is therefore very easy to miss that an error may occur and omit error handling routines.

Ensure that GORM errors are checked.

In the example below,

The corrected version of user checks err before using ptr.

  • The Go Blog: Error handling and Go.