You should be able to instantiate multiple
sql.DB connection pools, one for each database, and then use the appropriate one each time you need to execute some SQL. I’ve used two
sql.DB variables pointing at different databases at the same time with no problem.
I’d be inclined to keep a
map[string]*sql.DB in the appropriate place and then accept the map key as an API parameter. That way, it’ll be easily extensible to handle any number of databases.