mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
database/sql: add Drivers, returning list of registered drivers
Fixes #7969. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/158950043
This commit is contained in:
parent
05c4b69f84
commit
5318a1b5b1
2 changed files with 33 additions and 0 deletions
|
|
@ -18,6 +18,7 @@ import (
|
|||
"fmt"
|
||||
"io"
|
||||
"runtime"
|
||||
"sort"
|
||||
"sync"
|
||||
)
|
||||
|
||||
|
|
@ -36,6 +37,16 @@ func Register(name string, driver driver.Driver) {
|
|||
drivers[name] = driver
|
||||
}
|
||||
|
||||
// Drivers returns a sorted list of the names of the registered drivers.
|
||||
func Drivers() []string {
|
||||
var list []string
|
||||
for name := range drivers {
|
||||
list = append(list, name)
|
||||
}
|
||||
sort.Strings(list)
|
||||
return list
|
||||
}
|
||||
|
||||
// RawBytes is a byte slice that holds a reference to memory owned by
|
||||
// the database itself. After a Scan into a RawBytes, the slice is only
|
||||
// valid until the next call to Next, Scan, or Close.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue