package v2 import ( "fmt" "testing" "gorm.io/driver/postgres" "gorm.io/gorm" ) func GetDevDB() (*gorm.DB, error) { dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Shanghai", "192.168.31.55", "timerzz", "zhhg1997", "kedaya_dev", "5432") return gorm.Open(postgres.Open(dsn), &gorm.Config{}) } func TestMock(t *testing.T) { db, _ := GetDevDB() m := []Mock{} db.Model(&Mock{}).Where("test", nil).Find(&m) fmt.Println(m) }