Skip to content

Commit 518f06f

Browse files
committed
Update README
1 parent 529a1ab commit 518f06f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -460,12 +460,18 @@ func main() {
460460
A custom driver name can be set via build options: `-ldflags '-X "github.com/go-mysql-org/go-mysql/driver.driverName=gomysql"'`.
461461

462462
This can be useful when using [GORM](https://gorm.io/docs/connecting_to_the_database.html#Customize-Driver):
463+
463464
```go
464-
mysql.Config{
465-
DriverName: "gomysql",
466-
...
467-
}
465+
import (
466+
_ "github.com/go-mysql-org/go-mysql/driver"
467+
"gorm.io/driver/mysql"
468+
"gorm.io/gorm"
469+
)
468470

471+
db, err := gorm.Open(mysql.New(mysql.Config{
472+
DriverName: "gomysql",
473+
DSN: "gorm:[email protected]:3306/test",
474+
}))
469475
```
470476

471477
### Custom NamedValueChecker

0 commit comments

Comments
 (0)