{"id":20968830,"url":"https://github.com/phachon/retry","last_synced_at":"2025-09-10T03:34:35.901Z","repository":{"id":94427123,"uuid":"173711393","full_name":"phachon/retry","owner":"phachon","description":"a retry go package ","archived":false,"fork":false,"pushed_at":"2019-03-04T10:01:19.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-20T02:53:11.904Z","etag":null,"topics":["golang","retry"],"latest_commit_sha":null,"homepage":null,"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/phachon.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-03-04T09:11:03.000Z","updated_at":"2019-05-10T05:41:19.000Z","dependencies_parsed_at":"2023-03-08T08:00:28.023Z","dependency_job_id":null,"html_url":"https://github.com/phachon/retry","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phachon%2Fretry","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phachon%2Fretry/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phachon%2Fretry/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/phachon%2Fretry/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/phachon","download_url":"https://codeload.github.com/phachon/retry/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243365587,"owners_count":20279212,"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":["golang","retry"],"created_at":"2024-11-19T03:16:57.919Z","updated_at":"2025-03-13T07:43:42.953Z","avatar_url":"https://github.com/phachon.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![stable](https://img.shields.io/badge/stable-stable-green.svg)](https://github.com/phachon/retry/) \n[![build](https://img.shields.io/shippable/5444c5ecb904a4b21567b0ff.svg)](https://travis-ci.org/phachon/retry)\n[![godoc](http://img.shields.io/badge/godoc-reference-blue.svg?style=flat)](https://godoc.org/github.com/phachon/retry)\n[![license](http://img.shields.io/badge/license-MIT-red.svg?style=flat)](https://raw.githubusercontent.com/phachon/retry/master/LICENSE)\n[![go_Report](https://goreportcard.com/badge/github.com/phachon/retry)](https://goreportcard.com/report/github.com/phachon/retry)\n[![platforms](https://img.shields.io/badge/platform-All-yellow.svg?style=flat)]()\n\nHave a good retry.\n\n[中文文档](README_CN.md)\n\n## Feature\n- Support setting retry times\n- Support setting retry interval\n- Support setting retry timeout\n\n## Install\n```bash\ngo get github.com/phachon/retry\n```\n\n## Used\n```go\nimport github.com/phachon/retry\n```\n\n### Simple\n```go\nurl := \"https://api.github.com/\"\nreq, _ := http.NewRequest(\"GET\", url, nil)\nvar res *http.Response\n\nerr := retry.Retry(func() (err error) {\n    res, err = http.DefaultClient.Do(req)\n    if err != nil {\n        return err\n    }\n    return nil\n}, retry.SetRetryCount(2))\nif err != nil {\n    painc(err)\n}\nbody, _ := ioutil.ReadAll(res.Body)\ndefer res.Body.Close()\n\nfmt.Println(string(body))\n```\n\n### Retry interval\n```go\nurl := \"https://api.github.com/\"\nreq, _ := http.NewRequest(\"GET\", url, nil)\nvar res *http.Response\n\nerr := retry.Retry(func() (err error) {\n    res, err = http.DefaultClient.Do(req)\n    if err != nil {\n        return err\n    }\n    return nil\n}, retry.SetRetryCount(3), retry.SetIntervalTime(3 * time.Second))\nif err != nil {\n    panic(err)\n}\n\nbody, _ := ioutil.ReadAll(res.Body)\ndefer res.Body.Close()\n\nfmt.Println(string(body))\n```\n\n### Retry timeout\n```go\nurl := \"https://api.github.com/\"\nreq, _ := http.NewRequest(\"GET\", url, nil)\nvar res *http.Response\n\nerr := retry.Retry(func() (err error) {\n    res, err = http.DefaultClient.Do(req)\n    if err != nil {\n        return err\n    }\n    return nil\n}, retry.SetRetryCount(3), retry.SetRetryTimeout(800 * time.Millisecond))\nif err != nil {\n    panic(err)\n    return\n}\n\nbody, _ := ioutil.ReadAll(res.Body)\ndefer res.Body.Close()\n\nfmt.Println(string(body))\n```\n\n## Feedback\n\n- If you like the project, please [Star](https://github.com/phachon/retry/stargazers).\n- If you have any problems in the process of use, welcome submit [Issue](https://github.com/phachon/retry/issues).\n- If you find and solve bug, welcome submit [Pull Request](https://github.com/phachon/retry/pulls).\n- If you want to redevelop, welcome [Fork](https://github.com/phachon/retry/network/members).\n- If you want to make a friend, welcome send email to [phachon@163.com](mailto:phachon@163.com).\n\n## License\n\nMIT\n\nThanks\n---------\nCreate By phachon@163.com","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphachon%2Fretry","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fphachon%2Fretry","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fphachon%2Fretry/lists"}