I am new in Golang.
I want to use gorm in my code but when I run go run *.go
, I see this Error, unfortunately.
/var/www/html/src/gorm.io/gorm/utils/utils.go:46:30: reflect.ValueOf(val).IsZero undefined (type reflect.Value has no field or method IsZero)
this is my coe :
package main
import (
"gorm.io/gorm"
"gorm.io/driver/sqlite"
)
type Product struct {
gorm.Model
Code string
Price uint
}
func main() {
db, err := gorm.Open(sqlite.Open("test.db"), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
// Migrate the schema
db.AutoMigrate(&Product{})
// Create
db.Create(&Product{Code: "D42", Price: 100})
}
Aucun commentaire:
Enregistrer un commentaire