File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -460,6 +460,25 @@ func main() {
460
460
}
461
461
```
462
462
463
+ ### Custom Driver Name
464
+
465
+ A custom driver name can be set via build options: ` -ldflags '-X "github.com/go-mysql-org/go-mysql/driver.driverName=gomysql"' ` .
466
+
467
+ This can be useful when using [ GORM] ( https://gorm.io/docs/connecting_to_the_database.html#Customize-Driver ) :
468
+
469
+ ``` go
470
+ import (
471
+ _ " github.com/go-mysql-org/go-mysql/driver"
472
+ " gorm.io/driver/mysql"
473
+ " gorm.io/gorm"
474
+ )
475
+
476
+ db , err := gorm.Open (mysql.New (mysql.Config {
477
+ DriverName : " gomysql" ,
478
+ DSN :
" gorm:[email protected] :3306/test" ,
479
+ }))
480
+ ```
481
+
463
482
### Custom NamedValueChecker
464
483
465
484
Golang allows for custom handling of query arguments before they are passed to the driver
Original file line number Diff line number Diff line change @@ -389,13 +389,15 @@ func (r *rows) Next(dest []sqldriver.Value) error {
389
389
return nil
390
390
}
391
391
392
+ var driverName = "mysql"
393
+
392
394
func init () {
393
395
options ["compress" ] = CompressOption
394
396
options ["collation" ] = CollationOption
395
397
options ["readTimeout" ] = ReadTimeoutOption
396
398
options ["writeTimeout" ] = WriteTimeoutOption
397
399
398
- sql .Register ("mysql" , driver {})
400
+ sql .Register (driverName , driver {})
399
401
}
400
402
401
403
// SetCustomTLSConfig sets a custom TLSConfig for the address (host:port) of the supplied DSN.
You can’t perform that action at this time.
0 commit comments