What version of Go are you using (go version
)?
go version go1.7.4 linux/amd64
Which database and its version are you using?
mysql
What did you do?
use find with slice Please provide a complete runnable program to reproduce your issue.
package main
import (
"github.com/jinzhu/gorm'
)
var db *gorm.DB
func init() {
var err error
//db, err = gorm.Open("sqlite3", "test.db")
// Please use below username, password as your database's account for the script.
// db, err = gorm.Open("postgres", "user=gorm dbname=gorm sslmode=disable")
db, err = gorm.Open("mysql", "gorm:gorm@/dbname?charset=utf8&parseTime=True")
// db, err = gorm.Open("mssql", "sqlserver://gorm:LoremIpsum86@localhost:1433?database=gorm")
if err != nil {
panic(err)
}
db.LogMode(true)
}
func main() {
init()
type User struct {
username string `gorm:"not null;unique"`
password string `gorm:"not null;unique"`
}
db.Find([]model.User)
}
Comment From: vkrishnasatya
sorry it was connection issue
Comment From: manicar2093
Hi, this also happen when you pass a no pointer destination. Something like this:
var dest User
dbConn.First(dest, "id = ?", 1)
I just let this here to future references 😃