Skip to content

anikinmd/gmap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codecov Go Report Card

gmap

Go concurrent generic map

gmap is simple generic based thread safe comparable to any map implementation.

Use map with any type without type casting.

Usage:

// key can be any comparable type
type keyStruct struct {
	str string
	i   int
}

// value can be any type
type valStruct struct {
	b []byte
}

func main() {
	m := gmap.NewGMap[keyStruct, valStruct]()
	m.Set(keyStruct{"a", 1}, valStruct{[]byte{0x1}})
	// Don't need type casting
	val, err := m.Get(keyStruct{"a", 1})
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(val)
}

About

Go concurrent generic map

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages