Skip to content

Instantly share code, notes, and snippets.

@yutakahashi114
Created January 19, 2020 13:29
Show Gist options
  • Save yutakahashi114/31596635831aee9ba25d700fe2cd38df to your computer and use it in GitHub Desktop.
Save yutakahashi114/31596635831aee9ba25d700fe2cd38df to your computer and use it in GitHub Desktop.
type userForEnableEmpty struct {
ID uint64 `xorm:"autoincr"`
FirstName *string
LastName *string
FirstNameKana *string
LastNameKana *string
Version uint64 `xorm:"version"`
CreatedAt time.Time `xorm:"created"`
UpdatedAt time.Time `xorm:"updated"`
DeletedAt time.Time `xorm:"deleted"`
}
func (userForEnableEmpty) TableName() string {
return "users"
}
{
ufee := userForEnableEmpty{}
has, err = engine.
Where("id = ?", id).
Get(&ufee)
if err != nil {
log.Println(err)
return
}
if !has {
log.Println("Not Found")
return
}
ufee.FirstName = &u.FirstName
ufee.LastName = &u.LastName
ufee.FirstNameKana = &u.FirstNameKana
affected, err = engine.
Where("id = ?", id).
Update(&ufee)
if err != nil {
log.Println(err)
return
}
if affected == 0 {
log.Println("Not Found")
return
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment