Skip to content

A tiny library for retrying failing operations with Go.

License

Notifications You must be signed in to change notification settings

LyricTian/retry

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

retry

A tiny library for retrying failing operations with Go.

License ReportCard Build Coverage GoDoc

Get

go get -u github.com/LyricTian/retry

Usage

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
}

MIT License

    Copyright (c) 2017 Lyric

About

A tiny library for retrying failing operations with Go.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages