dal/pkg/adapter/registry.go
Anton Nesterov 296595cfea
[doc] fix copilot crap
Signed-off-by: Anton Nesterov <anton@demiurg.io>
2024-08-15 09:10:49 +02:00

25 lines
552 B
Go

package adapter
import "fmt"
var DIALECTS = map[string]Dialect{
"sqlite3": CommonDialect{},
}
/*
Register a new dialect for a given driver name.
`driverName` is the valid name of the db driver (e.g. "sqlite3", "postgres").
`dialect` is an implementation of the Dialect interface.
*/
func RegisterDialect(driverName string, dialect Dialect) {
DIALECTS[driverName] = dialect
}
func GetDialect(driverName string) Dialect {
dialect, ok := DIALECTS[driverName]
if !ok {
panic(fmt.Errorf("db driver %s not found", driverName))
}
return dialect
}