mirror of
https://github.com/jackc/pgx.git
synced 2025-04-27 13:14:32 +00:00
Added conn.Close
This commit is contained in:
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
|
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) {
|
func (c *conn) rxMsg() (msg interface{}, err error) {
|
||||||
var t byte
|
var t byte
|
||||||
var bodySize int32
|
var bodySize int32
|
||||||
|
@ -5,8 +5,13 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestConnect(t *testing.T) {
|
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 {
|
if err != nil {
|
||||||
t.Fatal("Unable to establish connection")
|
t.Fatal("Unable to establish connection")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = conn.Close()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal("Unable to close connection")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user