@@ -217,7 +217,12 @@ func (s *Session) connect(ctx context.Context, host *HostInfo, errorHandler Conn
217217}
218218
219219// dial establishes a connection to a Cassandra node and notifies the session's connectObserver.
220- func (s * Session ) dial (ctx context.Context , host * HostInfo , connConfig * ConnConfig , errorHandler ConnErrorHandler ) (* Conn , error ) {
220+ func (s * Session ) dial (
221+ ctx context.Context ,
222+ host * HostInfo ,
223+ connConfig * ConnConfig ,
224+ errorHandler ConnErrorHandler ,
225+ ) (* Conn , error ) {
221226 var obs ObservedConnect
222227 if s .connectObserver != nil {
223228 obs .Host = host
@@ -238,7 +243,12 @@ func (s *Session) dial(ctx context.Context, host *HostInfo, connConfig *ConnConf
238243// dialWithoutObserver establishes connection to a Cassandra node.
239244//
240245// dialWithoutObserver does not notify the connection observer, so you most probably want to call dial() instead.
241- func (s * Session ) dialWithoutObserver (ctx context.Context , host * HostInfo , cfg * ConnConfig , errorHandler ConnErrorHandler ) (* Conn , error ) {
246+ func (s * Session ) dialWithoutObserver (
247+ ctx context.Context ,
248+ host * HostInfo ,
249+ cfg * ConnConfig ,
250+ errorHandler ConnErrorHandler ,
251+ ) (* Conn , error ) {
242252 dialedHost , err := cfg .HostDialer .DialHost (ctx , host )
243253 if err != nil {
244254 return nil , err
@@ -385,7 +395,11 @@ func (s *startupCoordinator) setupConn(ctx context.Context) error {
385395 return nil
386396}
387397
388- func (s * startupCoordinator ) write (ctx context.Context , frame frameBuilder , startupCompleted * atomic.Bool ) (frame , error ) {
398+ func (s * startupCoordinator ) write (
399+ ctx context.Context ,
400+ frame frameBuilder ,
401+ startupCompleted * atomic.Bool ,
402+ ) (frame , error ) {
389403 select {
390404 case s .frameTicker <- struct {}{}:
391405 case <- ctx .Done ():
@@ -414,7 +428,11 @@ func (s *startupCoordinator) options(ctx context.Context, startupCompleted *atom
414428 return s .startup (ctx , supported .supported , startupCompleted )
415429}
416430
417- func (s * startupCoordinator ) startup (ctx context.Context , supported map [string ][]string , startupCompleted * atomic.Bool ) error {
431+ func (s * startupCoordinator ) startup (
432+ ctx context.Context ,
433+ supported map [string ][]string ,
434+ startupCompleted * atomic.Bool ,
435+ ) error {
418436 m := map [string ]string {
419437 "CQL_VERSION" : s .conn .cfg .CQLVersion ,
420438 "DRIVER_NAME" : driverName ,
@@ -457,7 +475,11 @@ func (s *startupCoordinator) startup(ctx context.Context, supported map[string][
457475 }
458476}
459477
460- func (s * startupCoordinator ) authenticateHandshake (ctx context.Context , authFrame * authenticateFrame , startupCompleted * atomic.Bool ) error {
478+ func (s * startupCoordinator ) authenticateHandshake (
479+ ctx context.Context ,
480+ authFrame * authenticateFrame ,
481+ startupCompleted * atomic.Bool ,
482+ ) error {
461483 if s .conn .auth == nil {
462484 return fmt .Errorf ("authentication required (using %q)" , authFrame .class )
463485 }
@@ -592,7 +614,7 @@ func (c *Conn) heartBeat(ctx context.Context) {
592614
593615 for {
594616 if failures > 5 {
595- c .closeWithError (fmt . Errorf ("gocql: heartbeat failed" ))
617+ c .closeWithError (errors . New ("gocql: heartbeat failed" ))
596618 return
597619 }
598620
@@ -659,10 +681,10 @@ func (c *Conn) processFrame(ctx context.Context, r io.Reader) error {
659681
660682 if c .frameObserver != nil {
661683 c .frameObserver .ObserveFrameHeader (context .Background (), ObservedFrameHeader {
662- Version : protoVersion ( head .version ) ,
684+ Version : head .version ,
663685 Flags : head .flags ,
664686 Stream : int16 (head .stream ),
665- Opcode : frameOp ( head .op ) ,
687+ Opcode : head .op ,
666688 Length : int32 (head .length ),
667689 Start : headStartTime ,
668690 End : headEndTime ,
@@ -822,7 +844,7 @@ func (c *Conn) recvPartialFrames(dst *bytes.Buffer, bytesToRead int) error {
822844 }
823845
824846 if isSelfContained {
825- return fmt . Errorf ("gocql: received self-contained segment, but expected not" )
847+ return errors . New ("gocql: received self-contained segment, but expected not" )
826848 }
827849
828850 if totalLength := dst .Len () + len (frame ); totalLength > dst .Cap () {
@@ -885,7 +907,7 @@ func (c *connReader) Read(p []byte) (n int, err error) {
885907 }
886908 }
887909
888- return
910+ return n , err
889911}
890912
891913func (c * connReader ) Write (b []byte ) (n int , err error ) {
@@ -1177,7 +1199,12 @@ func (c *Conn) exec(ctx context.Context, req frameBuilder, tracer Tracer) (*fram
11771199 return c .execInternal (ctx , req , tracer , true )
11781200}
11791201
1180- func (c * Conn ) execInternal (ctx context.Context , req frameBuilder , tracer Tracer , startupCompleted bool ) (* framer , error ) {
1202+ func (c * Conn ) execInternal (
1203+ ctx context.Context ,
1204+ req frameBuilder ,
1205+ tracer Tracer ,
1206+ startupCompleted bool ,
1207+ ) (* framer , error ) {
11811208 if ctxErr := ctx .Err (); ctxErr != nil {
11821209 return nil , ctxErr
11831210 }
@@ -1394,7 +1421,12 @@ type inflightPrepare struct {
13941421 preparedStatment * preparedStatment
13951422}
13961423
1397- func (c * Conn ) prepareStatement (ctx context.Context , stmt string , tracer Tracer , keyspace string ) (* preparedStatment , error ) {
1424+ func (c * Conn ) prepareStatement (
1425+ ctx context.Context ,
1426+ stmt string ,
1427+ tracer Tracer ,
1428+ keyspace string ,
1429+ ) (* preparedStatment , error ) {
13981430 stmtCacheKey := c .session .stmtsLRU .keyFor (c .host .HostID (), keyspace , stmt )
13991431 flight , ok := c .session .stmtsLRU .execIfMissing (stmtCacheKey , func (lru * lru.Cache ) * inflightPrepare {
14001432 flight := & inflightPrepare {
@@ -1546,7 +1578,9 @@ func (c *Conn) executeQuery(ctx context.Context, qry *Query) *Iter {
15461578 }
15471579
15481580 if len (values ) != info .request .actualColCount {
1549- return & Iter {err : fmt .Errorf ("gocql: expected %d values send got %d" , info .request .actualColCount , len (values ))}
1581+ return & Iter {
1582+ err : fmt .Errorf ("gocql: expected %d values send got %d" , info .request .actualColCount , len (values )),
1583+ }
15501584 }
15511585
15521586 params .values = make ([]queryValues , len (values ))
@@ -1560,7 +1594,8 @@ func (c *Conn) executeQuery(ctx context.Context, qry *Query) *Iter {
15601594 }
15611595
15621596 // if the metadata was not present in the response then we should not skip it
1563- params .skipMeta = ! (c .session .cfg .DisableSkipMetadata || qry .disableSkipMetadata ) && info != nil && info .response .flags & flagNoMetaData == 0
1597+ params .skipMeta = ! (c .session .cfg .DisableSkipMetadata || qry .disableSkipMetadata ) && info != nil &&
1598+ info .response .flags & flagNoMetaData == 0
15641599
15651600 frame = & writeExecuteFrame {
15661601 preparedID : info .id ,
@@ -1791,7 +1826,14 @@ func (c *Conn) executeBatch(ctx context.Context, batch *Batch) *Iter {
17911826 }
17921827
17931828 if len (values ) != info .request .actualColCount {
1794- return & Iter {err : fmt .Errorf ("gocql: batch statement %d expected %d values send got %d" , i , info .request .actualColCount , len (values ))}
1829+ return & Iter {
1830+ err : fmt .Errorf (
1831+ "gocql: batch statement %d expected %d values send got %d" ,
1832+ i ,
1833+ info .request .actualColCount ,
1834+ len (values ),
1835+ ),
1836+ }
17951837 }
17961838
17971839 b .preparedID = info .id
@@ -1876,7 +1918,8 @@ func (c *Conn) querySystemPeers(ctx context.Context, version cassVersion) *Iter
18761918
18771919 err := iter .checkErrAndNotFound ()
18781920 if err != nil {
1879- if errFrame , ok := err .(errorFrame ); ok && errFrame .code == ErrCodeInvalid { // system.peers_v2 not found, try system.peers
1921+ if errFrame , ok := err .(errorFrame ); ok &&
1922+ errFrame .code == ErrCodeInvalid { // system.peers_v2 not found, try system.peers
18801923 c .mu .Lock ()
18811924 c .isSchemaV2 = false
18821925 c .mu .Unlock ()
@@ -1908,17 +1951,19 @@ func (c *Conn) awaitSchemaAgreement(ctx context.Context) (err error) {
19081951
19091952 versions = make (map [string ]struct {})
19101953
1911- rows , err := iter .SliceMap ()
1954+ var rows []map [string ]interface {}
1955+ rows , err = iter .SliceMap ()
19121956 if err != nil {
19131957 goto cont
19141958 }
19151959
19161960 for _ , row := range rows {
1917- h , err := NewHostInfo (c .host .ConnectAddress (), c .session .cfg .Port )
1961+ var host * HostInfo
1962+ host , err = NewHostInfo (c .host .ConnectAddress (), c .session .cfg .Port )
19181963 if err != nil {
19191964 goto cont
19201965 }
1921- host , err : = c .session .hostInfoFromMap (row , h )
1966+ host , err = c .session .hostInfoFromMap (row , host )
19221967 if err != nil {
19231968 goto cont
19241969 }
0 commit comments