A tiny library for retrying failing operations with Go.
go get -u github.com/LyricTian/retry
package main
import (
"errors"
"fmt"
"log"
"time"
"github.com/LyricTian/retry"
)
func main() {
var (
count int
value string
)
err := retry.DoFunc(3, func() error {
if count > 1 {
value = "foo"
return nil
}
count++
return errors.New("not allowed")
})
if err != nil {
log.Fatalln(err.Error())
}
fmt.Println(value)
// Output: foo
}
Copyright (c) 2017 Lyric