-
Notifications
You must be signed in to change notification settings - Fork 0
/
driver.go
36 lines (29 loc) · 863 Bytes
/
driver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package gohive
import (
"database/sql"
"database/sql/driver"
"net"
)
func init() {
sql.Register(HIVE_2, &HiveDriver{})
}
// HiveDriver implements sql.driver
type HiveDriver struct {
}
// DialFunc is a function which can be used to establish the network connection.
// Custom dial functions must be registered with RegisterDial
type DialFunc func(addr string) (net.Conn, error)
var dials map[string]DialFunc
// RegisterDial registers a custom dial function. It can then be used by the
// network address mynet(addr), where mynet is the registered new network.
// addr is passed as a parameter to the dial function.
func RegisterDial(net string, dial DialFunc) {
if dials == nil {
dials = make(map[string]DialFunc)
}
dials[net] = dial
}
// Open new Connection.
func (d *HiveDriver) Open(dsn string) (driver.Conn, error) {
return NewHiveConn(dsn)
}