Note As of Go 1.18, just use generics.
A tool which generates thread safe maps for Go.
Features:
- Supports any key/value pair supported by Go's native maps
- Allows complex operations via
Lock()
andUnlock()
- Generated code conforms to
golint
andgofmt
- Allows custom types
- Sensible default file name and map name
- Optionally generates using
sync.RWMutex
Generated example located in
examples/
go get -u github.com/s-kirby/mapgen/cmd/mapgen
Create string -> int map:
$ mapgen string/int Wrote string_int_map_gen.goCreate string -> *bytes.Buffer map using a read-write mutex:
$ mapgen --rwmu string/*bytes.Buffer Wrote string_buffer_map_gen.go
Help:
usage: mapgen [<flags>] <keyvalue types> [<tname>] Flags: --help Show context-sensitive help (also try --help-long and --help-man). -p, --pkg="." package name -v, --verbose highly descriptive output -f, --file=FILE output file name --rwmu Use RWMutex Args: <keyvalue types> Key and value types, e.g `string/int` [<tname>] name of generated type
-
Notifications
You must be signed in to change notification settings - Fork 4
Generate thread-safe, type-safe Go maps
License
stirby/mapgen
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
Generate thread-safe, type-safe Go maps
Topics
Resources
License
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published