Skip to content

How to handle 'Open connection failed:sql: unknown driver "mssql" (forgotten import?)'

Keith Hutchison edited this page Sep 8, 2016 · 3 revisions

The first time I ran https://github.com/denisenkom/go-mssqldb/blob/master/examples/simple.go I got the error 'Open connection failed:sql: unknown driver "mssql" (forgotten import?)'

I resolved this by changing import _ "github.com/denisenkom/go-mssqldb" to import "github.com/denisenkom/go-mssqldb"

Which gave a different error of 'imported and not used: "github.com/denisenkom/go-mssqldb" as mssql'.

However ... after changing back to import _ "github.com/denisenkom/go-mssqldb" and building again the first error went away.

I also had to change the main function name from 'simplemain' to 'main' for some reason before it would compile.

See http://stackoverflow.com/questions/39381968/why-would-open-connection-failedsql-unknown-driver-mssql-forgotten-import

Clone this wiki locally