douhuifen9942 2016-10-08 02:39
浏览 1165
已采纳

golang同时连接2个不同类型的数据库

I need to connect mysql and oracle at same time for a database related application. From the document I learned that in go the database drivers are initialized in "init()" function. So I want to know if I import 2 different database drivers, does the later driver will override the former one?

  • 写回答

1条回答 默认 最新

  • douben6670 2016-10-08 03:03
    关注

    There's no problem importing both because the drivers use different names. The driver name is the first argument to sql.Open.

    If they should happen to use the same name, then the driver registration function panics.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?