Skip to content

Instantly share code, notes, and snippets.

@yutakahashi114
Created January 19, 2020 13:24
Show Gist options
  • Save yutakahashi114/7f8f0af1b27d5f2fda446aa7b1e6227a to your computer and use it in GitHub Desktop.
Save yutakahashi114/7f8f0af1b27d5f2fda446aa7b1e6227a to your computer and use it in GitHub Desktop.
u := user{}
has, err := engine.
Where("id = ?", id).
Get(&u)
if err != nil {
log.Println(err)
return
}
if !has {
log.Println("Not Found")
return
}
u.FirstName = "太郎更新"
u.LastName = "テスト更新"
u.FirstNameKana = "タロウコウシン"
affected, err = engine.
Where("id = ?", id).
Update(&u)
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