Your issue may already be reported! Please search on the issue track before creating one.
What version of Go are you using (go version)?
go1.13
Which database and its version are you using?
Mysql 5.7
Please provide a complete runnable program to reproduce your issue. IMPORTANT
Need to runnable with GORM's docker compose config or please provides your config.
package main
import (
"fmt"
"gorm.io/driver/mysql"
"gorm.io/gorm"
)
var GDB *gorm.DB
func main() {
var err error
dsn := "gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True&loc=Local"
GDB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{})
if err != nil {
fmt.Println("open db err", err)
}
}
Comment From: LonglyCode
Run go build,will get error:
go: finding gorm.io/driver/mysql latest
go: gotest imports
gorm.io/driver/mysql imports
gorm.io/gorm: gorm.io/gorm@v1.9.12: parsing go.mod:
module declares its path as: github.com/jinzhu/gorm
but was required as: gorm.io/gorm
Comment From: jinzhu
I am working on that, please use go get gorm.io/gorm@v0.2.4 to install for now.
Comment From: github-actions[bot]
This issue will be automatically closed because it is marked as GORM V1 issue, we have released the public testing GORM V2 release and its documents https://v2.gorm.io/docs/ already, the testing release has been used in some production services for a while, and going to release the final version in following weeks, we are still actively collecting feedback before it, please open a new issue for any suggestion or problem, thank you
Also check out https://github.com/go-gorm/gorm/wiki/GORM-V2-Release-Note-Draft for how to use the public testing version and its changelog
Comment From: 741369
go get github.com/jinzhu/gorm@v2_dev
go get github.com/jinzhu/gorm@v2_dev v2 will get error go: github.com/jinzhu/gorm v2_dev => v1.9.13-0.20200602011801-e986371a42bb go get: github.com/jinzhu/gorm@v1.9.13-0.20200602011801-e986371a42bb: parsing go.mod: module declares its path as: gorm.io/gorm but was required as: github.com/jinzhu/gorm
Comment From: ifqygazhar
how to fix this ?
github.com/go-gorm/mysql@none updating to github.com/go-gorm/mysql@v1.1.1: parsing go.mod: module declares its path as: gorm.io/driver/mysql but was required as: github.com/go-gorm/mysql
Comment From: runzhliu
@ifqygazhar it does work for me ;)
module test
go 1.18
require (
gorm.io/driver/sqlite v1.2.6
gorm.io/gorm v1.22.4
)
require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.3 // indirect
github.com/mattn/go-sqlite3 v1.14.9 // indirect
)