@@ -27,12 +27,12 @@ var (
2727 ErrNotSupported = errors .New ("pq: Unsupported command" )
2828 ErrInFailedTransaction = errors .New ("pq: Could not complete operation in a failed transaction" )
2929 ErrSSLNotSupported = errors .New ("pq: SSL is not enabled on the server" )
30- ErrSSLKeyHasWorldPermissions = errors .New ("pq: Private key file has group or world access. Permissions should be u=rw (0600) or less. " )
31- ErrCouldNotDetectUsername = errors .New ("pq: Could not detect default username. Please provide one explicitly. " )
30+ ErrSSLKeyHasWorldPermissions = errors .New ("pq: Private key file has group or world access. Permissions should be u=rw (0600) or less" )
31+ ErrCouldNotDetectUsername = errors .New ("pq: Could not detect default username. Please provide one explicitly" )
3232
3333 errUnexpectedReady = errors .New ("unexpected ReadyForQuery" )
3434 errNoRowsAffected = errors .New ("no RowsAffected available after the empty statement" )
35- errNoLastInsertId = errors .New ("no LastInsertId available after the empty statement" )
35+ errNoLastInsertID = errors .New ("no LastInsertId available after the empty statement" )
3636)
3737
3838type Driver struct {}
@@ -131,7 +131,7 @@ type conn struct {
131131}
132132
133133// Handle driver-side settings in parsed connection string.
134- func (c * conn ) handleDriverSettings (o values ) (err error ) {
134+ func (cn * conn ) handleDriverSettings (o values ) (err error ) {
135135 boolSetting := func (key string , val * bool ) error {
136136 if value , ok := o [key ]; ok {
137137 if value == "yes" {
@@ -145,18 +145,18 @@ func (c *conn) handleDriverSettings(o values) (err error) {
145145 return nil
146146 }
147147
148- err = boolSetting ("disable_prepared_binary_result" , & c .disablePreparedBinaryResult )
148+ err = boolSetting ("disable_prepared_binary_result" , & cn .disablePreparedBinaryResult )
149149 if err != nil {
150150 return err
151151 }
152- err = boolSetting ("binary_parameters" , & c .binaryParameters )
152+ err = boolSetting ("binary_parameters" , & cn .binaryParameters )
153153 if err != nil {
154154 return err
155155 }
156156 return nil
157157}
158158
159- func (c * conn ) handlePgpass (o values ) {
159+ func (cn * conn ) handlePgpass (o values ) {
160160 // if a password was supplied, do not process .pgpass
161161 if _ , ok := o ["password" ]; ok {
162162 return
@@ -229,10 +229,10 @@ func (c *conn) handlePgpass(o values) {
229229 }
230230}
231231
232- func (c * conn ) writeBuf (b byte ) * writeBuf {
233- c .scratch [0 ] = b
232+ func (cn * conn ) writeBuf (b byte ) * writeBuf {
233+ cn .scratch [0 ] = b
234234 return & writeBuf {
235- buf : c .scratch [:5 ],
235+ buf : cn .scratch [:5 ],
236236 pos : 1 ,
237237 }
238238}
@@ -310,9 +310,8 @@ func DialOpen(d Dialer, name string) (_ driver.Conn, err error) {
310310 u , err := userCurrent ()
311311 if err != nil {
312312 return nil , err
313- } else {
314- o ["user" ] = u
315313 }
314+ o ["user" ] = u
316315 }
317316
318317 cn := & conn {
@@ -698,7 +697,7 @@ var emptyRows noRows
698697var _ driver.Result = noRows {}
699698
700699func (noRows ) LastInsertId () (int64 , error ) {
701- return 0 , errNoLastInsertId
700+ return 0 , errNoLastInsertID
702701}
703702
704703func (noRows ) RowsAffected () (int64 , error ) {
@@ -840,16 +839,15 @@ func (cn *conn) query(query string, args []driver.Value) (_ *rows, err error) {
840839 rows .colNames , rows .colFmts , rows .colTyps = cn .readPortalDescribeResponse ()
841840 cn .postExecuteWorkaround ()
842841 return rows , nil
843- } else {
844- st := cn .prepareTo (query , "" )
845- st .exec (args )
846- return & rows {
847- cn : cn ,
848- colNames : st .colNames ,
849- colTyps : st .colTyps ,
850- colFmts : st .colFmts ,
851- }, nil
852842 }
843+ st := cn .prepareTo (query , "" )
844+ st .exec (args )
845+ return & rows {
846+ cn : cn ,
847+ colNames : st .colNames ,
848+ colTyps : st .colTyps ,
849+ colFmts : st .colFmts ,
850+ }, nil
853851}
854852
855853// Implement the optional "Execer" interface for one-shot queries
@@ -876,17 +874,16 @@ func (cn *conn) Exec(query string, args []driver.Value) (res driver.Result, err
876874 cn .postExecuteWorkaround ()
877875 res , _ , err = cn .readExecuteResponse ("Execute" )
878876 return res , err
879- } else {
880- // Use the unnamed statement to defer planning until bind
881- // time, or else value-based selectivity estimates cannot be
882- // used.
883- st := cn .prepareTo (query , "" )
884- r , err := st .Exec (args )
885- if err != nil {
886- panic (err )
887- }
888- return r , err
889877 }
878+ // Use the unnamed statement to defer planning until bind
879+ // time, or else value-based selectivity estimates cannot be
880+ // used.
881+ st := cn .prepareTo (query , "" )
882+ r , err := st .Exec (args )
883+ if err != nil {
884+ panic (err )
885+ }
886+ return r , err
890887}
891888
892889func (cn * conn ) send (m * writeBuf ) {
@@ -1147,10 +1144,10 @@ const formatText format = 0
11471144const formatBinary format = 1
11481145
11491146// One result-column format code with the value 1 (i.e. all binary).
1150- var colFmtDataAllBinary [] byte = []byte {0 , 1 , 0 , 1 }
1147+ var colFmtDataAllBinary = []byte {0 , 1 , 0 , 1 }
11511148
11521149// No result-column format codes (i.e. all text).
1153- var colFmtDataAllText [] byte = []byte {0 , 0 }
1150+ var colFmtDataAllText = []byte {0 , 0 }
11541151
11551152type stmt struct {
11561153 cn * conn
@@ -1515,7 +1512,7 @@ func (cn *conn) sendBinaryModeQuery(query string, args []driver.Value) {
15151512 cn .send (b )
15161513}
15171514
1518- func (c * conn ) processParameterStatus (r * readBuf ) {
1515+ func (cn * conn ) processParameterStatus (r * readBuf ) {
15191516 var err error
15201517
15211518 param := r .string ()
@@ -1526,22 +1523,22 @@ func (c *conn) processParameterStatus(r *readBuf) {
15261523 var minor int
15271524 _ , err = fmt .Sscanf (r .string (), "%d.%d.%d" , & major1 , & major2 , & minor )
15281525 if err == nil {
1529- c .parameterStatus .serverVersion = major1 * 10000 + major2 * 100 + minor
1526+ cn .parameterStatus .serverVersion = major1 * 10000 + major2 * 100 + minor
15301527 }
15311528
15321529 case "TimeZone" :
1533- c .parameterStatus .currentLocation , err = time .LoadLocation (r .string ())
1530+ cn .parameterStatus .currentLocation , err = time .LoadLocation (r .string ())
15341531 if err != nil {
1535- c .parameterStatus .currentLocation = nil
1532+ cn .parameterStatus .currentLocation = nil
15361533 }
15371534
15381535 default :
15391536 // ignore
15401537 }
15411538}
15421539
1543- func (c * conn ) processReadyForQuery (r * readBuf ) {
1544- c .txnStatus = transactionStatus (r .byte ())
1540+ func (cn * conn ) processReadyForQuery (r * readBuf ) {
1541+ cn .txnStatus = transactionStatus (r .byte ())
15451542}
15461543
15471544func (cn * conn ) readReadyForQuery () {
@@ -1556,9 +1553,9 @@ func (cn *conn) readReadyForQuery() {
15561553 }
15571554}
15581555
1559- func (c * conn ) processBackendKeyData (r * readBuf ) {
1560- c .processID = r .int32 ()
1561- c .secretKey = r .int32 ()
1556+ func (cn * conn ) processBackendKeyData (r * readBuf ) {
1557+ cn .processID = r .int32 ()
1558+ cn .secretKey = r .int32 ()
15621559}
15631560
15641561func (cn * conn ) readParseResponse () {
0 commit comments