Skip to content

Enable unconvert linter#2543

Merged
jackc merged 2 commits into
jackc:masterfrom
alexandear-org:enable-unconvert
May 8, 2026
Merged

Enable unconvert linter#2543
jackc merged 2 commits into
jackc:masterfrom
alexandear-org:enable-unconvert

Conversation

@alexandear
Copy link
Copy Markdown
Contributor

Simplify code with unconvert linter:

go install github.com/mdempsky/unconvert@latest
unconvert -apply ./...

Copilot AI review requested due to automatic review settings April 27, 2026 11:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 unconvert in .golangci.yml.
  • Remove redundant conversions in core packages (pgconn, pgproto3, pgtype, stdlib, root pgx) 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.

Comment thread .golangci.yml
@jackc jackc merged commit cfd733d into jackc:master May 8, 2026
14 checks passed
@jackc
Copy link
Copy Markdown
Owner

jackc commented May 8, 2026

LGTM

@alexandear alexandear deleted the enable-unconvert branch May 9, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants