File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,32 @@ slightly inspired by
1717
1818http get with retry:
1919
20+ url := "http://example.com"
21+ var body []byte
22+
23+ err := retry.Do(
24+ func() error {
25+ resp, err := http.Get(url)
26+ if err != nil {
27+ return err
28+ }
29+ defer resp.Body.Close()
30+ body, err = ioutil.ReadAll(resp.Body)
31+ if err != nil {
32+ return err
33+ }
34+
35+ return nil
36+ },
37+ )
38+ if err != nil {
39+ // handle error
40+ }
41+
42+ fmt.Println(string(body))
43+
44+ http get with retry with data:
45+
2046 url := "http://example.com"
2147
2248 body, err := retry.DoWithData(
Original file line number Diff line number Diff line change @@ -7,6 +7,32 @@ slightly inspired by [Try::Tiny::Retry](https://metacpan.org/pod/Try::Tiny::Retr
77
88http get with retry:
99
10+ url := "http://example.com"
11+ var body []byte
12+
13+ err := retry.Do(
14+ func() error {
15+ resp, err := http.Get(url)
16+ if err != nil {
17+ return err
18+ }
19+ defer resp.Body.Close()
20+ body, err = ioutil.ReadAll(resp.Body)
21+ if err != nil {
22+ return err
23+ }
24+
25+ return nil
26+ },
27+ )
28+ if err != nil {
29+ // handle error
30+ }
31+
32+ fmt.Println(string(body))
33+
34+ http get with retry with data:
35+
1036 url := "http://example.com"
1137
1238 body, err := retry.DoWithData(
You can’t perform that action at this time.
0 commit comments