Files
2020-02-29 01:04:07 +08:00

23 lines
574 B
Go

package dialect
import "reflect"
var dialectsMap = map[string]Dialect{}
// Dialect is an interface contains methods that a dialect has to implement
type Dialect interface {
DataTypeOf(typ reflect.Value) string
TableExistSQL(tableName string) (string, []interface{})
}
// RegisterDialect register a dialect to the global variable
func RegisterDialect(name string, dialect Dialect) {
dialectsMap[name] = dialect
}
// Get the dialect from global variable if it exists
func GetDialect(name string) (dialect Dialect, ok bool) {
dialect, ok = dialectsMap[name]
return
}