Enable unconvert linter#2543
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Enables the unconvert linter in golangci-lint and applies its suggested simplifications across the codebase by removing redundant type conversions (e.g., string(x) where x is already a string).
Changes:
- Enable
unconvertin.golangci.yml. - Remove redundant conversions in core packages (
pgconn,pgproto3,pgtype,stdlib, rootpgx) and update affected tests accordingly.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tracer_test.go | Removes redundant ctxKey conversions in tracer tests. |
| stdlib/sql.go | Simplifies column name assignment by removing redundant string() conversion. |
| rows.go | Simplifies RowToMap field-name handling by removing redundant string() conversion. |
| pgtype/uint64.go | Removes redundant uint64(...) conversions in encoding/decoding paths. |
| pgtype/tsvector.go | Simplifies bit-packing expression by removing redundant uint16(...) conversion. |
| pgtype/numeric.go | Removes redundant string(...) conversion in scientific scanning path. |
| pgtype/float8.go | Removes redundant string(...) conversion prior to ParseFloat. |
| pgtype/float4.go | Removes redundant string(...) conversion prior to ParseFloat. |
| pgproto3/describe.go | Removes redundant byte(...) conversion when assigning ObjectType. |
| pgproto3/close.go | Removes redundant byte(...) conversion when assigning ObjectType. |
| pgconn/pgconn_test.go | Updates tests to compare field names directly as string without conversion. |
| pgconn/pgconn.go | Removes redundant conversions in protocol version handling and error mapping. |
| named_args.go | Removes redundant namedArg(...) conversion when appending lexer parts. |
| conn.go | Removes redundant uint32(...) conversion when indexing by DataTypeOID. |
| .golangci.yml | Enables the unconvert linter. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Owner
|
LGTM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Simplify code with
unconvertlinter: