package main import ( "fmt" "time" _ "github.com/go-sql-driver/mysql" "github.com/jinzhu/gorm" ) func main() { // db接続 db, err := sqlConnect() if err != nil { panic(err.Error()) } defer db.Close() result := []*Users{} db.Find(&result) for _, user := range result { fmt.Println(user.Name) } fmt.Println("update") // Modelに構造体の配列をいれる error := db.Model(Users{}).Where("id = ?", 1).Update(&Users{ Name: "
![【第13回】Go言語(Golang)入門~MySQL利用編~ – 株式会社ライトコード](https://cdn-ak-scissors.b.st-hatena.com/image/square/cc3e2477109b1597da47c30b476fbe17ed6fdd87/height=288;version=1;width=512/https%3A%2F%2Frightcode.co.jp%2Fwp-content%2Fuploads%2F2019%2F12%2Fgolang-introduction-mysql-utilization.png)