Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly implement database/sql/driver.Driver for better wrappability #1005

Merged

Conversation

igorwwwwwwwwwwwwwwwwwwww
Copy link
Contributor

I was trying to wrap pq with instrumentedsql, but it does not implement the database/sql/driver.Driver type.

Minimal example:

package main

import (
	"database/sql"

	"github.com/lib/pq"
	"github.com/luna-duclos/instrumentedsql"
	instrumentedsqltrace "github.com/luna-duclos/instrumentedsql/opentracing"
)

func main() {
	sql.Register("instrumented-postgres", instrumentedsql.WrapDriver(pq.Driver{}, instrumentedsql.WithTracer(instrumentedsqltrace.NewTracer(false))))
}

Compile error:

./minimal.go:12:76: cannot use pq.Driver literal (type pq.Driver) as type driver.Driver in argument to instrumentedsql.WrapDriver:
	pq.Driver does not implement driver.Driver (Open method has pointer receiver)

This patch aims to address this by changing the pointer receiver to a value receiver.

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