Skip to content

replace interface{} with any in db.go according to modern 1.18+ go standards - #2677

Merged
otoolep merged 1 commit into
rqlite:masterfrom
DARSHANR007:cleanup/replace-interface-with-any
May 20, 2026
Merged

otoolep merged 1 commit into
rqlite:masterfrom
DARSHANR007:cleanup/replace-interface-with-any

Conversation

@DARSHANR007

Copy link
Copy Markdown
Contributor

Replaced interface with any in go available from 1.18+ in db.go

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request replaces the interface{} type with any in the qualifyRowColumns function within db/db.go. A review comment suggests implementing a check for the type assertion of the driver connection to ensure safety and prevent potential runtime panics.

Comment thread db/db.go
Comment on lines +1918 to 1919
err := conn.Raw(func(driverConn any) error {
sqliteConn := driverConn.(*sqlite3.SQLiteConn)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The type assertion driverConn.(*sqlite3.SQLiteConn) is performed without checking the success of the assertion. While rqlite currently uses the go-sqlite3 driver, it is safer to use the "comma-ok" idiom to avoid a potential panic if the underlying driver connection is not of the expected type (e.g., if a wrapper or different driver is used in the future). Additionally, while replacing interface{} with any is a good modernization for Go 1.18+, it is worth noting that this is a type alias and does not provide performance benefits as implied by the PR title.

	err := conn.Raw(func(driverConn any) error {
		sqliteConn, ok := driverConn.(*sqlite3.SQLiteConn)
		if !ok {
			return fmt.Errorf("unexpected driver connection type: %T", driverConn)
		}
References
  1. Enforce defensive programming by ensuring type assertions are checked to prevent runtime panics.

@DARSHANR007 DARSHANR007 changed the title perf: replace interface{} with any in db.go replace interface{} with any in db.go according to modern 1.18+ go standards May 20, 2026
@otoolep
otoolep merged commit 57a37a7 into rqlite:master May 20, 2026
@otoolep

otoolep commented May 20, 2026

Copy link
Copy Markdown
Member

Thanks for your contribution @DARSHANR007

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.

2 participants