-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can I use interface{} as query destination? #857
Comments
package main
import (
_ "github.com/go-sql-driver/mysql"
"github.com/jinzhu/gorm"
)
type Foo struct {
gorm.Model
Name string
}
var db *gorm.DB
func find(v interface{}) {
db.Debug().Find(v)
}
func main() {
var err error
db, err = gorm.Open("mysql", "gorm:gorm@/gorm?charset=utf8&parseTime=True&loc=Local")
if err != nil {
panic(err)
}
db.AutoMigrate(&Foo{})
var x1 = []Foo{}
find(&x1)
} |
@jinzhu Hi, i don't think it will work if we assign
|
@SherL0cked |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How should I pass
interface{}
containing struct? Example with x2 works, but example with x1 does not. Is it a feature or bug? Is it possible to bypass this somehow?The text was updated successfully, but these errors were encountered: