Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

serkodev/singleflight-any

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

singleflight-any

This repo hard forks from golang.org/x/sync/singleflight and support generics to the Group and Key type. Comparing to the original version of singleflight, you are free to use any comparable key type instead of string only.

Install

go get github.com/serkodev/singleflight-any@latest

Usage

string key, string value

var g Group[string, string]
v, _, _ := g.Do("foo", func() (string, error) {
    return "bar", nil
})

int key, string value

var g Group[int, string]
v, _, _ := g.Do(123, func() (string, error) {
    return "bar", nil
})

Requirements

go 1.18 or above.

About

Go singleflight with generics key & value

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.