77 "encoding/pem"
88 "errors"
99 "fmt"
10- "io"
1110 "maps"
1211 "math"
1312 "net"
@@ -308,9 +307,7 @@ func ParseConfigWithOptions(connString string, options ParseConfigOptions) (*Con
308307 User : settings ["user" ],
309308 Password : settings ["password" ],
310309 RuntimeParams : make (map [string ]string ),
311- BuildFrontend : func (r io.Reader , w io.Writer ) * pgproto3.Frontend {
312- return pgproto3 .NewFrontend (r , w )
313- },
310+ BuildFrontend : pgproto3 .NewFrontend ,
314311 BuildContextWatcherHandler : func (pgConn * PgConn ) ctxwatch.Handler {
315312 return & DeadlineContextWatcherHandler {Conn : pgConn .conn }
316313 },
@@ -643,8 +640,9 @@ func parseKeywordValueSettings(s string) (map[string]string, error) {
643640
644641 key = strings .Trim (s [:eqIdx ], " \t \n \r \v \f " )
645642 s = strings .TrimLeft (s [eqIdx + 1 :], " \t \n \r \v \f " )
646- if len (s ) == 0 {
647- } else if s [0 ] != '\'' {
643+ switch {
644+ case len (s ) == 0 :
645+ case s [0 ] != '\'' :
648646 end := 0
649647 for ; end < len (s ); end ++ {
650648 if asciiSpace [s [end ]] == 1 {
@@ -657,11 +655,11 @@ func parseKeywordValueSettings(s string) (map[string]string, error) {
657655 }
658656 }
659657 }
660- val = strings .Replace (strings .Replace (s [:end ], "\\ \\ " , "\\ " , - 1 ), "\\ '" , "'" , - 1 )
658+ val = strings .ReplaceAll (strings .ReplaceAll (s [:end ], "\\ \\ " , "\\ " ), "\\ '" , "'" )
661659 // Consume the value and trim any subsequent whitespace so that
662660 // multiple trailing spaces don't cause a spurious parse failure.
663661 s = strings .TrimLeft (s [end :], " \t \n \r \v \f " )
664- } else { // quoted string
662+ default : // quoted string
665663 s = s [1 :]
666664 end := 0
667665 for ; end < len (s ); end ++ {
@@ -675,7 +673,7 @@ func parseKeywordValueSettings(s string) (map[string]string, error) {
675673 if end == len (s ) {
676674 return nil , errors .New ("unterminated quoted string in connection info string" )
677675 }
678- val = strings .Replace (strings .Replace (s [:end ], "\\ \\ " , "\\ " , - 1 ), "\\ '" , "'" , - 1 )
676+ val = strings .ReplaceAll (strings .ReplaceAll (s [:end ], "\\ \\ " , "\\ " ), "\\ '" , "'" )
679677 // Consume the closing quote and any subsequent whitespace.
680678 s = strings .TrimLeft (s [end + 1 :], " \t \n \r \v \f " )
681679 }
0 commit comments