golang 匿名导入包不起作用

Golang
425
0
0
2022-04-10

如下匿名导入,包名前加 ‘_’

import(_ "github.com/go-sql-driver/mysql"
)
func main(){
    config := mysql.config{...}
}

编译时会报错 undifined mysql

去掉匿名导入的下划线,即可正常编译