Gorm
参考資料
- GitHub - go-gorm/gorm: The fantastic ORM library for Golang, aims to be developer friendly
- GORM Guides | GORM - The fantastic ORM library for Golang, aims to be developer friendly.
- 【Go】Gormの使い方(CRUD)
Appendix-1 基本的な使い方
DB接続
package main import ( "fmt" "gorm.io/driver/mysql" "gorm.io/gorm" ) func main() { dsn := "root:password@tcp(127.0.0.1:3306)/sample_db?charset=utf8mb4&parseTime=true" db, err := gorm.Open(mysql.Open(dsn), &gorm.Config{}) if err != nil { panic("failed to connect database") } db.Ping() }