The problem of taking address and value by golang method

here is a sample code for adding, deleting, modifying and querying users:

// Create creates a new user account.
func (u *User) Create() error {
    return DB.Self.Create(&u).Error
}

// Update updates an user account information.
func (u *User) Update() error {
    return DB.Self.Save(u).Error
}

question:
Why should Create (& u) use the address and Save (u) use the value?

Mar.10,2022

feels misused. The first to create, u itself is a pointer type, so there is no need to get the pointer of the pointer.

Menu