Go Retry

A small retry helper for Go that exposes go-foundation retry behavior through a compact API.

Features

  • Simple API: Call retry.Do(ctx, fn, attempts) for the common case.
  • Sensible Defaults: Falls back to three attempts when the caller passes a non-positive value.
  • Foundation Backed: Reuses the exponential backoff implementation from go-foundation.
  • Context Aware: Stops retrying when the context is canceled.

Installation

go get github.com/mirkobrombin/go-retry

Quick Start

package main

import (
    "context"
    "errors"

    "github.com/mirkobrombin/go-retry/pkg/retry"
)

func main() {
    err := retry.Do(context.Background(), func() error {
        return errors.New("temporary failure")
    }, 3)
    if err != nil {
        panic(err)
    }
}

Documentation

License

This project is licensed under the MIT License. See the LICENSE file for details.