-
Notifications
You must be signed in to change notification settings - Fork 991
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
driver: allow configuration of the driver name (#958)
* driver: allow configuration of the driver name * Update README * Update README --------- Co-authored-by: lance6716 <[email protected]>
- Loading branch information
Showing
2 changed files
with
22 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -460,6 +460,25 @@ func main() { | |
} | ||
``` | ||
|
||
### Custom Driver Name | ||
|
||
A custom driver name can be set via build options: `-ldflags '-X "github.com/go-mysql-org/go-mysql/driver.driverName=gomysql"'`. | ||
|
||
This can be useful when using [GORM](https://gorm.io/docs/connecting_to_the_database.html#Customize-Driver): | ||
|
||
```go | ||
import ( | ||
_ "github.com/go-mysql-org/go-mysql/driver" | ||
"gorm.io/driver/mysql" | ||
"gorm.io/gorm" | ||
) | ||
|
||
db, err := gorm.Open(mysql.New(mysql.Config{ | ||
DriverName: "gomysql", | ||
DSN: "gorm:[email protected]:3306/test", | ||
})) | ||
``` | ||
|
||
### Custom NamedValueChecker | ||
|
||
Golang allows for custom handling of query arguments before they are passed to the driver | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters