tysyncmap

Go Reference

Typed version of sync.Map using Go 1.18 generics.

Examples

package main

import (
	"fmt"
	"tysyncmap"
)

func main() {
	m := new(tysyncmap.Map[string, string])
	m.Store("key", "value")
	val, ok := m.Load("key")
	if !ok {
		panic("should have been loaded")
	}
	fmt.Println(val)
}

Output:

value

GitHub

View Github