本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

32 lines
673B

  1. // Copyright 2019 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package core
  5. type Driver interface {
  6. Parse(string, string) (*Uri, error)
  7. }
  8. var (
  9. drivers = map[string]Driver{}
  10. )
  11. func RegisterDriver(driverName string, driver Driver) {
  12. if driver == nil {
  13. panic("core: Register driver is nil")
  14. }
  15. if _, dup := drivers[driverName]; dup {
  16. panic("core: Register called twice for driver " + driverName)
  17. }
  18. drivers[driverName] = driver
  19. }
  20. func QueryDriver(driverName string) Driver {
  21. return drivers[driverName]
  22. }
  23. func RegisteredDriverSize() int {
  24. return len(drivers)
  25. }
上海开阖软件有限公司 沪ICP备12045867号-1