{"id":16933586,"url":"https://github.com/shogo82148/go-mysql-pool","last_synced_at":"2025-04-11T18:42:10.593Z","repository":{"id":228205069,"uuid":"773384251","full_name":"shogo82148/go-mysql-pool","owner":"shogo82148","description":"create MySQL database for testing","archived":false,"fork":false,"pushed_at":"2025-04-09T12:42:38.000Z","size":48,"stargazers_count":12,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T12:44:51.491Z","etag":null,"topics":["go","golang","mysql"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/shogo82148/go-mysql-pool","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shogo82148.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-17T14:19:45.000Z","updated_at":"2025-04-09T12:42:35.000Z","dependencies_parsed_at":"2024-03-17T16:26:09.435Z","dependency_job_id":"479dbc34-b0f0-459d-824e-23692221208e","html_url":"https://github.com/shogo82148/go-mysql-pool","commit_stats":null,"previous_names":["shogo82148/go-mysql-pool"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shogo82148%2Fgo-mysql-pool","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shogo82148%2Fgo-mysql-pool/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shogo82148%2Fgo-mysql-pool/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shogo82148%2Fgo-mysql-pool/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shogo82148","download_url":"https://codeload.github.com/shogo82148/go-mysql-pool/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248460876,"owners_count":21107563,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","mysql"],"created_at":"2024-10-13T20:49:50.668Z","updated_at":"2025-04-11T18:42:10.573Z","avatar_url":"https://github.com/shogo82148.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Reference](https://pkg.go.dev/badge/github.com/shogo82148/go-mysql-pool.svg)](https://pkg.go.dev/github.com/shogo82148/go-mysql-pool)\n[![test](https://github.com/shogo82148/go-mysql-pool/actions/workflows/test.yaml/badge.svg)](https://github.com/shogo82148/go-mysql-pool/actions/workflows/test.yaml)\n\n# go-mysql-pool\n\nGo-MySQL-Pool is a package that simplifies the creation and management of MySQL database pools for testing and development purposes.\n\n## Synopsis\n\n```go\npackage example_test\n\nimport (\n    \"context\"\n    \"testing\"\n\n    \"github.com/go-sql-driver/mysql\"\n    \"github.com/shogo82148/go-mysql-pool\"\n)\n\nvar pool *mysqlpool.Pool\n\nfunc TestMain(m *testing.M) {\n    // setup the pool\n    cfg := mysql.NewConfig()\n    cfg.User = \"username\"\n    cfg.Passwd = \"password\"\n    cfg.Net = \"tcp\"\n    cfg.Addr = \"127.0.0.1:3306\"\n    pool = \u0026mysqlpool.Pool{\n        MySQLConfig: cfg,\n        DDL:         \"CREATE TABLE foo (id INT PRIMARY KEY)\",\n    }\n    defer pool.Close() // cleanup all databases\n\n    m.Run()\n}\n\nfunc TestFooBar(t *testing.T) {\n    // get *sql.DB from the pool.\n    db, err := pool.Get(context.Background())\n    if err != nil {\n        t.Fatal(err)\n    }\n    t.Cleanup(func() {\n        pool.Put(db)\n    })\n\n    // use db for testing.\n}\n```\n\n## Reference\n\n- [Go で MySQL を使ったテストを書くときにつかうユーティリティーライブラリを作った](https://shogo82148.github.io/blog/2024/03/20/2024-03-20-go-mysql-pool/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshogo82148%2Fgo-mysql-pool","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshogo82148%2Fgo-mysql-pool","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshogo82148%2Fgo-mysql-pool/lists"}