upper/db

If mysql db has multiple instance objects, is there a problem here?

daheige opened this issue · 0 comments

db/adapter.go

Line 55 in 6d34eff

if _, ok := adapterMap[name]; ok {

// RegisterAdapter registers a generic database adapter.
func RegisterAdapter(name string, adapter Adapter) {
	adapterMapMu.Lock()
	defer adapterMapMu.Unlock()

	if name == "" {
		panic(`Missing adapter name`)
	}
	if _, ok := adapterMap[name]; ok {
		panic(`db.RegisterAdapter() called twice for adapter: ` + name)
	}
	adapterMap[name] = adapter
}

adapterMap var,this way of adapterMap is problematic
In business scenarios, different mysql db instances will be used. If there is a mysql name here, panic will occur if you look at the code here. I think this is unreasonable. Can you improve it?