Since _
is used in Go as a blank identifier to discard value. The import statement below will import the package and execute its init
function. Is there a way to alias the package as _
? so that I can use it as _.Method()
.
import (
_ "github.com/ziutek/mymysql/godrv"
)
No, this is not possible, for the reason you described. The closest you can do is use two underscores:
import (
__ "github.com/ziutek/mymysql/godrv"
)
__.Method()