{"id":13764067,"url":"https://github.com/thedevsaddam/retry","last_synced_at":"2025-04-26T12:22:16.394Z","repository":{"id":57495217,"uuid":"122866770","full_name":"thedevsaddam/retry","owner":"thedevsaddam","description":"Simple and easy retry mechanism package for Go","archived":false,"fork":false,"pushed_at":"2022-01-04T07:54:02.000Z","size":9,"stargazers_count":67,"open_issues_count":0,"forks_count":6,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-26T10:34:13.311Z","etag":null,"topics":["goretry","retry","retry-go","retry-mechanism"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/thedevsaddam/retry","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/thedevsaddam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-25T19:08:03.000Z","updated_at":"2025-03-31T09:31:36.000Z","dependencies_parsed_at":"2022-08-31T12:42:03.346Z","dependency_job_id":null,"html_url":"https://github.com/thedevsaddam/retry","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedevsaddam%2Fretry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedevsaddam%2Fretry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedevsaddam%2Fretry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thedevsaddam%2Fretry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thedevsaddam","download_url":"https://codeload.github.com/thedevsaddam/retry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250976115,"owners_count":21516878,"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":["goretry","retry","retry-go","retry-mechanism"],"created_at":"2024-08-03T15:01:11.772Z","updated_at":"2025-04-26T12:22:16.369Z","avatar_url":"https://github.com/thedevsaddam.png","language":"Go","funding_links":[],"categories":["Utilities","公用事业公司","工具库","实用工具","工具库`可以提升效率的通用代码库和工具`","Utility"],"sub_categories":["Utility/Miscellaneous","实用程序/Miscellaneous","HTTP Clients","Advanced Console UIs","查询语","交流","Fail injection"],"readme":"Retry\n==================\n\n[![Build Status](https://travis-ci.org/thedevsaddam/retry.svg?branch=master)](https://travis-ci.org/thedevsaddam/retry)\n[![Project status](https://img.shields.io/badge/version-1.2-green.svg)](https://github.com/thedevsaddam/retry/releases)\n[![Go Report Card](https://goreportcard.com/badge/github.com/thedevsaddam/retry)](https://goreportcard.com/report/github.com/thedevsaddam/retry)\n[![Coverage Status](https://coveralls.io/repos/github/thedevsaddam/retry/badge.svg?branch=master)](https://coveralls.io/github/thedevsaddam/retry?branch=master)\n[![GoDoc](https://godoc.org/github.com/thedevsaddam/retry?status.svg)](https://pkg.go.dev/github.com/thedevsaddam/retry)\n[![License](https://img.shields.io/dub/l/vibe-d.svg)](https://github.com/thedevsaddam/retry/blob/dev/LICENSE.md)\n\n\nSimple and easy retry mechanism package for Go\n\n### Installation\n\nInstall the package using\n```go\n$ go get github.com/thedevsaddam/retry\n```\n\n### Usage\n\nTo use the package import it in your `*.go` code\n```go\nimport \"github.com/thedevsaddam/retry\"\n```\n\n### Example\n\nSimply retry a function to execute for max 10 times with interval of 1 second\n\n```go\n\npackage main\n\nimport (\n\t\"fmt\"\n\t\"time\"\n\n\t\"github.com/thedevsaddam/retry\"\n)\n\nfunc main() {\n\ti := 1 // lets assume we expect i to be a value of 8\n\terr := retry.DoFunc(10, 1*time.Second, func() error {\n\t\tfmt.Printf(\"trying for: %dth time\\n\", i)\n\t\ti++\n\t\tif i \u003e 7 {\n\t\t\treturn nil\n\t\t}\n\t\treturn fmt.Errorf(\"i = %d is still low value\", i)\n\t})\n\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfmt.Println(\"Got our expected result: \", i)\n}\n\n```\n\nWe can execute function from other package with arguments and return values\n\n```go\n\npackage main\n\nimport (\n\t\"errors\"\n\t\"log\"\n\t\"time\"\n\n\t\"github.com/thedevsaddam/retry\"\n)\n\nfunc div(a, b float64) (float64, error) {\n\tif b == 0 {\n\t\treturn 0, errors.New(\"Can not divide by zero\")\n\t}\n\treturn a / b, nil\n}\n\nfunc main() {\n\ta := 20.6\n\tb := 3.7 // if we assign 0.0 to b, it will cause an error and will retry for 3 times\n\tres, err := retry.Do(3, 5*time.Second, div, a, b)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tlog.Println(res)\n}\n\n```\n\n### **Contribution**\nIf you are interested to make the package better please send pull requests or create an issue so that others can fix. Read the [contribution guide here](CONTRIBUTING.md). \n\n### **License**\nThe **retry** is an open-source software licensed under the [MIT License](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedevsaddam%2Fretry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthedevsaddam%2Fretry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthedevsaddam%2Fretry/lists"}