From 506416d3f6cd2414b2cdd0d5eab5eea08190e799 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Wed, 4 Dec 2024 03:41:20 +0100 Subject: [PATCH 1/2] README: fix example for database/sql (#955) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a768a3747..4f1a5f650 100644 --- a/README.md +++ b/README.md @@ -342,7 +342,7 @@ import ( func main() { // dsn format: "user:password@addr?dbname" dsn := "root@127.0.0.1:3306?test" - db, _ := sql.Open(dsn) + db, _ := sql.Open("mysql", dsn) db.Close() } ``` From 615af30bd3d66d326d66925046dbec42d74545d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Fri, 6 Dec 2024 09:38:31 +0100 Subject: [PATCH 2/2] Update README (#950) * Update README * Update example about GTID * Add description to examples * Add 'go mod edit' line * Remove donate and feedback sessions, add credits --------- Signed-off-by: lance6716 Co-authored-by: lance6716 --- README.md | 65 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 4f1a5f650..facc91b4b 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,34 @@ # go-mysql -A pure go library to handle MySQL network protocol and replication. +A pure go library to handle MySQL network protocol and replication as used by MySQL and MariaDB. ![semver](https://img.shields.io/github/v/tag/go-mysql-org/go-mysql) ![example workflow](https://github.com/go-mysql-org/go-mysql/actions/workflows/ci.yml/badge.svg) ![gomod version](https://img.shields.io/github/go-mod/go-version/go-mysql-org/go-mysql/master) - -## 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`: -``` -replace github.com/siddontang/go-mysql => github.com/go-mysql-org/go-mysql v1.10.0 -``` - -v1.10.0 - is the last tag in repo, feel free to choose what you want. +[![Go Reference](https://pkg.go.dev/badge/github.com/go-mysql-org/go-mysql.svg)](https://pkg.go.dev/github.com/go-mysql-org/go-mysql) ## Changelog This repo uses [Changelog](CHANGELOG.md). --- # Content -* [Replication](#replication) -* [Incremental dumping](#canal) -* [Client](#client) -* [Fake server](#server) -* [database/sql like driver](#driver) -* [Logging](#logging) +* [Replication](#replication) - Process events from a binlog stream. +* [Incremental dumping](#canal) - Sync from MySQL to Redis, Elasticsearch, etc. +* [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 + +The `cmd` directory contains example applications that can be build by running `make build` in the root of the project. The resulting binaries will be places in `bin/`. + +- `go-binlogparser`: parses a binlog file at a given offset +- `go-canal`: streams binlog events from a server to canal +- `go-mysqlbinlog`: streams binlog events +- `go-mysqldump`: like `mysqldump`, but in Go +- `go-mysqlserver`: fake MySQL server ## Replication @@ -55,9 +59,10 @@ syncer := replication.NewBinlogSyncer(cfg) streamer, _ := syncer.StartSync(mysql.Position{binlogFile, binlogPos}) // or you can start a gtid replication like +// gtidSet, _ := mysql.ParseGTIDSet(mysql.MySQLFlavor, "de278ad0-2106-11e4-9f8e-6edd0ca20947:1-2") // streamer, _ := syncer.StartSyncGTID(gtidSet) -// the mysql GTID set likes this "de278ad0-2106-11e4-9f8e-6edd0ca20947:1-2" -// the mariadb GTID set likes this "0-1-100" +// the mysql GTID set is like this "de278ad0-2106-11e4-9f8e-6edd0ca20947:1-2" and uses mysql.MySQLFlavor +// the mariadb GTID set is like this "0-1-100" and uses mysql.MariaDBFlavor for { ev, _ := streamer.GetEvent(context.Background()) @@ -111,7 +116,7 @@ Query: DROP TABLE IF EXISTS `test_replication` /* generated by server */ ## Canal -Canal is a package that can sync your MySQL into everywhere, like Redis, Elasticsearch. +Canal is a package that can sync your MySQL into everywhere, like Redis, Elasticsearch. First, canal will dump your MySQL data then sync changed data using binlog incrementally. @@ -161,7 +166,7 @@ func main() { } ``` -You can see [go-mysql-elasticsearch](https://github.com/siddontang/go-mysql-elasticsearch) for how to sync MySQL data into Elasticsearch. +You can see [go-mysql-elasticsearch](https://github.com/go-mysql-org/go-mysql-elasticsearch) for how to sync MySQL data into Elasticsearch. ## Client @@ -516,17 +521,19 @@ import "github.com/siddontang/go-log/log" Or you can implement your own [`log.Handler`](https://pkg.go.dev/github.com/siddontang/go-log/log#Handler). -## Donate - -If you like the project and want to buy me a cola, you can through: - -|PayPal|微信| -|------|---| -|[![](https://www.paypalobjects.com/webstatic/paypalme/images/pp_logo_small.png)](https://paypal.me/siddontang)|[![](https://github.com/siddontang/blog/blob/master/donate/weixin.png)| +## 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`: +``` +replace github.com/siddontang/go-mysql => github.com/go-mysql-org/go-mysql v1.10.0 +``` -## Feedback +This can be done by running this command: +``` +go mod edit -replace=github.com/siddontang/go-mysql=github.com/go-mysql-org/go-mysql@v1.10.0 +``` -go-mysql is still in development, your feedback is very welcome. +v1.10.0 - is the last tag in repo, feel free to choose what you want. +## Credits -Gmail: siddontang@gmail.com +go-mysql was started by @siddontang and has many [contributors](https://github.com/go-mysql-org/go-mysql/graphs/contributors)