Skip to content

Instantly share code, notes, and snippets.

@yutakahashi114
Created January 19, 2020 13:27
Show Gist options
  • Save yutakahashi114/dedf7f98153f9bc3525dcc90d2ae9983 to your computer and use it in GitHub Desktop.
Save yutakahashi114/dedf7f98153f9bc3525dcc90d2ae9983 to your computer and use it in GitHub Desktop.
type userForNoLock struct {
ID uint64 `xorm:"autoincr"`
FirstName string
LastName string
FirstNameKana string
LastNameKana string
CreatedAt time.Time `xorm:"created"`
UpdatedAt time.Time `xorm:"updated"`
DeletedAt time.Time `xorm:"deleted"`
}
func (userForNoLock) TableName() string {
return "users"
}
{
ufnl := userForNoLock{
FirstName: "太郎更新",
FirstNameKana: "タロウコウシン",
}
affected, err := engine.
Where("id = ?", id).
Update(&ufnl)
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