Maps
map library using Go generics that offers a standard interface, go routine synchronization, and sorting
Install / Use
/learn @goradd/MapsREADME
maps
maps is a library using Go generics that offers a standard interface for manipulating different kinds of maps.
Using the same interface, you can create and use a standard Go map, a map that is safe for concurrency and/or a map that lets you order the keys in the map.
A Set class is included for quickly determining membership in a group.
Example
package main
import . "github.com/goradd/maps"
import "fmt"
type myMap = Map[string,int] // the equal sign here is critical!
type myStdMap = StdMap[string, int]
func main() {
m := new(Map[string, int])
m.Copy(myStdMap{"b":2, "c":3})
m.Set("a",1)
sum := 0
for v := range m.All() {
sum += v
}
fmt.Print(sum)
}
By simply changing myMap to a SafeMap, you can make the map safe for concurrent use. Or, you can change myMap to a SliceMap, or a SafeSliceMap to also be able to iterate the map in the order it was created, similar to a PHP map.
Related Skills
node-connect
344.4kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
99.2kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
344.4kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
344.4kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
