-
Notifications
You must be signed in to change notification settings - Fork 995
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:go-mysql-org/go-mysql into update…
…_readme Signed-off-by: lance6716 <[email protected]>
- Loading branch information
Showing
4 changed files
with
41 additions
and
8 deletions.
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
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 |
---|---|---|
|
@@ -17,6 +17,7 @@ This repo uses [Changelog](CHANGELOG.md). | |
* [Client](#client) - Simple MySQL client. | ||
* [Fake server](#server) - server side of the MySQL protocol, as library. | ||
* [database/sql like driver](#driver) - An alternative `database/sql` driver for MySQL. | ||
* [Logging](#logging) - Custom logging options. | ||
* [Migration](#how-to-migrate-to-this-repo) - Information for how to migrate if you used the old location of this project. | ||
|
||
## Examples | ||
|
@@ -346,7 +347,7 @@ import ( | |
func main() { | ||
// dsn format: "user:password@addr?dbname" | ||
dsn := "[email protected]:3306?test" | ||
db, _ := sql.Open(dsn) | ||
db, _ := sql.Open("mysql", dsn) | ||
db.Close() | ||
} | ||
``` | ||
|
@@ -497,6 +498,29 @@ func main() { | |
|
||
We pass all tests in https://github.com/bradfitz/go-sql-test using go-mysql driver. :-) | ||
|
||
## Logging | ||
|
||
Logging by default is send to stdout. | ||
|
||
To disable logging completely: | ||
```go | ||
import "github.com/siddontang/go-log/log" | ||
... | ||
nullHandler, _ := log.NewNullHandler() | ||
cfg.Logger = log.NewDefault(nullHandler) | ||
``` | ||
|
||
To write logging to any [`io.Writer`](https://pkg.go.dev/io#Writer): | ||
```go | ||
import "github.com/siddontang/go-log/log" | ||
... | ||
w := ... | ||
streamHandler, _ := log.NewStreamHandler(w) | ||
cfg.Logger = log.NewDefault(streamHandler) | ||
``` | ||
|
||
Or you can implement your own [`log.Handler`](https://pkg.go.dev/github.com/siddontang/go-log/log#Handler). | ||
|
||
## How to migrate to this repo | ||
To change the used package in your repo it's enough to add this `replace` directive to your `go.mod`: | ||
``` | ||
|
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
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