mirror of https://github.com/jackc/pgx.git
Added conn.Close
parent
0e992bbaa5
commit
bc830d4a21
8
conn.go
8
conn.go
|
@ -53,6 +53,14 @@ func Connect(options map[string]string) (c *conn, err error) {
|
|||
return c, nil
|
||||
}
|
||||
|
||||
func (c *conn) Close() (err error) {
|
||||
buf := c.getBuf(5)
|
||||
buf[0] = 'X'
|
||||
binary.BigEndian.PutUint32(buf[1:], 4)
|
||||
_, err = c.conn.Write(buf)
|
||||
return
|
||||
}
|
||||
|
||||
func (c *conn) rxMsg() (msg interface{}, err error) {
|
||||
var t byte
|
||||
var bodySize int32
|
||||
|
|
|
@ -5,8 +5,13 @@ import (
|
|||
)
|
||||
|
||||
func TestConnect(t *testing.T) {
|
||||
_, err := Connect(map[string]string{"socket": "/private/tmp/.s.PGSQL.5432"})
|
||||
conn, err := Connect(map[string]string{"socket": "/private/tmp/.s.PGSQL.5432"})
|
||||
if err != nil {
|
||||
t.Fatal("Unable to establish connection")
|
||||
}
|
||||
|
||||
err = conn.Close()
|
||||
if err != nil {
|
||||
t.Fatal("Unable to close connection")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue