A common pattern in soju is:
record := user.User // copy
record.Something = 42
user.updateUser(&record)
This is suboptimal because it's pretty easy to forget the copy and mutate the data directly:
user.Something = 42
user.updateUser(&user.User)
This is a mistake because the in-memory state goes out-of-sync with the DB state if updateUser
fails.
Something safer could be:
user.updateUser(func(record *database.User) {
record.Something = 42
})
Simon Ser referenced this ticket in commit aecff32.