Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,15 @@ func (d MySQLDriver) OpenConnector(dsn string) (driver.Connector, error) {
cfg: cfg,
}, nil
}

// Connect connects to MySQL server.
// You can use this function to create custom connector which dynamically
// change the config. The cfg object must not be changed during calling
// this function.
func Connect(ctx context.Context, cfg *Config) (driver.Conn, error) {

Choose a reason for hiding this comment

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

Why use a pointer here if it's sensitive to concurrent changes?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because shallow copy of the config object is not a right way to copy config object.

connector, err := NewConnector(cfg)
if err != nil {
return nil, err
}
return connector.Connect(ctx)
}