1、开发环境:go 1.19.1 windows/amd64
2、问题描述:创建DM数据库连接报 error.dsn.invalidSchema
3、相关代码
```
import (
"database/sql"
"dm"
"fmt"
"io/ioutil"
"time"
)
var db *sql.DB
var err error
func main() {
driverName := "dm"
dataSourceName := "TCM:Tcm#123@tcp(10.92.225.249:5236/dwglsvc?)"
if db, err = connect(driverName, dataSourceName); err != nil {
fmt.Printf("%v\n",err)
return
}
}
func connect(driverName string, dataSourceName string) (*sql.DB, error) {
var db *sql.DB
var err error
if db, err = sql.Open(driverName, dataSourceName); err != nil {
return nil, err
}
if err = db.Ping(); err != nil {
return nil, err
}
fmt.Printf("connect to \"%s\" succeed.\n", dataSourceName)
return db, nil
}
```
报错信息(对应到sql.Open)
![image.png](https://static.golangjob.cn/230725/1b600bea26e9132a42c4998ee7047cb3.png)
希望得到正确的创建DM连接的方式,感觉dataSourceName的变量写法有问题。望得到各位大佬帮助