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

Use a custom dialer to create connection with db #801

Closed
XiaoYiXiaoYang opened this issue May 20, 2024 · 2 comments
Closed

Use a custom dialer to create connection with db #801

XiaoYiXiaoYang opened this issue May 20, 2024 · 2 comments

Comments

@XiaoYiXiaoYang
Copy link

XiaoYiXiaoYang commented May 20, 2024

Is your feature request related to a problem? Please describe.
when i use "github.com/lib/pq" as sql driver to connect to postgressql
i can use func DialOpen(d Dialer, dsn string) (_ driver.Conn, err error) method to connect to db with my custom dialer

and i suggest "github.com/denisenkom/go-mssqldb" need a same one

Describe the solution you'd like
add a method like func DialOpen(d Dialer, dsn string) (_ driver.Conn, err error) before create connection

Describe alternatives you've considered

Additional context
"github.com/go-sql-driver/mysql" have a similar method to use my own custom dialer, it is func RegisterDial(network string, dial DialFunc)

@niudaii
Copy link

niudaii commented Jun 5, 2024

Please see #665

type ProxyDialer struct {
	dialer proxy.Dialer
}

func (d ProxyDialer) DialContext(ctx context.Context, network string, addr string) (net.Conn, error) {
	return d.dialer.Dial(network, addr)
}

@XiaoYiXiaoYang
Copy link
Author

thanks~~, it works for me good.

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

No branches or pull requests

3 participants