Skip to content

Commit 2a217b9

Browse files
authored
add version check for go 1.15 (#1123)
1 parent d8d93a3 commit 2a217b9

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

conn.go

+14-5
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ type defaultDialer struct {
113113
func (d defaultDialer) Dial(network, address string) (net.Conn, error) {
114114
return d.d.Dial(network, address)
115115
}
116-
func (d defaultDialer) DialTimeout(network, address string, timeout time.Duration) (net.Conn, error) {
116+
func (d defaultDialer) DialTimeout(
117+
network, address string, timeout time.Duration,
118+
) (net.Conn, error) {
117119
ctx, cancel := context.WithTimeout(context.Background(), timeout)
118120
defer cancel()
119121
return d.DialContext(ctx, network, address)
@@ -775,7 +777,9 @@ func (noRows) RowsAffected() (int64, error) {
775777

776778
// Decides which column formats to use for a prepared statement. The input is
777779
// an array of type oids, one element per result column.
778-
func decideColumnFormats(colTyps []fieldDesc, forceText bool) (colFmts []format, colFmtData []byte) {
780+
func decideColumnFormats(
781+
colTyps []fieldDesc, forceText bool,
782+
) (colFmts []format, colFmtData []byte) {
779783
if len(colTyps) == 0 {
780784
return nil, colFmtDataAllText
781785
}
@@ -1830,7 +1834,11 @@ func (cn *conn) readParseResponse() {
18301834
}
18311835
}
18321836

1833-
func (cn *conn) readStatementDescribeResponse() (paramTyps []oid.Oid, colNames []string, colTyps []fieldDesc) {
1837+
func (cn *conn) readStatementDescribeResponse() (
1838+
paramTyps []oid.Oid,
1839+
colNames []string,
1840+
colTyps []fieldDesc,
1841+
) {
18341842
for {
18351843
t, r := cn.recv1()
18361844
switch t {
@@ -1918,7 +1926,9 @@ func (cn *conn) postExecuteWorkaround() {
19181926
}
19191927

19201928
// Only for Exec(), since we ignore the returned data
1921-
func (cn *conn) readExecuteResponse(protocolState string) (res driver.Result, commandTag string, err error) {
1929+
func (cn *conn) readExecuteResponse(
1930+
protocolState string,
1931+
) (res driver.Result, commandTag string, err error) {
19221932
for {
19231933
t, r := cn.recv1()
19241934
switch t {
@@ -2089,7 +2099,6 @@ func alnumLowerASCII(ch rune) rune {
20892099
// All Conn implementations should implement the following interfaces: Pinger, SessionResetter, and Validator.
20902100
var _ driver.Pinger = &conn{}
20912101
var _ driver.SessionResetter = &conn{}
2092-
var _ driver.Validator = &conn{}
20932102

20942103
func (cn *conn) ResetSession(ctx context.Context) error {
20952104
// Ensure bad connections are reported: From database/sql/driver:

conn_go115.go

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//go:build go1.15
2+
// +build go1.15
3+
4+
package pq
5+
6+
import "database/sql/driver"
7+
8+
var _ driver.Validator = &conn{}

0 commit comments

Comments
 (0)