如下匿名导入,包名前加 ‘_’
import(_ "github.com/go-sql-driver/mysql"
)
func main(){
config := mysql.config{...}
}
编译时会报错 undifined mysql
去掉匿名导入的下划线,即可正常编译
如下匿名导入,包名前加 ‘_’
import(_ "github.com/go-sql-driver/mysql"
)
func main(){
config := mysql.config{...}
}
编译时会报错 undifined mysql
去掉匿名导入的下划线,即可正常编译